Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/pr-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ["3.10", "3.11", "3.12"]
python_version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -22,13 +22,13 @@ jobs:
with:
python_version: ${{ matrix.python_version }}
- name: Test
run: poetry run ruff check
run: uv run ruff check
ruff-format:
name: Ruff Format
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ["3.10", "3.11", "3.12"]
python_version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -37,13 +37,13 @@ jobs:
with:
python_version: ${{ matrix.python_version }}
- name: Test
run: poetry run ruff format --check
run: uv run ruff format --check
mypy:
name: Mypy
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ["3.10", "3.11", "3.12"]
python_version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -52,4 +52,4 @@ jobs:
with:
python_version: ${{ matrix.python_version }}
- name: Test
run: poetry run mypy
run: uv run mypy
13 changes: 3 additions & 10 deletions .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@ inputs:
runs:
using: "composite"
steps:
- name: Install Poetry
run: pipx install poetry
shell: bash
- name: Setup Python
uses: actions/setup-python@v5
- name: Setup uv
uses: astral-sh/setup-uv@v10.4.0
with:
python-version: ${{ inputs.python_version }}
cache: 'poetry'
- name: Install Dependencies
run: poetry install
shell: bash
working-directory: ./flixpy
working-directory: ./flixpy
16 changes: 6 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,24 @@ files: ^flixpy/
repos:
- repo: local
hooks:
- id: poetry-check
name: poetry check
entry: poetry -C flixpy check
language: python
pass_filenames: false
files: '^(.*/)?(pyproject.toml|poetry.toml)$'

- id: ruff-check
name: ruff check
entry: poetry -C flixpy run ruff check --force-exclude
entry: uv --directory flixpy run ruff check
language: python
types_or: [python, pyi]
pass_filenames: false

- id: ruff-format
name: ruff format
entry: poetry -C flixpy run ruff format --force-exclude
entry: uv --directory flixpy run ruff format
language: python
types_or: [python, pyi]
pass_filenames: false

- id: mypy
name: mypy
entry: poetry -C flixpy run mypy --config-file flixpy/pyproject.toml
entry: uv --directory flixpy run mypy
language: python
types_or: [python, pyi]
exclude: '.*pb2\w*\.py$'
pass_filenames: false
1 change: 1 addition & 0 deletions flixpy/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
22 changes: 11 additions & 11 deletions flixpy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,36 @@ EXTENSION_API_OUT := $(addprefix $(EXTENSION_DIR),extension_api)

all:build

.download: poetry.lock
poetry install
.download: uv.lock
uv sync
touch $@

$(GRPC_OUT): $(PROTO) .download
poetry run python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. --mypy_out=. --mypy_grpc_out=. $<
uv run python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. --mypy_out=. --mypy_grpc_out=. $<

$(EXTENSION_API_OUT): .download $(addprefix $(EXTENSION_DIR),$(EXTENSION_API_OPENAPI) $(EXTENSION_API_CONFIG)) $(EXTENSION_API_TEMPLATES)
rm -rf $@ && mkdir -p $@
rm -rf $@
cd flix/extension && \
poetry run openapi-python-client update \
uv run openapi-python-client generate \
--path $(EXTENSION_API_OPENAPI) \
--meta none \
--config $(EXTENSION_API_CONFIG) \
--custom-template-path extension_api_templates

.PHONY: typecheck
typecheck: .download
poetry run mypy
uv run mypy

.PHONY: build
build:$(GRPC_OUT) $(EXTENSION_API_OUT) typecheck
poetry build
uv build

.PHONY: publish
publish: build
# requires POETRY_PYPI_TOKEN_PYPI to be set with an api key
poetry publish
# requires UV_PUBLISH_TOKEN to be set with an api key
uv publish

.PHONY: publish_test
publish_test: build
# requires POETRY_PYPI_TOKEN_TESTPYPI to be set with an api key
poetry publish -r testpypi
# requires UV_PUBLISH_TOKEN to be set with an api key
uv publish --index testpypi
14 changes: 5 additions & 9 deletions flixpy/examples/shotgrid_create_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import aiohttp
import flix
import shotgun_api3 # type: ignore[import-untyped]
from shotgun_api3.shotgun import BaseEntity, Shotgun

# ShotGrid credentials and project ID to fetch the project data from
SHOTGRID_BASE_URL = "https://yourstudio.shotgunstudio.com/"
Expand Down Expand Up @@ -49,32 +49,28 @@ class ShotgridProject(TypedDict):
code: str | None


class ShotgridSequence(TypedDict):
class ShotgridSequence(BaseEntity):
"""Typed schema for ShotGrid sequences."""

type: str
id: int
code: str | None
description: str | None


async def import_sg_show() -> None:
"""Create a Flix show from an existing ShotGrid project."""
sg = shotgun_api3.Shotgun(
SHOTGRID_BASE_URL, login=SHOTGRID_USERNAME, password=SHOTGRID_PASSWORD
)
sg = Shotgun(SHOTGRID_BASE_URL, login=SHOTGRID_USERNAME, password=SHOTGRID_PASSWORD)
try:
# fetch the existing ShotGrid project and sequence data
sg_project = cast(
ShotgridProject,
"ShotgridProject",
sg.find_one(
"Project",
[["id", "is", SHOTGRID_PROJECT]],
["id", "name", "sg_description", "image", "code"],
),
)
sg_sequences = cast(
list[ShotgridSequence],
"list[ShotgridSequence]",
sg.find(
"Sequence",
[["project.Project.id", "is", SHOTGRID_PROJECT]],
Expand Down
11 changes: 6 additions & 5 deletions flixpy/examples/shotgrid_version_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
import logging
import os
import tempfile
from typing import TYPE_CHECKING, Literal, TypedDict, cast
from typing import TYPE_CHECKING, Literal, NotRequired, TypedDict, cast

import flix
import shotgun_api3 # type: ignore[import-untyped]
from typing_extensions import NotRequired
from shotgun_api3.shotgun import Shotgun

if TYPE_CHECKING:
import pathlib
Expand All @@ -46,7 +45,7 @@

# create long-lived ShotGrid client so we don't need
# to create a new one for each event
SG = shotgun_api3.Shotgun(SHOTGRID_BASE_URL, login=SHOTGRID_USERNAME, password=SHOTGRID_PASSWORD)
SG = Shotgun(SHOTGRID_BASE_URL, login=SHOTGRID_USERNAME, password=SHOTGRID_PASSWORD)


# optional: typed schemas for our ShotGrid entities for use with Mypy/Pyright
Expand Down Expand Up @@ -122,7 +121,9 @@ async def on_publish(event: flix.PublishEditorialEvent) -> None:
def _upload_to_shotgrid(event: flix.PublishEditorialEvent, quicktime_path: pathlib.Path) -> None:
"""Create a new ShotGrid version from a Flix sequence revision and attach a QuickTime."""
logger.info("Creating new ShotGrid version...")
version = cast(ShotgridVersionWithID, SG.create("Version", _version_from_publish(event)))
version = cast(
"ShotgridVersionWithID", SG.create("Version", dict(_version_from_publish(event)))
)

logger.info("Uploading QuickTime to ShotGrid...")
SG.upload(
Expand Down
4 changes: 2 additions & 2 deletions flixpy/examples/update_sequence_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from __future__ import annotations

import asyncio
import datetime
import datetime as dt
import os

import flix
Expand All @@ -35,7 +35,7 @@ async def update_sequence_metadata() -> None:
print("Current metadata:", sequence.metadata)

# set a single metadata field without persisting to the database
sequence.metadata["processed_time"] = datetime.datetime.now(tz=datetime.timezone.utc)
sequence.metadata["processed_time"] = dt.datetime.now(tz=dt.UTC)

# set multiple metadata fields
sequence.metadata.update(
Expand Down
7 changes: 5 additions & 2 deletions flixpy/flix/cli/interactive_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
port: int,
ssl: bool,
config: dict[str, Any],
*,
username: str | None = None,
password: str | None = None,
access_key: models.AccessKey | None = None,
Expand All @@ -47,8 +48,10 @@ async def _sign_in(self) -> None:
click.echo("Not signed in, attempting to authenticate...", err=True)
self.__config.pop("access_key", None)

username = self.__username or click.prompt("Username", type=str, err=True)
password = self.__password or click.prompt("Password", type=str, hide_input=True, err=True)
username = self.__username or await click.prompt("Username", type=str, err=True)
password = self.__password or await click.prompt(
"Password", type=str, hide_input=True, err=True
)
access_key = await self.authenticate(username, password)
self.__config["access_key"] = access_key.to_json()

Expand Down
Loading
Loading