From be20a9f69626240bbb941e7661d5866a97b736cc Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 29 Nov 2024 10:14:47 +0100 Subject: [PATCH 001/319] Add ShapeFX Loki support --- client/ayon_core/hooks/pre_add_last_workfile_arg.py | 3 ++- client/ayon_core/hooks/pre_ocio_hook.py | 3 ++- client/ayon_core/plugins/publish/validate_file_saved.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/hooks/pre_add_last_workfile_arg.py b/client/ayon_core/hooks/pre_add_last_workfile_arg.py index d5914c2352..0652e7c5aa 100644 --- a/client/ayon_core/hooks/pre_add_last_workfile_arg.py +++ b/client/ayon_core/hooks/pre_add_last_workfile_arg.py @@ -29,7 +29,8 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook): "aftereffects", "wrap", "openrv", - "cinema4d" + "cinema4d", + "loki" } launch_types = {LaunchTypes.local} diff --git a/client/ayon_core/hooks/pre_ocio_hook.py b/client/ayon_core/hooks/pre_ocio_hook.py index 7406aa42cf..6462d1a3ae 100644 --- a/client/ayon_core/hooks/pre_ocio_hook.py +++ b/client/ayon_core/hooks/pre_ocio_hook.py @@ -20,7 +20,8 @@ class OCIOEnvHook(PreLaunchHook): "hiero", "resolve", "openrv", - "cinema4d" + "cinema4d", + "loki" } launch_types = set() diff --git a/client/ayon_core/plugins/publish/validate_file_saved.py b/client/ayon_core/plugins/publish/validate_file_saved.py index f52998cef3..78c243d5aa 100644 --- a/client/ayon_core/plugins/publish/validate_file_saved.py +++ b/client/ayon_core/plugins/publish/validate_file_saved.py @@ -37,7 +37,7 @@ class ValidateCurrentSaveFile(pyblish.api.ContextPlugin): label = "Validate File Saved" order = pyblish.api.ValidatorOrder - 0.1 hosts = ["fusion", "houdini", "max", "maya", "nuke", "substancepainter", - "cinema4d"] + "cinema4d", "loki"] actions = [SaveByVersionUpAction, ShowWorkfilesAction] def process(self, context): From 3ddd64bbc3b12b4bbd2ac6c4d6280a91b6aed81c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 26 Mar 2025 14:22:51 +0100 Subject: [PATCH 002/319] handle project argument --- client/ayon_core/cli.py | 75 +++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 11 deletions(-) diff --git a/client/ayon_core/cli.py b/client/ayon_core/cli.py index 6f89a6d17d..dc8ca44082 100644 --- a/client/ayon_core/cli.py +++ b/client/ayon_core/cli.py @@ -24,22 +24,35 @@ from ayon_core.lib.env_tools import ( ) - @click.group(invoke_without_command=True) @click.pass_context -@click.option("--use-staging", is_flag=True, - expose_value=False, help="use staging variants") -@click.option("--debug", is_flag=True, expose_value=False, - help="Enable debug") -@click.option("--verbose", expose_value=False, - help=("Change AYON log level (debug - critical or 0-50)")) -@click.option("--force", is_flag=True, hidden=True) -def main_cli(ctx, force): +@click.option( + "--use-staging", + is_flag=True, + expose_value=False, + help="use staging variants") +@click.option( + "--debug", + is_flag=True, + expose_value=False, + help="Enable debug") +@click.option( + "--project", + help="Project name") +@click.option( + "--verbose", + expose_value=False, + help="Change AYON log level (debug - critical or 0-50)") +@click.option( + "--use-dev", + is_flag=True, + expose_value=False, + help="use dev bundle") +def main_cli(ctx, *_args, **_kwargs): """AYON is main command serving as entry point to pipeline system. It wraps different commands together. """ - if ctx.invoked_subcommand is None: # Print help if headless mode is used if os.getenv("AYON_HEADLESS_MODE") == "1": @@ -60,7 +73,6 @@ def tray(force): Default action of AYON command is to launch tray widget to control basic aspects of AYON. See documentation for more information. """ - from ayon_core.tools.tray import main main(force) @@ -283,6 +295,43 @@ def _add_addons(addons_manager): ) +def _cleanup_project_args(): + rem_args = list(sys.argv[1:]) + if "--project" not in rem_args: + return + + cmd = None + current_ctx = None + parent_name = "ayon" + parent_cmd = main_cli + while hasattr(parent_cmd, "resolve_command"): + if current_ctx is None: + current_ctx = main_cli.make_context(parent_name, rem_args) + else: + current_ctx = parent_cmd.make_context( + parent_name, + rem_args, + parent=current_ctx + ) + if not rem_args: + break + cmd_name, cmd, rem_args = parent_cmd.resolve_command( + current_ctx, rem_args + ) + parent_name = cmd_name + parent_cmd = cmd + + if cmd is None: + return + + param_names = {param.name for param in cmd.params} + if "project" in param_names: + return + idx = sys.argv.index("--project") + sys.argv.pop(idx) + sys.argv.pop(idx) + + def main(*args, **kwargs): initialize_ayon_connection() python_path = os.getenv("PYTHONPATH", "") @@ -307,10 +356,14 @@ def main(*args, **kwargs): addons_manager = AddonsManager() _set_addons_environments(addons_manager) _add_addons(addons_manager) + + _cleanup_project_args() + try: main_cli( prog_name="ayon", obj={"addons_manager": addons_manager}, + args=(sys.argv[1:]), ) except Exception: # noqa exc_info = sys.exc_info() From 09fe05025c85aecbe3f7635fe8c5c53b559906d2 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 26 Mar 2025 14:23:07 +0100 Subject: [PATCH 003/319] modified settings fetching --- client/ayon_core/settings/lib.py | 68 +++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/client/ayon_core/settings/lib.py b/client/ayon_core/settings/lib.py index aa56fa8326..d251439221 100644 --- a/client/ayon_core/settings/lib.py +++ b/client/ayon_core/settings/lib.py @@ -4,6 +4,7 @@ import logging import collections import copy import time +from urllib.parse import urlencode import ayon_api @@ -35,6 +36,35 @@ class CacheItem: return time.time() > self._outdate_time +def _get_addons_settings( + studio_bundle_name, + project_bundle_name, + variant, + project_name=None, +): + """Modified version of `ayon_api.get_addons_settings` function.""" + query_values = { + key: value + for key, value in ( + ("bundle_name", studio_bundle_name), + ("project_bundle_name ", project_bundle_name), + ("variant", variant), + ("project_name", project_name), + ) + if value + } + site_id = ayon_api.get_site_id() + if site_id: + query_values["site_id"] = site_id + + response = ayon_api.get(f"settings?{urlencode(query_values)}") + response.raise_for_status() + return { + addon["name"]: addon["settings"] + for addon in response.data["addons"] + } + + class _AyonSettingsCache: use_bundles = None variant = None @@ -60,7 +90,7 @@ class _AyonSettingsCache: variant = "production" if is_dev_mode_enabled(): - variant = cls._get_bundle_name() + variant = cls._get_studio_bundle_name() elif is_staging_enabled(): variant = "staging" @@ -72,27 +102,33 @@ class _AyonSettingsCache: return _AyonSettingsCache.variant @classmethod - def _get_bundle_name(cls): + def _get_studio_bundle_name(cls): + bundle_name = os.environ.get("AYON_STUDIO_BUNDLE_NAME") + if bundle_name: + return bundle_name + return os.environ["AYON_BUNDLE_NAME"] + + @classmethod + def _get_project_bundle_name(cls): return os.environ["AYON_BUNDLE_NAME"] @classmethod def get_value_by_project(cls, project_name): cache_item = _AyonSettingsCache.cache_by_project_name[project_name] if cache_item.is_outdated: - if cls._use_bundles(): - value = ayon_api.get_addons_settings( - bundle_name=cls._get_bundle_name(), + cache_item.update_value( + _get_addons_settings( + studio_bundle_name=cls._get_studio_bundle_name(), + project_bundle_name=cls._get_project_bundle_name(), project_name=project_name, - variant=cls._get_variant() + variant=cls._get_variant(), ) - else: - value = ayon_api.get_addons_settings(project_name) - cache_item.update_value(value) + ) return cache_item.get_value() @classmethod def _get_addon_versions_from_bundle(cls): - expected_bundle = cls._get_bundle_name() + expected_bundle = cls._get_project_bundle_name() bundles = ayon_api.get_bundles()["bundles"] bundle = next( ( @@ -110,15 +146,9 @@ class _AyonSettingsCache: def get_addon_versions(cls): cache_item = _AyonSettingsCache.addon_versions if cache_item.is_outdated: - if cls._use_bundles(): - addons = cls._get_addon_versions_from_bundle() - else: - settings_data = ayon_api.get_addons_settings( - only_values=False, - variant=cls._get_variant() - ) - addons = settings_data["versions"] - cache_item.update_value(addons) + cache_item.update_value( + cls._get_addon_versions_from_bundle() + ) return cache_item.get_value() From 0a54f569ceb80e491e21ff1f8b80131191f0c48f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 26 Mar 2025 16:55:26 +0100 Subject: [PATCH 004/319] fix addons discovery --- client/ayon_core/addon/base.py | 25 ++++++++++++++++++++----- client/ayon_core/cli.py | 1 + client/ayon_core/settings/lib.py | 27 ++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index 72270fa585..7d02acf548 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -155,18 +155,33 @@ def load_addons(force=False): def _get_ayon_bundle_data(): + studio_bundle_name = os.environ.get("AYON_STUDIO_BUNDLE_NAME") + project_bundle_name = os.getenv("AYON_BUNDLE_NAME") bundles = ayon_api.get_bundles()["bundles"] - - bundle_name = os.getenv("AYON_BUNDLE_NAME") - - return next( + project_bundle = next( ( bundle for bundle in bundles - if bundle["name"] == bundle_name + if bundle["name"] == project_bundle_name ), None ) + studio_bundle = None + if studio_bundle_name and project_bundle_name != studio_bundle_name: + studio_bundle = next( + ( + bundle + for bundle in bundles + if bundle["name"] == studio_bundle_name + ), + None + ) + + if project_bundle and studio_bundle: + addons = copy.deepcopy(studio_bundle["addons"]) + addons.update(project_bundle["addons"]) + project_bundle["addons"] = addons + return project_bundle def _get_ayon_addons_information(bundle_info): diff --git a/client/ayon_core/cli.py b/client/ayon_core/cli.py index dc8ca44082..8f2abbaeab 100644 --- a/client/ayon_core/cli.py +++ b/client/ayon_core/cli.py @@ -59,6 +59,7 @@ def main_cli(ctx, *_args, **_kwargs): print(ctx.get_help()) sys.exit(0) else: + ctx.params.pop("project") ctx.forward(tray) diff --git a/client/ayon_core/settings/lib.py b/client/ayon_core/settings/lib.py index d251439221..7b4c08bc04 100644 --- a/client/ayon_core/settings/lib.py +++ b/client/ayon_core/settings/lib.py @@ -128,18 +128,35 @@ class _AyonSettingsCache: @classmethod def _get_addon_versions_from_bundle(cls): - expected_bundle = cls._get_project_bundle_name() + studio_bundle_name = cls._get_studio_bundle_name() + project_bundle_name = cls._get_project_bundle_name() bundles = ayon_api.get_bundles()["bundles"] - bundle = next( + project_bundle = next( ( bundle for bundle in bundles - if bundle["name"] == expected_bundle + if bundle["name"] == project_bundle_name ), None ) - if bundle is not None: - return bundle["addons"] + studio_bundle = None + if studio_bundle_name and project_bundle_name != studio_bundle_name: + studio_bundle = next( + ( + bundle + for bundle in bundles + if bundle["name"] == studio_bundle_name + ), + None + ) + + if studio_bundle and project_bundle: + addons = copy.deepcopy(studio_bundle["addons"]) + addons.update(project_bundle["addons"]) + project_bundle["addons"] = addons + + if project_bundle is not None: + return project_bundle["addons"] return {} @classmethod From a8baf72a7fd583fb8fb8f7701b295e00d428b907 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 26 Mar 2025 17:01:54 +0100 Subject: [PATCH 005/319] automatically restart tray if is running in project bundle mode --- client/ayon_core/tools/tray/ui/tray.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/ayon_core/tools/tray/ui/tray.py b/client/ayon_core/tools/tray/ui/tray.py index aad89b6081..f090be063e 100644 --- a/client/ayon_core/tools/tray/ui/tray.py +++ b/client/ayon_core/tools/tray/ui/tray.py @@ -240,6 +240,11 @@ class TrayManager: self.log.warning("Other tray started meanwhile. Exiting.") self.exit() + project_bundle = os.getenv("AYON_BUNDLE_NAME") + studio_bundle = os.getenv("AYON_STUDIO_BUNDLE_NAME") + if studio_bundle and project_bundle != studio_bundle: + self.restart() + def get_services_submenu(self): return self._services_submenu @@ -270,11 +275,18 @@ class TrayManager: elif is_staging_enabled(): additional_args.append("--use-staging") + if "--project" in additional_args: + idx = additional_args.index("--project") + additional_args.pop(idx) + additional_args.pop(idx) + args.extend(additional_args) envs = dict(os.environ.items()) for key in { "AYON_BUNDLE_NAME", + "AYON_STUDIO_BUNDLE_NAME", + "AYON_PROJECT_NAME", }: envs.pop(key, None) @@ -329,6 +341,7 @@ class TrayManager: return json_response({ "username": self._cached_username, "bundle": os.getenv("AYON_BUNDLE_NAME"), + "studio_bundle": os.getenv("AYON_STUDIO_BUNDLE_NAME"), "dev_mode": is_dev_mode_enabled(), "staging_mode": is_staging_enabled(), "addons": { @@ -516,6 +529,8 @@ class TrayManager: "AYON_SERVER_URL", "AYON_API_KEY", "AYON_BUNDLE_NAME", + "AYON_STUDIO_BUNDLE_NAME", + "AYON_PROJECT_NAME", }: os.environ.pop(key, None) self.restart() @@ -549,6 +564,8 @@ class TrayManager: envs = dict(os.environ.items()) for key in { "AYON_BUNDLE_NAME", + "AYON_STUDIO_BUNDLE_NAME", + "AYON_PROJECT_NAME", }: envs.pop(key, None) From c194fe2dd2c1016827dce3fcf2f162c5888a6c1b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 27 Mar 2025 07:44:10 +0100 Subject: [PATCH 006/319] set project bundle name only if is different from studio bundle name --- client/ayon_core/settings/lib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/settings/lib.py b/client/ayon_core/settings/lib.py index 7b4c08bc04..cd219a153b 100644 --- a/client/ayon_core/settings/lib.py +++ b/client/ayon_core/settings/lib.py @@ -47,12 +47,14 @@ def _get_addons_settings( key: value for key, value in ( ("bundle_name", studio_bundle_name), - ("project_bundle_name ", project_bundle_name), ("variant", variant), ("project_name", project_name), ) if value } + if project_bundle_name != studio_bundle_name: + query_values["project_bundle_name"] = project_bundle_name + site_id = ayon_api.get_site_id() if site_id: query_values["site_id"] = site_id From 3483a7bd0ed9a4c3d9e1f99832ddb9524db3a8b6 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 5 May 2025 12:02:22 +0200 Subject: [PATCH 007/319] Updates plugin families Removes "circuit" from plugin families and adds "batchdelivery" to align with current project needs. This change ensures that the collect, extract, and review processes are correctly associated with the appropriate families, streamlining publishing workflows. --- client/ayon_core/plugins/publish/collect_audio.py | 2 +- client/ayon_core/plugins/publish/extract_burnin.py | 2 +- client/ayon_core/plugins/publish/extract_review.py | 2 +- client/ayon_core/plugins/publish/extract_thumbnail.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_audio.py b/client/ayon_core/plugins/publish/collect_audio.py index 57c69ef2b2..069082af37 100644 --- a/client/ayon_core/plugins/publish/collect_audio.py +++ b/client/ayon_core/plugins/publish/collect_audio.py @@ -39,7 +39,7 @@ class CollectAudio(pyblish.api.ContextPlugin): "blender", "houdini", "max", - "circuit", + "batchdelivery", ] audio_product_name = "audioMain" diff --git a/client/ayon_core/plugins/publish/extract_burnin.py b/client/ayon_core/plugins/publish/extract_burnin.py index 3f7c2f4cba..4b285d9990 100644 --- a/client/ayon_core/plugins/publish/extract_burnin.py +++ b/client/ayon_core/plugins/publish/extract_burnin.py @@ -55,7 +55,7 @@ class ExtractBurnin(publish.Extractor): "max", "blender", "unreal", - "circuit", + "batchdelivery", ] optional = True diff --git a/client/ayon_core/plugins/publish/extract_review.py b/client/ayon_core/plugins/publish/extract_review.py index a15886451b..7a0627d05c 100644 --- a/client/ayon_core/plugins/publish/extract_review.py +++ b/client/ayon_core/plugins/publish/extract_review.py @@ -92,7 +92,7 @@ class ExtractReview(pyblish.api.InstancePlugin): "aftereffects", "flame", "unreal", - "circuit", + "batchdelivery", ] # Supported extensions diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 3a428c46a7..b4309a6038 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -40,7 +40,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): "aftereffects", "unreal", "houdini", - "circuit", + "batchdelivery", ] enabled = False From 10c66f496e911b105c7ce34818d10bd471059a14 Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 14:39:26 +0200 Subject: [PATCH 008/319] first version Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 78 +++++++++++++++++++++++++++++ docs/mkdocs_requirements.txt | 9 ++++ 2 files changed, 87 insertions(+) create mode 100644 .github/workflows/deploy_mkdocs.yml create mode 100644 docs/mkdocs_requirements.txt diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml new file mode 100644 index 0000000000..9fd97c1e82 --- /dev/null +++ b/.github/workflows/deploy_mkdocs.yml @@ -0,0 +1,78 @@ +name: Deploy MkDocs + +on: + workflow_dispatch: + workflow_call: + inputs: + repo: + type: string + required: true + branch_name: + type: string + required: true + default: "main" + tag: + type: string + required: true + secrets: + token: + required: true + user: + required: true + email: + required: true + +env: + GH_TOKEN: ${{ secrets.token || secrets.YNPUT_BOT_TOKEN }} + GH_USER: ${{ secrets.user || secrets.CI_USER }} + GH_EMAIL: ${{ secrets.email || secrets.CI_EMAIL }} + +jobs: + + verify-latest-release: + uses: ynput/ops-repo-automation/.github/workflows/verify_latest_release.yml@main + with: + repo: ${{ github.repository }} + expect_release: true + secrets: + gh_token: ${{ secrets.token }} + + verify-repo-secrets: + uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@main + with: + repo: ${{ github.repository }} + secrets: + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} + + verify-repo-vars: + uses: ynput/ops-repo-automation/.github/workflows/verify_variables.yml@main + with: + variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" + repo: ${{ github.repository }} + secrets: + gh_token: ${{ secrets.token }} + + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout ${{ inputs.branch_name }} + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch_name }} + fetch-depth: 0 + submodules: true + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python3 -m pip install -r ./docs/mkdocs_requirements.txt + + - name: Mike deploy + run: mike deploy --update-aliases ${{ inputs.tag }} latest diff --git a/docs/mkdocs_requirements.txt b/docs/mkdocs_requirements.txt new file mode 100644 index 0000000000..829d02951a --- /dev/null +++ b/docs/mkdocs_requirements.txt @@ -0,0 +1,9 @@ +mkdocs-material >= 9.6.7 +mkdocs-autoapi >= 0.4.0 +mkdocstrings-python >= 1.16.2 +mkdocs-minify-plugin >= 0.8.0 +markdown-checklist >= 0.4.4 +mdx-gh-links >= 0.4 +pymdown-extensions >= 10.14.3 +mike >= 2.1.3 +mkdocstrings-shell >= 1.0.2 From bd1dd87d242ee3d637133bea0e84ee64c2b76172 Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 16:41:16 +0200 Subject: [PATCH 009/319] can I test this ? Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index 9fd97c1e82..fcee1dd3c2 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -1,6 +1,7 @@ name: Deploy MkDocs on: + pull_request: workflow_dispatch: workflow_call: inputs: From 4977e771224ed202d76d11c6bfd6187d37812240 Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 16:44:05 +0200 Subject: [PATCH 010/319] remove some tests Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index fcee1dd3c2..80e69b8fa1 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -30,13 +30,13 @@ env: jobs: - verify-latest-release: - uses: ynput/ops-repo-automation/.github/workflows/verify_latest_release.yml@main - with: - repo: ${{ github.repository }} - expect_release: true - secrets: - gh_token: ${{ secrets.token }} +# verify-latest-release: +# uses: ynput/ops-repo-automation/.github/workflows/verify_latest_release.yml@main +# with: +# repo: ${{ github.repository }} +# expect_release: true +# secrets: +# gh_token: ${{ secrets.token }} verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@main @@ -47,13 +47,13 @@ jobs: gh_user: ${{ secrets.user }} gh_email: ${{ secrets.email }} - verify-repo-vars: - uses: ynput/ops-repo-automation/.github/workflows/verify_variables.yml@main - with: - variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" - repo: ${{ github.repository }} - secrets: - gh_token: ${{ secrets.token }} +# verify-repo-vars: +# uses: ynput/ops-repo-automation/.github/workflows/verify_variables.yml@main +# with: +# variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" +# repo: ${{ github.repository }} +# secrets: +# gh_token: ${{ secrets.token }} deploy: runs-on: ubuntu-latest From dc9d65d9b85d6a4afe5eda2e3638facf2d7d2c6a Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 17:01:09 +0200 Subject: [PATCH 011/319] fix authentification error Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index 80e69b8fa1..98866eb43e 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -66,6 +66,11 @@ jobs: fetch-depth: 0 submodules: true + - name: 🔑 Set Authentication + run: | + git config --global user.name "${{ secrets.user }}" + git config --global user.email "${{ secrets.email }}" + - name: Set up Python uses: actions/setup-python@v4 with: From 5899f484a5d242904b5ee21808b2c53249deadc7 Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 17:10:26 +0200 Subject: [PATCH 012/319] better authentification fix Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index 98866eb43e..8c05985613 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -68,8 +68,8 @@ jobs: - name: 🔑 Set Authentication run: | - git config --global user.name "${{ secrets.user }}" - git config --global user.email "${{ secrets.email }}" + git config --global user.name "${{ secrets.user || secrets.CI_USER }}" + git config --global user.email "${{ secrets.email || secrets.CI_EMAIL }}" - name: Set up Python uses: actions/setup-python@v4 From b5006abc8b51bf18f7ba4fa083925df364877692 Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 17:15:09 +0200 Subject: [PATCH 013/319] display tag Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index 8c05985613..49f6cfafba 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -80,5 +80,5 @@ jobs: run: | python3 -m pip install -r ./docs/mkdocs_requirements.txt - - name: Mike deploy + - name: Mike deploy ${{ inputs.tag }} run: mike deploy --update-aliases ${{ inputs.tag }} latest From 71a5a4603020905dbd2a33751b4f24030bbabadb Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 17:38:41 +0200 Subject: [PATCH 014/319] Get the current tag with fallback to 1.0.0 Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 30 ++++++++--------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index 49f6cfafba..2e6329f924 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -12,9 +12,6 @@ on: type: string required: true default: "main" - tag: - type: string - required: true secrets: token: required: true @@ -29,15 +26,6 @@ env: GH_EMAIL: ${{ secrets.email || secrets.CI_EMAIL }} jobs: - -# verify-latest-release: -# uses: ynput/ops-repo-automation/.github/workflows/verify_latest_release.yml@main -# with: -# repo: ${{ github.repository }} -# expect_release: true -# secrets: -# gh_token: ${{ secrets.token }} - verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@main with: @@ -47,14 +35,6 @@ jobs: gh_user: ${{ secrets.user }} gh_email: ${{ secrets.email }} -# verify-repo-vars: -# uses: ynput/ops-repo-automation/.github/workflows/verify_variables.yml@main -# with: -# variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" -# repo: ${{ github.repository }} -# secrets: -# gh_token: ${{ secrets.token }} - deploy: runs-on: ubuntu-latest @@ -71,6 +51,12 @@ jobs: git config --global user.name "${{ secrets.user || secrets.CI_USER }}" git config --global user.email "${{ secrets.email || secrets.CI_EMAIL }}" + - name: Get current tag + id: git_tag + uses: "devops-actions/action-get-tag@v1.0.3" + with: + default: 1.0.0 + - name: Set up Python uses: actions/setup-python@v4 with: @@ -80,5 +66,5 @@ jobs: run: | python3 -m pip install -r ./docs/mkdocs_requirements.txt - - name: Mike deploy ${{ inputs.tag }} - run: mike deploy --update-aliases ${{ inputs.tag }} latest + - name: Mike deploy ${{ steps.git_tag.outputs.tag }} + run: mike deploy --update-aliases ${{ steps.git_tag.outputs.tag }} latest From 17fbd5228cad7a867137751f2a0ceb125f10f0a0 Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 17:43:42 +0200 Subject: [PATCH 015/319] remove quotes Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index 2e6329f924..a8281a1de0 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -53,7 +53,7 @@ jobs: - name: Get current tag id: git_tag - uses: "devops-actions/action-get-tag@v1.0.3" + uses: devops-actions/action-get-tag@v1.0.3 with: default: 1.0.0 From 18c0299bfb9a1812a485d8c454f68f5d165f5271 Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 17:47:57 +0200 Subject: [PATCH 016/319] fix missing branch name Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index a8281a1de0..4d6fd9104e 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -39,10 +39,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout ${{ inputs.branch_name }} + - name: Checkout ${{ inputs.branch_name || 'main' }} uses: actions/checkout@v4 with: - ref: ${{ inputs.branch_name }} + ref: ${{ inputs.branch_name || 'main' }} fetch-depth: 0 submodules: true From 539be6c5270dbdfe739df9d2ccda8b59cc7b7340 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 9 May 2025 17:51:51 +0200 Subject: [PATCH 017/319] Handles OCIO shared view token The OCIO config can return a special token "" as the colorspace name for a display view. This commit implements handling for this token, replacing it with the display name if found. --- client/ayon_core/pipeline/colorspace.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/colorspace.py b/client/ayon_core/pipeline/colorspace.py index 8c4f97ab1c..79aea391eb 100644 --- a/client/ayon_core/pipeline/colorspace.py +++ b/client/ayon_core/pipeline/colorspace.py @@ -1403,7 +1403,12 @@ def _get_display_view_colorspace_name(config_path, display, view): """ config = _get_ocio_config(config_path) - return config.getDisplayViewColorSpaceName(display, view) + colorspace = config.getDisplayViewColorSpaceName(display, view) + # Special token. See https://opencolorio.readthedocs.io/en/latest/guides/authoring/authoring.html#shared-views # noqa + if colorspace == "": + colorspace = display + + return colorspace def _get_ocio_config_colorspaces(config_path): From af9fd17ee8108f4a13b9777fa9daf68e3a09fa74 Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 9 May 2025 17:55:49 +0200 Subject: [PATCH 018/319] format Signed-off-by: Philippe Leprince --- .github/workflows/deploy_mkdocs.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index 4d6fd9104e..2f46bdc6ad 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -21,28 +21,28 @@ on: required: true env: - GH_TOKEN: ${{ secrets.token || secrets.YNPUT_BOT_TOKEN }} - GH_USER: ${{ secrets.user || secrets.CI_USER }} - GH_EMAIL: ${{ secrets.email || secrets.CI_EMAIL }} + GH_TOKEN: ${{ secrets.token || secrets.YNPUT_BOT_TOKEN }} + GH_USER: ${{ secrets.user || secrets.CI_USER }} + GH_EMAIL: ${{ secrets.email || secrets.CI_EMAIL }} jobs: verify-repo-secrets: - uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@main - with: - repo: ${{ github.repository }} - secrets: - gh_token: ${{ secrets.token }} - gh_user: ${{ secrets.user }} - gh_email: ${{ secrets.email }} + uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@main + with: + repo: ${{ github.repository }} + secrets: + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} deploy: runs-on: ubuntu-latest steps: - - name: Checkout ${{ inputs.branch_name || 'main' }} + - name: Checkout ${{ inputs.branch_name}} uses: actions/checkout@v4 with: - ref: ${{ inputs.branch_name || 'main' }} + ref: ${{ inputs.branch_name}} fetch-depth: 0 submodules: true From dba8d78a2abc79583d64016c46b6aa5df13916bb Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 20 May 2025 10:53:37 +0200 Subject: [PATCH 019/319] Refactors color space conversion with oiiotool Consolidates color space conversion logic into a dedicated `oiiotool_transcode` function for better flexibility and clarity. This change introduces support for display/view transformations, enhancing the tool's ability to handle complex color management workflows. It also fixes issues with conflicting color space parameters and improves handling of source and target display/view configurations. --- client/ayon_core/lib/transcoding.py | 170 ++++++++++++++++-- .../publish/extract_color_transcode.py | 42 +++-- .../plugins/publish/extract_thumbnail.py | 10 +- 3 files changed, 184 insertions(+), 38 deletions(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index 8c84e1c4dc..6648f5219e 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -977,7 +977,60 @@ def convert_colorspace( additional_command_args=None, logger=None, ): - """Convert source file from one color space to another. + """Backward compatibility function for convert_colorspace. + + Args: + input_path (str): Path to input file that should be converted. + output_path (str): Path to output file where result will be stored. + config_path (str): Path to OCIO config file. + source_colorspace (str): OCIO valid color space of source files. + target_colorspace (str, optional): OCIO valid target color space. + If filled, 'view' and 'display' must be empty. + view (str, optional): Name for target viewer space (OCIO valid). + Both 'view' and 'display' must be filled (if not 'target_colorspace'). + display (str, optional): Name for target display-referred reference space. + Both 'view' and 'display' must be filled (if not 'target_colorspace'). + additional_command_args (list, optional): Additional arguments for oiiotool + (like binary depth for .dpx). + logger (logging.Logger, optional): Logger used for logging. + + Returns: + None: Function returns None. + + Raises: + ValueError: If parameters are misconfigured. + """ + return oiiotool_transcode( + input_path, + output_path, + config_path, + source_colorspace, + target_colorspace=target_colorspace, + target_display=display, + target_view=view, + additional_command_args=additional_command_args, + logger=logger, + ) + + +def oiiotool_transcode( + input_path, + output_path, + config_path, + source_colorspace, + source_display=None, + source_view=None, + target_colorspace=None, + target_display=None, + target_view=None, + additional_command_args=None, + logger=None, +): + """Transcode source file to other with colormanagement. + + Oiiotool also support additional arguments for transcoding. + For more information, see the official documentation: + https://openimageio.readthedocs.io/en/latest/oiiotool.html Args: input_path (str): Path that should be converted. It is expected that @@ -989,17 +1042,26 @@ def convert_colorspace( sequence in 'file.FRAMESTART-FRAMEEND#.ext', `output.1-3#.tif`) config_path (str): path to OCIO config file source_colorspace (str): ocio valid color space of source files + source_display (str, optional): name for source display-referred + reference space (ocio valid). If provided, source_view must also be + provided, and source_colorspace will be ignored + source_view (str, optional): name for source viewer space (ocio valid) + If provided, source_display must also be provided, and + source_colorspace will be ignored target_colorspace (str): ocio valid target color space if filled, 'view' and 'display' must be empty - view (str): name for viewer space (ocio valid) - both 'view' and 'display' must be filled (if 'target_colorspace') - display (str): name for display-referred reference space (ocio valid) + target_display (str): name for target display-referred reference space + (ocio valid) both 'view' and 'display' must be filled (if + 'target_colorspace') + target_view (str): name for target viewer space (ocio valid) both 'view' and 'display' must be filled (if 'target_colorspace') additional_command_args (list): arguments for oiiotool (like binary depth for .dpx) logger (logging.Logger): Logger used for logging. + Raises: ValueError: if misconfigured + """ if logger is None: logger = logging.getLogger(__name__) @@ -1024,23 +1086,99 @@ def convert_colorspace( "--ch", channels_arg ]) - if all([target_colorspace, view, display]): - raise ValueError("Colorspace and both screen and display" - " cannot be set together." - "Choose colorspace or screen and display") - if not target_colorspace and not all([view, display]): - raise ValueError("Both screen and display must be set.") + # Validate input parameters + if all([target_colorspace, target_view, target_display]): + raise ValueError( + "Colorspace and both screen and display cannot be set together." + "Choose colorspace or screen and display" + ) + + if all([source_view, source_display]) and source_colorspace: + logger.warning( + "Both source display/view and source_colorspace provided. " + "Using source display/view pair and ignoring source_colorspace." + ) + + if not target_colorspace and not all([target_view, target_display]): + raise ValueError( + "Both screen and display must be set if target_colorspace is not " + "provided." + ) + + if ((source_view and not source_display) or + (source_display and not source_view)): + raise ValueError( + "Both source_view and source_display must be provided if using " + "display/view inputs." + ) if additional_command_args: oiio_cmd.extend(additional_command_args) + # Handle the different conversion cases if target_colorspace: - oiio_cmd.extend(["--colorconvert:subimages=0", - source_colorspace, - target_colorspace]) - if view and display: - oiio_cmd.extend(["--iscolorspace", source_colorspace]) - oiio_cmd.extend(["--ociodisplay:subimages=0", display, view]) + # Case 1: Converting to a named colorspace + if all([source_view, source_display]): + # First convert from source display/view to a role/reference space + # that can be used with colorconvert + # For example, converting to "scene_linear" or an appropriate + # intermediate space + # This is a two-step conversion process since there's no direct + # display/view to colorspace command + # This could be a config parameter or determined from OCIO config + tmp_role_space = "scene_linear" + oiio_cmd.extend([ + "--ociodisplay:inverse=1:subimages=0", source_display, + source_view, "--colorconvert:subimages=0", tmp_role_space, + target_colorspace, + ]) + else: + # Standard color space to color space conversion + oiio_cmd.extend([ + "--colorconvert:subimages=0", source_colorspace, + target_colorspace, + ]) + else: # Using display/view target + if all([source_view, source_display]): + if source_display == target_display and source_view == target_view: + # No conversion needed if source and target display/view are + # the same + logger.debug( + "Source and target display/view pairs are identical. " + "No color conversion needed." + ) + elif source_display == target_display: + # When only the view changes but display stays the same + # First convert from source view to a reference space, then to + # target view + # This could be configured + tmp_role_space = "scene_linear" + oiio_cmd.extend([ + "--ociodisplay:inverse=1:subimages=0", + source_display, + source_view, + "--ociodisplay:subimages=0", + target_display, + target_view, + ]) + else: + # Complete display/view pair conversion + # Similar approach: go through a reference space + # This could be configured + tmp_role_space = "scene_linear" + oiio_cmd.extend([ + "--ociodisplay:inverse=1:subimages=0", + source_display, + source_view, "--ociodisplay:subimages=0", + target_display, + target_view, + ]) + else: + # Standard conversion from colorspace to display/view + oiio_cmd.extend([ + "--iscolorspace", source_colorspace, + "--ociodisplay:subimages=0", target_display, target_view, + ]) oiio_cmd.extend(["-o", output_path]) diff --git a/client/ayon_core/plugins/publish/extract_color_transcode.py b/client/ayon_core/plugins/publish/extract_color_transcode.py index 6cf30857a4..f61379189c 100644 --- a/client/ayon_core/plugins/publish/extract_color_transcode.py +++ b/client/ayon_core/plugins/publish/extract_color_transcode.py @@ -11,7 +11,7 @@ from ayon_core.lib import ( is_oiio_supported, ) from ayon_core.lib.transcoding import ( - convert_colorspace, + oiiotool_transcode, ) from ayon_core.lib.profiles_filtering import filter_profiles @@ -94,6 +94,8 @@ class ExtractOIIOTranscode(publish.Extractor): colorspace_data = repre["colorspaceData"] source_colorspace = colorspace_data["colorspace"] + source_display = colorspace_data.get("display") + source_view = colorspace_data.get("view") config_path = colorspace_data.get("config", {}).get("path") if not config_path or not os.path.exists(config_path): self.log.warning("Config file doesn't exist, skipping") @@ -124,7 +126,7 @@ class ExtractOIIOTranscode(publish.Extractor): transcoding_type = output_def["transcoding_type"] - target_colorspace = view = display = None + target_colorspace = target_view = target_display = None # NOTE: we use colorspace_data as the fallback values for # the target colorspace. if transcoding_type == "colorspace": @@ -136,18 +138,20 @@ class ExtractOIIOTranscode(publish.Extractor): colorspace_data.get("colorspace")) elif transcoding_type == "display_view": display_view = output_def["display_view"] - view = display_view["view"] or colorspace_data.get("view") - display = ( + target_view = ( + display_view["view"] + or colorspace_data.get("view")) + target_display = ( display_view["display"] or colorspace_data.get("display") ) # both could be already collected by DCC, # but could be overwritten when transcoding - if view: - new_repre["colorspaceData"]["view"] = view - if display: - new_repre["colorspaceData"]["display"] = display + if target_view: + new_repre["colorspaceData"]["view"] = target_view + if target_display: + new_repre["colorspaceData"]["display"] = target_display if target_colorspace: new_repre["colorspaceData"]["colorspace"] = \ target_colorspace @@ -166,16 +170,18 @@ class ExtractOIIOTranscode(publish.Extractor): new_staging_dir, output_extension) - convert_colorspace( - input_path, - output_path, - config_path, - source_colorspace, - target_colorspace, - view, - display, - additional_command_args, - self.log + oiiotool_transcode( + input_path=input_path, + output_path=output_path, + config_path=config_path, + source_colorspace=source_colorspace, + target_colorspace=target_colorspace, + target_display=target_display, + target_view=target_view, + source_display=source_display, + source_view=source_view, + additional_command_args=additional_command_args, + logger=self.log ) # cleanup temporary transcoded files diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 3a428c46a7..f65308121b 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -15,7 +15,7 @@ from ayon_core.lib import ( path_to_subprocess_arg, run_subprocess, ) -from ayon_core.lib.transcoding import convert_colorspace +from ayon_core.lib.transcoding import oiiotool_transcode from ayon_core.lib.transcoding import VIDEO_EXTENSIONS, IMAGE_EXTENSIONS @@ -431,13 +431,15 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): oiio_default_view = display_and_view["view"] try: - convert_colorspace( + oiiotool_transcode( src_path, dst_path, colorspace_data["config"]["path"], colorspace_data["colorspace"], - display=repre_display or oiio_default_display, - view=repre_view or oiio_default_view, + source_display=colorspace_data.get("display"), + source_view=colorspace_data.get("view"), + target_display=repre_display or oiio_default_display, + target_view=repre_view or oiio_default_view, target_colorspace=oiio_default_colorspace, additional_command_args=resolution_arg, logger=self.log, From 08f6b61a3e5f4d91d8a4d7247024a14fe9067d27 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 20 May 2025 11:19:14 +0200 Subject: [PATCH 020/319] Adds deprecation decorator and marks function Introduces a `deprecated` decorator to mark functions as deprecated, issuing a warning when they are called. The `convert_colorspace` function is marked as deprecated, advising users to switch to `oiiotool_transcode`. --- client/ayon_core/lib/transcoding.py | 90 +++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 24 deletions(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index 6648f5219e..e62873184d 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -6,6 +6,8 @@ import collections import tempfile import subprocess import platform +import warnings +import functools from typing import Optional import xml.etree.ElementTree @@ -67,6 +69,48 @@ VIDEO_EXTENSIONS = { } + +def deprecated(new_destination): + """Mark functions as deprecated. + + It will result in a warning being emitted when the function is used. + """ + + func = None + if callable(new_destination): + func = new_destination + new_destination = None + + def _decorator(decorated_func): + if new_destination is None: + warning_message = ( + " Please check content of deprecated function to figure out" + " possible replacement." + ) + else: + warning_message = " Please replace your usage with '{}'.".format( + new_destination + ) + + @functools.wraps(decorated_func) + def wrapper(*args, **kwargs): + warnings.simplefilter("always", DeprecationWarning) + warnings.warn( + ( + "Call to deprecated function '{}'" + "\nFunction was moved or removed.{}" + ).format(decorated_func.__name__, warning_message), + category=DeprecationWarning, + stacklevel=4 + ) + return decorated_func(*args, **kwargs) + return wrapper + + if func is None: + return _decorator + return _decorator(func) + + def get_transcode_temp_directory(): """Creates temporary folder for transcoding. @@ -966,6 +1010,8 @@ def convert_ffprobe_fps_to_float(value): return dividend / divisor +# --- Deprecated functions --- +@deprecated("oiiotool_transcode") def convert_colorspace( input_path, output_path, @@ -977,7 +1023,7 @@ def convert_colorspace( additional_command_args=None, logger=None, ): - """Backward compatibility function for convert_colorspace. + """DEPRECATED function use `oiiotool_transcode` instead Args: input_path (str): Path to input file that should be converted. @@ -1105,8 +1151,10 @@ def oiiotool_transcode( "provided." ) - if ((source_view and not source_display) or - (source_display and not source_view)): + if ( + (source_view and not source_display) + or (source_display and not source_view) + ): raise ValueError( "Both source_view and source_display must be provided if using " "display/view inputs." @@ -1128,14 +1176,18 @@ def oiiotool_transcode( # This could be a config parameter or determined from OCIO config tmp_role_space = "scene_linear" oiio_cmd.extend([ - "--ociodisplay:inverse=1:subimages=0", source_display, - source_view, "--colorconvert:subimages=0", tmp_role_space, + "--ociodisplay:inverse=1:subimages=0", + source_display, + source_view, + "--colorconvert:subimages=0", + tmp_role_space, target_colorspace, ]) else: # Standard color space to color space conversion oiio_cmd.extend([ - "--colorconvert:subimages=0", source_colorspace, + "--colorconvert:subimages=0", + source_colorspace, target_colorspace, ]) else: # Using display/view target @@ -1147,10 +1199,9 @@ def oiiotool_transcode( "Source and target display/view pairs are identical. " "No color conversion needed." ) - elif source_display == target_display: - # When only the view changes but display stays the same - # First convert from source view to a reference space, then to - # target view + else: + # Complete display/view pair conversion + # Similar approach: go through a reference space # This could be configured tmp_role_space = "scene_linear" oiio_cmd.extend([ @@ -1161,23 +1212,14 @@ def oiiotool_transcode( target_display, target_view, ]) - else: - # Complete display/view pair conversion - # Similar approach: go through a reference space - # This could be configured - tmp_role_space = "scene_linear" - oiio_cmd.extend([ - "--ociodisplay:inverse=1:subimages=0", - source_display, - source_view, "--ociodisplay:subimages=0", - target_display, - target_view, - ]) else: # Standard conversion from colorspace to display/view oiio_cmd.extend([ - "--iscolorspace", source_colorspace, - "--ociodisplay:subimages=0", target_display, target_view, + "--iscolorspace", + source_colorspace, + "--ociodisplay:subimages=0", + target_display, + target_view, ]) oiio_cmd.extend(["-o", output_path]) From 4ebf35dd8b68ef10a66551ef47276516a291e360 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 20 May 2025 11:26:28 +0200 Subject: [PATCH 021/319] Refactors docstring formatting in transcoding Improves readability by adjusting docstring formatting in the `convert_colorspace` function. This change ensures consistent documentation style and enhances clarity. --- client/ayon_core/lib/transcoding.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index e62873184d..4f985d5128 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -69,7 +69,6 @@ VIDEO_EXTENSIONS = { } - def deprecated(new_destination): """Mark functions as deprecated. @@ -1033,11 +1032,13 @@ def convert_colorspace( target_colorspace (str, optional): OCIO valid target color space. If filled, 'view' and 'display' must be empty. view (str, optional): Name for target viewer space (OCIO valid). - Both 'view' and 'display' must be filled (if not 'target_colorspace'). - display (str, optional): Name for target display-referred reference space. - Both 'view' and 'display' must be filled (if not 'target_colorspace'). - additional_command_args (list, optional): Additional arguments for oiiotool - (like binary depth for .dpx). + Both 'view' and 'display' must be filled + (if not 'target_colorspace'). + display (str, optional): Name for target display-referred + reference space. Both 'view' and 'display' must be filled + (if not 'target_colorspace'). + additional_command_args (list, optional): Additional arguments + for oiiotool (like binary depth for .dpx). logger (logging.Logger, optional): Logger used for logging. Returns: From 0b20e49eda6eb85b3b3c32039ee24a3880fc12e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Je=C5=BEek?= Date: Fri, 6 Jun 2025 16:07:06 +0200 Subject: [PATCH 022/319] Update client/ayon_core/pipeline/colorspace.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/pipeline/colorspace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/colorspace.py b/client/ayon_core/pipeline/colorspace.py index a7d1d80b0a..41241e17ca 100644 --- a/client/ayon_core/pipeline/colorspace.py +++ b/client/ayon_core/pipeline/colorspace.py @@ -1404,7 +1404,7 @@ def _get_display_view_colorspace_name(config_path, display, view): """ config = _get_ocio_config(config_path) colorspace = config.getDisplayViewColorSpaceName(display, view) - # Special token. See https://opencolorio.readthedocs.io/en/latest/guides/authoring/authoring.html#shared-views # noqa + # Special token. See https://opencolorio.readthedocs.io/en/latest/guides/authoring/authoring.html#shared-views # noqa if colorspace == "": colorspace = display From 21737339d37432cc62f83d88839711f6dc5e32fd Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 12 Jun 2025 15:46:23 +0200 Subject: [PATCH 023/319] rename 'oiiotool_transcode' to 'oiio_color_convert' --- client/ayon_core/lib/transcoding.py | 8 ++++---- .../ayon_core/plugins/publish/extract_color_transcode.py | 4 ++-- client/ayon_core/plugins/publish/extract_thumbnail.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index 4f985d5128..97e9f417f0 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -1010,7 +1010,7 @@ def convert_ffprobe_fps_to_float(value): # --- Deprecated functions --- -@deprecated("oiiotool_transcode") +@deprecated("oiio_color_convert") def convert_colorspace( input_path, output_path, @@ -1022,7 +1022,7 @@ def convert_colorspace( additional_command_args=None, logger=None, ): - """DEPRECATED function use `oiiotool_transcode` instead + """DEPRECATED function use `oiio_color_convert` instead Args: input_path (str): Path to input file that should be converted. @@ -1047,7 +1047,7 @@ def convert_colorspace( Raises: ValueError: If parameters are misconfigured. """ - return oiiotool_transcode( + return oiio_color_convert( input_path, output_path, config_path, @@ -1060,7 +1060,7 @@ def convert_colorspace( ) -def oiiotool_transcode( +def oiio_color_convert( input_path, output_path, config_path, diff --git a/client/ayon_core/plugins/publish/extract_color_transcode.py b/client/ayon_core/plugins/publish/extract_color_transcode.py index 9759b340c7..152e0a27ea 100644 --- a/client/ayon_core/plugins/publish/extract_color_transcode.py +++ b/client/ayon_core/plugins/publish/extract_color_transcode.py @@ -11,7 +11,7 @@ from ayon_core.lib import ( is_oiio_supported, ) from ayon_core.lib.transcoding import ( - oiiotool_transcode, + oiio_color_convert, ) from ayon_core.lib.profiles_filtering import filter_profiles @@ -170,7 +170,7 @@ class ExtractOIIOTranscode(publish.Extractor): new_staging_dir, output_extension) - oiiotool_transcode( + oiio_color_convert( input_path=input_path, output_path=output_path, config_path=config_path, diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 4d51405f01..541082352b 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -15,7 +15,7 @@ from ayon_core.lib import ( path_to_subprocess_arg, run_subprocess, ) -from ayon_core.lib.transcoding import oiiotool_transcode +from ayon_core.lib.transcoding import oiio_color_convert from ayon_core.lib.transcoding import VIDEO_EXTENSIONS, IMAGE_EXTENSIONS @@ -431,7 +431,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): oiio_default_view = display_and_view["view"] try: - oiiotool_transcode( + oiio_color_convert( src_path, dst_path, colorspace_data["config"]["path"], From 28978f07c654446c3af3b64e54cc93bff879bd56 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 12 Jun 2025 15:50:21 +0200 Subject: [PATCH 024/319] use standard conditions --- client/ayon_core/lib/transcoding.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index 97e9f417f0..01a21615b5 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -1134,19 +1134,13 @@ def oiio_color_convert( ]) # Validate input parameters - if all([target_colorspace, target_view, target_display]): + if target_colorspace and target_view and target_display: raise ValueError( "Colorspace and both screen and display cannot be set together." "Choose colorspace or screen and display" ) - if all([source_view, source_display]) and source_colorspace: - logger.warning( - "Both source display/view and source_colorspace provided. " - "Using source display/view pair and ignoring source_colorspace." - ) - - if not target_colorspace and not all([target_view, target_display]): + if not target_colorspace and not target_view and not target_display: raise ValueError( "Both screen and display must be set if target_colorspace is not " "provided." @@ -1161,6 +1155,12 @@ def oiio_color_convert( "display/view inputs." ) + if source_view and source_display and source_colorspace: + logger.warning( + "Both source display/view and source_colorspace provided. " + "Using source display/view pair and ignoring source_colorspace." + ) + if additional_command_args: oiio_cmd.extend(additional_command_args) From 3eb88ae8506eac6dbbd8fd8f94abf88703c7bc72 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 12 Jun 2025 15:50:34 +0200 Subject: [PATCH 025/319] use 'view' instead of 'screen' --- client/ayon_core/lib/transcoding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index 01a21615b5..7a4fd65e7c 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -1136,7 +1136,7 @@ def oiio_color_convert( # Validate input parameters if target_colorspace and target_view and target_display: raise ValueError( - "Colorspace and both screen and display cannot be set together." + "Colorspace and both view and display cannot be set together." "Choose colorspace or screen and display" ) From 2b209044ed4861668b908ee08f2115805eb0fa77 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 12 Jun 2025 15:50:44 +0200 Subject: [PATCH 026/319] better conditions order --- client/ayon_core/lib/transcoding.py | 83 ++++++++++++----------------- 1 file changed, 35 insertions(+), 48 deletions(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index 7a4fd65e7c..bf88e187ae 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -1165,64 +1165,51 @@ def oiio_color_convert( oiio_cmd.extend(additional_command_args) # Handle the different conversion cases - if target_colorspace: - # Case 1: Converting to a named colorspace - if all([source_view, source_display]): - # First convert from source display/view to a role/reference space - # that can be used with colorconvert - # For example, converting to "scene_linear" or an appropriate - # intermediate space + # Source view and display are known + if source_view and source_display: + if target_colorspace: # This is a two-step conversion process since there's no direct # display/view to colorspace command # This could be a config parameter or determined from OCIO config - tmp_role_space = "scene_linear" + # Use temporarty role space 'scene_linear' + color_convert_args = ("scene_linear", target_colorspace) + elif source_display != target_display or source_view != target_view: + # Complete display/view pair conversion + # - go through a reference space + color_convert_args = (target_display, target_view) + else: + color_convert_args = None + logger.debug( + "Source and target display/view pairs are identical." + " No color conversion needed." + ) + + if color_convert_args: oiio_cmd.extend([ "--ociodisplay:inverse=1:subimages=0", source_display, source_view, "--colorconvert:subimages=0", - tmp_role_space, - target_colorspace, - ]) - else: - # Standard color space to color space conversion - oiio_cmd.extend([ - "--colorconvert:subimages=0", - source_colorspace, - target_colorspace, - ]) - else: # Using display/view target - if all([source_view, source_display]): - if source_display == target_display and source_view == target_view: - # No conversion needed if source and target display/view are - # the same - logger.debug( - "Source and target display/view pairs are identical. " - "No color conversion needed." - ) - else: - # Complete display/view pair conversion - # Similar approach: go through a reference space - # This could be configured - tmp_role_space = "scene_linear" - oiio_cmd.extend([ - "--ociodisplay:inverse=1:subimages=0", - source_display, - source_view, - "--ociodisplay:subimages=0", - target_display, - target_view, - ]) - else: - # Standard conversion from colorspace to display/view - oiio_cmd.extend([ - "--iscolorspace", - source_colorspace, - "--ociodisplay:subimages=0", - target_display, - target_view, + *color_convert_args ]) + elif target_colorspace: + # Standard color space to color space conversion + oiio_cmd.extend([ + "--colorconvert:subimages=0", + source_colorspace, + target_colorspace, + ]) + else: + # Standard conversion from colorspace to display/view + oiio_cmd.extend([ + "--iscolorspace", + source_colorspace, + "--ociodisplay:subimages=0", + target_display, + target_view, + ]) + oiio_cmd.extend(["-o", output_path]) logger.debug("Conversion command: {}".format(" ".join(oiio_cmd))) From a237a2441abb0e121215b77e599ee5f7910214ed Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 17 Jun 2025 09:25:09 +0200 Subject: [PATCH 027/319] change core support for per project bundles --- package.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.py b/package.py index 908d34ffa8..9b4a15d24e 100644 --- a/package.py +++ b/package.py @@ -6,6 +6,8 @@ client_dir = "ayon_core" plugin_for = ["ayon_server"] +project_can_override_addon_version = True + ayon_server_version = ">=1.8.4,<2.0.0" ayon_launcher_version = ">=1.0.2" ayon_required_addons = {} From f673abebc8393c9fdce5faf18291d2015fa0b039 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 19 Jun 2025 10:29:45 +0200 Subject: [PATCH 028/319] use 'view' instead of 'screen' Co-authored-by: Roy Nieterau --- client/ayon_core/lib/transcoding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index bf88e187ae..a4edf0aa1c 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -1142,7 +1142,7 @@ def oiio_color_convert( if not target_colorspace and not target_view and not target_display: raise ValueError( - "Both screen and display must be set if target_colorspace is not " + "Both view and display must be set if target_colorspace is not " "provided." ) From 63c81970316e66153cb2e2d05f1899c62fac89fd Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 2 Jul 2025 14:47:05 +0200 Subject: [PATCH 029/319] try to fix flickering issue in publisher --- client/ayon_core/tools/utils/widgets.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/tools/utils/widgets.py b/client/ayon_core/tools/utils/widgets.py index de2c42c91f..941aa692f9 100644 --- a/client/ayon_core/tools/utils/widgets.py +++ b/client/ayon_core/tools/utils/widgets.py @@ -441,14 +441,18 @@ class ExpandingTextEdit(QtWidgets.QTextEdit): margins = self.contentsMargins() document_width = 0 - if width >= margins.left() + margins.right(): - document_width = width - margins.left() - margins.right() + margins_size = margins.left() + margins.right() + if width >= margins_size: + document_width = width - margins_size document = self.document().clone() document.setTextWidth(document_width) return math.ceil( - margins.top() + document.size().height() + margins.bottom() + margins.top() + + document.size().height() + + margins.bottom() + + 2 ) def sizeHint(self): From 2228037656b8eeaa400fcaab1329c6416dbc050f Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 3 Jul 2025 09:57:20 +0200 Subject: [PATCH 030/319] Adds target color space data extraction to OIIO transcode processor. - Introduces extraction of `targetOCIOColorspace`, `targetOCIODisplay`, and `targetOCIOView` from instance data. - Removes redundant assignment of `target_colorspace`, `target_display`, and `target_view`. --- client/ayon_core/plugins/publish/extract_color_transcode.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/extract_color_transcode.py b/client/ayon_core/plugins/publish/extract_color_transcode.py index ef718b8d02..7083d5094c 100644 --- a/client/ayon_core/plugins/publish/extract_color_transcode.py +++ b/client/ayon_core/plugins/publish/extract_color_transcode.py @@ -85,6 +85,11 @@ class ExtractOIIOTranscode(publish.Extractor): new_representations = [] repres = instance.data["representations"] for idx, repre in enumerate(list(repres)): + # target space, display and view might be defined upstream + target_colorspace = instance.data.get("targetOCIOColorspace") + target_display = instance.data.get("targetOCIODisplay") + target_view = instance.data.get("targetOCIOView") + self.log.debug("repre ({}): `{}`".format(idx + 1, repre["name"])) if not self._repre_is_valid(repre): continue @@ -126,7 +131,6 @@ class ExtractOIIOTranscode(publish.Extractor): transcoding_type = output_def["transcoding_type"] - target_colorspace = target_view = target_display = None # NOTE: we use colorspace_data as the fallback values for # the target colorspace. if transcoding_type == "colorspace": From 72bde0349b0112f558d3b742128d864de13d055f Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 8 Jul 2025 17:04:35 +0200 Subject: [PATCH 031/319] Allow to push to other projects not only Library --- .../tools/push_to_project/control.py | 10 +++++++ .../tools/push_to_project/ui/window.py | 26 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index fb080d158b..f24d11d0b7 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -40,6 +40,8 @@ class PushToContextController: self.set_source(project_name, version_id) + self._library_only = True + # Events system def emit_event(self, topic, data=None, source=None): """Use implemented event system to trigger event.""" @@ -128,6 +130,14 @@ class PushToContextController: self._src_label = self._prepare_source_label() return self._src_label + def get_library_only(self): + """Returns state of library filter""" + return self._library_only + + def set_library_only(self, state: bool): + """Change state of library filter""" + self._library_only = state + def get_project_items(self, sender=None): return self._projects_model.get_project_items(sender) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index a69c512fcd..566a0fc605 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -85,6 +85,14 @@ class PushToContextSelectWindow(QtWidgets.QWidget): header_widget = QtWidgets.QWidget(main_context_widget) + library_only = self._controller.get_library_only() + library_only_label = QtWidgets.QLabel( + "Show only libraries", + header_widget + ) + library_only_checkbox = NiceCheckbox( + library_only, parent=header_widget) + header_label = QtWidgets.QLabel( controller.get_source_label(), header_widget @@ -93,6 +101,14 @@ class PushToContextSelectWindow(QtWidgets.QWidget): header_layout = QtWidgets.QHBoxLayout(header_widget) header_layout.setContentsMargins(0, 0, 0, 0) header_layout.addWidget(header_label) + header_layout.addStretch() + + library_only_layout = QtWidgets.QHBoxLayout() + library_only_layout.addWidget(library_only_label) + library_only_layout.addWidget(library_only_checkbox) + library_only_layout.setSpacing(5) # or whatever spacing you prefer + + header_layout.addLayout(library_only_layout) main_splitter = QtWidgets.QSplitter( QtCore.Qt.Horizontal, main_context_widget @@ -102,7 +118,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): projects_combobox = ProjectsCombobox(controller, context_widget) projects_combobox.set_select_item_visible(True) - projects_combobox.set_standard_filter_enabled(True) + projects_combobox.set_standard_filter_enabled(library_only) context_splitter = QtWidgets.QSplitter( QtCore.Qt.Vertical, context_widget @@ -240,6 +256,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): folder_name_input.textChanged.connect(self._on_new_folder_change) variant_input.textChanged.connect(self._on_variant_change) comment_input.textChanged.connect(self._on_comment_change) + library_only_checkbox.stateChanged.connect(self._on_library_only_change) publish_btn.clicked.connect(self._on_select_click) cancel_btn.clicked.connect(self._on_close_click) @@ -394,6 +411,13 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._comment_input_text = text self._user_input_changed_timer.start() + def _on_library_only_change(self, state: int) -> None: + """Change toggle state, reset filter, recalculate dropdown""" + state = bool(state) + self._controller.set_library_only(state) + self._projects_combobox.set_standard_filter_enabled(state) + self._projects_combobox.refresh() + def _on_user_input_timer(self): folder_name_enabled = self._new_folder_name_enabled folder_name = self._new_folder_name_input_text From e880b2983896cb79493266c61f08089e16d109a4 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 8 Jul 2025 17:06:11 +0200 Subject: [PATCH 032/319] Changed label of action Push to --- client/ayon_core/plugins/load/push_to_library.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/load/push_to_library.py b/client/ayon_core/plugins/load/push_to_library.py index 981028d734..825192c15e 100644 --- a/client/ayon_core/plugins/load/push_to_library.py +++ b/client/ayon_core/plugins/load/push_to_library.py @@ -14,7 +14,7 @@ class PushToLibraryProject(load.ProductLoaderPlugin): representations = {"*"} product_types = {"*"} - label = "Push to Library project" + label = "Push to (Library) project" order = 35 icon = "send" color = "#d8d8d8" From c35c86440bedd9d15475cd7db9d9685965c1777c Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 10 Jul 2025 11:39:01 +0200 Subject: [PATCH 033/319] Used different layout Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/ui/window.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 566a0fc605..49093b8a00 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -101,14 +101,9 @@ class PushToContextSelectWindow(QtWidgets.QWidget): header_layout = QtWidgets.QHBoxLayout(header_widget) header_layout.setContentsMargins(0, 0, 0, 0) header_layout.addWidget(header_label) - header_layout.addStretch() - - library_only_layout = QtWidgets.QHBoxLayout() - library_only_layout.addWidget(library_only_label) - library_only_layout.addWidget(library_only_checkbox) - library_only_layout.setSpacing(5) # or whatever spacing you prefer - - header_layout.addLayout(library_only_layout) + header_layout.addStretch(1) + header_layout.addWidget(library_only_label, 0) + header_layout.addWidget(library_only_checkbox, 0) main_splitter = QtWidgets.QSplitter( QtCore.Qt.Horizontal, main_context_widget From 63da40c2025739bdfc864ae38e5031fe20dcc0a9 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 11 Jul 2025 13:59:34 +0200 Subject: [PATCH 034/319] Added thumbnail copy from source to target --- .../tools/push_to_project/models/integrate.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 6bd4279219..fd20a7faba 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -3,6 +3,7 @@ import re import copy import itertools import sys +import tempfile import traceback import uuid @@ -484,6 +485,7 @@ class ProjectPushItemProcess: self._make_sure_version_exists() self._log_info("Prerequirements were prepared") self._integrate_representations() + self._copy_version_thumbnail() self._log_info("Integration finished") except PushToProjectError as exc: @@ -1145,8 +1147,39 @@ class ProjectPushItemProcess: "representation", repre_entity["id"], {"active": False} + + def _copy_version_thumbnail(self): + version_thumbnail = ayon_api.get_version_thumbnail( + self._item.src_project_name, self._src_version_entity["id"]) + if not version_thumbnail or not version_thumbnail.id: + return + + temp_file_name = None + try: + with tempfile.NamedTemporaryFile(mode='w+b', delete=False) as fp: + fp.write(version_thumbnail.content) + temp_file_name = fp.name + + new_thumbnail_id = ayon_api.create_thumbnail( + self._item.dst_project_name, + temp_file_name ) + task_id = None + if self._task_info: + task_id = self._task_info["id"] + + self._operations.update_version( + project_name=self._item.dst_project_name, + version_id=self._version_entity["id"], + task_id=task_id, + thumbnail_id=new_thumbnail_id + ) + self._operations.commit() + finally: + if temp_file_name and os.path.exists(temp_file_name): + os.remove(temp_file_name) + class IntegrateModel: def __init__(self, controller): From 00cfb962e4f748aaec7e68b25d6d9c89833ee39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Je=C5=BEek?= Date: Mon, 14 Jul 2025 14:38:41 +0200 Subject: [PATCH 035/319] Update client/ayon_core/lib/transcoding.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com> --- client/ayon_core/lib/transcoding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index a4edf0aa1c..b3958863fe 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -1136,7 +1136,7 @@ def oiio_color_convert( # Validate input parameters if target_colorspace and target_view and target_display: raise ValueError( - "Colorspace and both view and display cannot be set together." + "Colorspace and both view and display cannot be set together." "Choose colorspace or screen and display" ) From 7161de78fabaddd55d5d9e1c1d6f01e167da7910 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 14 Jul 2025 16:33:44 +0200 Subject: [PATCH 036/319] Fix typo --- client/ayon_core/tools/push_to_project/models/integrate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index fd20a7faba..341858148b 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -1147,6 +1147,7 @@ class ProjectPushItemProcess: "representation", repre_entity["id"], {"active": False} + ) def _copy_version_thumbnail(self): version_thumbnail = ayon_api.get_version_thumbnail( From 6064f095c8db0ef8a7d7137c0947275cd8603e6b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 14 Jul 2025 17:11:19 +0200 Subject: [PATCH 037/319] added base of instance parenting --- client/ayon_core/pipeline/create/structures.py | 4 ++++ client/ayon_core/tools/publisher/models/create.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/client/ayon_core/pipeline/create/structures.py b/client/ayon_core/pipeline/create/structures.py index a4c68d2502..3048ae2829 100644 --- a/client/ayon_core/pipeline/create/structures.py +++ b/client/ayon_core/pipeline/create/structures.py @@ -653,6 +653,10 @@ class CreatedInstance: def product_name(self): return self._data["productName"] + @property + def parent_instance_id(self) -> Optional[str]: + return self._data.get("parentInstanceId") + @property def label(self): label = self._data.get("label") diff --git a/client/ayon_core/tools/publisher/models/create.py b/client/ayon_core/tools/publisher/models/create.py index 75ed2c73fe..058077aadd 100644 --- a/client/ayon_core/tools/publisher/models/create.py +++ b/client/ayon_core/tools/publisher/models/create.py @@ -219,6 +219,7 @@ class InstanceItem: is_active: bool, is_mandatory: bool, has_promised_context: bool, + parent_instance_id: Optional[str], ): self._instance_id: str = instance_id self._creator_identifier: str = creator_identifier @@ -232,6 +233,7 @@ class InstanceItem: self._is_active: bool = is_active self._is_mandatory: bool = is_mandatory self._has_promised_context: bool = has_promised_context + self._parent_instance_id: Optional[str] = parent_instance_id @property def id(self): @@ -261,6 +263,10 @@ class InstanceItem: def has_promised_context(self): return self._has_promised_context + @property + def parent_instance_id(self): + return self._parent_instance_id + def get_variant(self): return self._variant @@ -312,6 +318,7 @@ class InstanceItem: instance["active"], instance.is_mandatory, instance.has_promised_context, + instance.parent_instance_id, ) From 9792be3c849c840f5fca8ade4f54bb3942af81fa Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 14 Jul 2025 17:14:16 +0200 Subject: [PATCH 038/319] modified instances view to show parenting hierarchy --- .../publisher/widgets/list_view_widgets.py | 488 +++++++++--------- 1 file changed, 249 insertions(+), 239 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 969bec11e5..9fb0402810 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -22,12 +22,15 @@ selection can be enabled disabled using checkbox or keyboard key presses: ... ``` """ +from __future__ import annotations + import collections +import typing from qtpy import QtWidgets, QtCore, QtGui from ayon_core.style import get_objected_colors -from ayon_core.tools.utils import NiceCheckbox +from ayon_core.tools.utils import NiceCheckbox, BaseClickableFrame from ayon_core.tools.utils.lib import html_escape, checkstate_int_to_enum from ayon_core.tools.publisher.abstract import AbstractPublisherFrontend @@ -44,6 +47,9 @@ from ayon_core.tools.publisher.constants import ( from .widgets import AbstractInstanceView +if typing.TYPE_CHECKING: + from ayon_core.tools.publisher.abstract import InstanceItem + class ListItemDelegate(QtWidgets.QStyledItemDelegate): """Generic delegate for instance group. @@ -135,8 +141,7 @@ class InstanceListItemWidget(QtWidgets.QWidget): active_checkbox.setVisible(not instance.is_mandatory) layout = QtWidgets.QHBoxLayout(self) - content_margins = layout.contentsMargins() - layout.setContentsMargins(content_margins.left() + 2, 0, 2, 0) + layout.setContentsMargins(2, 0, 2, 0) layout.addWidget(product_name_label) layout.addStretch(1) layout.addWidget(active_checkbox) @@ -194,6 +199,7 @@ class InstanceListItemWidget(QtWidgets.QWidget): def update_instance(self, instance, context_info): """Update instance object.""" # Check product name + self._instance_id = instance.id label = instance.label if label != self._instance_label_widget.text(): self._instance_label_widget.setText(html_escape(label)) @@ -241,43 +247,33 @@ class ListContextWidget(QtWidgets.QFrame): self.double_clicked.emit() -class InstanceListGroupWidget(QtWidgets.QFrame): +class InstanceListGroupWidget(BaseClickableFrame): """Widget representing group of instances. - Has collapse/expand indicator, label of group and checkbox modifying all - of its children. + Has label of group and checkbox modifying all of its children. """ - expand_changed = QtCore.Signal(str, bool) toggle_requested = QtCore.Signal(str, int) + expand_change_requested = QtCore.Signal(str) def __init__(self, group_name, parent): super().__init__(parent) self.setObjectName("InstanceListGroupWidget") self.group_name = group_name - self._expanded = False - - expand_btn = QtWidgets.QToolButton(self) - expand_btn.setObjectName("ArrowBtn") - expand_btn.setArrowType(QtCore.Qt.RightArrow) - expand_btn.setMaximumWidth(14) name_label = QtWidgets.QLabel(group_name, self) toggle_checkbox = NiceCheckbox(parent=self) layout = QtWidgets.QHBoxLayout(self) - layout.setContentsMargins(5, 0, 2, 0) - layout.addWidget(expand_btn) + layout.setContentsMargins(2, 0, 2, 0) layout.addWidget( name_label, 1, QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter ) layout.addWidget(toggle_checkbox, 0) name_label.setAttribute(QtCore.Qt.WA_TranslucentBackground) - expand_btn.setAttribute(QtCore.Qt.WA_TranslucentBackground) - expand_btn.clicked.connect(self._on_expand_clicked) toggle_checkbox.stateChanged.connect(self._on_checkbox_change) self._ignore_state_change = False @@ -285,7 +281,6 @@ class InstanceListGroupWidget(QtWidgets.QFrame): self._expected_checkstate = None self.name_label = name_label - self.expand_btn = expand_btn self.toggle_checkbox = toggle_checkbox def set_checkstate(self, state): @@ -307,26 +302,15 @@ class InstanceListGroupWidget(QtWidgets.QFrame): return self.toggle_checkbox.checkState() + def set_active_toggle_enabled(self, enabled): + self.toggle_checkbox.setEnabled(enabled) + def _on_checkbox_change(self, state): if not self._ignore_state_change: self.toggle_requested.emit(self.group_name, state) - def _on_expand_clicked(self): - self.expand_changed.emit(self.group_name, not self._expanded) - - def set_expanded(self, expanded): - """Change icon of collapse/expand identifier.""" - if self._expanded == expanded: - return - - self._expanded = expanded - if expanded: - self.expand_btn.setArrowType(QtCore.Qt.DownArrow) - else: - self.expand_btn.setArrowType(QtCore.Qt.RightArrow) - - def set_active_toggle_enabled(self, enabled): - self.toggle_checkbox.setEnabled(enabled) + def _mouse_release_callback(self): + self.expand_change_requested.emit(self.group_name) class InstanceTreeView(QtWidgets.QTreeView): @@ -339,24 +323,11 @@ class InstanceTreeView(QtWidgets.QTreeView): self.setObjectName("InstanceListView") self.setHeaderHidden(True) - self.setIndentation(0) self.setExpandsOnDoubleClick(False) self.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection ) self.viewport().setMouseTracking(True) - self._pressed_group_index = None - - def _expand_item(self, index, expand=None): - is_expanded = self.isExpanded(index) - if expand is None: - expand = not is_expanded - - if expand != is_expanded: - if expand: - self.expand(index) - else: - self.collapse(index) def get_selected_instance_ids(self): """Ids of selected instances.""" @@ -388,53 +359,6 @@ class InstanceTreeView(QtWidgets.QTreeView): return super().event(event) - def _mouse_press(self, event): - """Store index of pressed group. - - This is to be able to change state of group and process mouse - "double click" as 2x "single click". - """ - if event.button() != QtCore.Qt.LeftButton: - return - - pressed_group_index = None - pos_index = self.indexAt(event.pos()) - if pos_index.data(IS_GROUP_ROLE): - pressed_group_index = pos_index - - self._pressed_group_index = pressed_group_index - - def mousePressEvent(self, event): - self._mouse_press(event) - super().mousePressEvent(event) - - def mouseDoubleClickEvent(self, event): - self._mouse_press(event) - super().mouseDoubleClickEvent(event) - - def _mouse_release(self, event, pressed_index): - if event.button() != QtCore.Qt.LeftButton: - return False - - pos_index = self.indexAt(event.pos()) - if not pos_index.data(IS_GROUP_ROLE) or pressed_index != pos_index: - return False - - if self.state() == QtWidgets.QTreeView.State.DragSelectingState: - indexes = self.selectionModel().selectedIndexes() - if len(indexes) != 1 or indexes[0] != pos_index: - return False - - self._expand_item(pos_index) - return True - - def mouseReleaseEvent(self, event): - pressed_index = self._pressed_group_index - self._pressed_group_index = None - result = self._mouse_release(event, pressed_index) - if not result: - super().mouseReleaseEvent(event) - class InstanceListView(AbstractInstanceView): """Widget providing abstract methods of AbstractInstanceView for list view. @@ -472,18 +396,19 @@ class InstanceListView(AbstractInstanceView): instance_view.selectionModel().selectionChanged.connect( self._on_selection_change ) - instance_view.collapsed.connect(self._on_collapse) - instance_view.expanded.connect(self._on_expand) instance_view.toggle_requested.connect(self._on_toggle_request) instance_view.double_clicked.connect(self.double_clicked) self._group_items = {} self._group_widgets = {} - self._widgets_by_id = {} + self._widgets_by_id: dict[str, InstanceListItemWidget] = {} + self._items_by_id = {} + self._parent_id_by_id = {} # Group by instance id for handling of active state self._group_by_instance_id = {} self._context_item = None self._context_widget = None + self._missing_parent_item = None self._convertor_group_item = None self._convertor_group_widget = None @@ -496,22 +421,6 @@ class InstanceListView(AbstractInstanceView): self._active_toggle_enabled = True - def _on_expand(self, index): - self._update_widget_expand_state(index, True) - - def _on_collapse(self, index): - self._update_widget_expand_state(index, False) - - def _update_widget_expand_state(self, index, expanded): - group_name = index.data(GROUP_ROLE) - if group_name == CONVERTOR_ITEM_GROUP: - group_widget = self._convertor_group_widget - else: - group_widget = self._group_widgets.get(group_name) - - if group_widget: - group_widget.set_expanded(expanded) - def _on_toggle_request(self, toggle): if not self._active_toggle_enabled: return @@ -583,85 +492,94 @@ class InstanceListView(AbstractInstanceView): self._update_convertor_items_group() context_info_by_id = self._controller.get_instances_context_info() - + instance_items = self._controller.get_instance_items() # Prepare instances by their groups instances_by_group_name = collections.defaultdict(list) + instances_by_parent_id = collections.defaultdict(list) group_names = set() - for instance in self._controller.get_instance_items(): + instance_ids = set() + for instance in instance_items: + instance_ids.add(instance.id) + if instance.parent_instance_id: + instances_by_parent_id[instance.parent_instance_id].append( + instance + ) + continue + group_label = instance.group_label group_names.add(group_label) instances_by_group_name[group_label].append(instance) + missing_parent_ids = set(instances_by_parent_id) - instance_ids + for instance_id in missing_parent_ids: + for instance in instances_by_parent_id[instance_id]: + group_label = instance.group_label + group_names.add(group_label) + instances_by_group_name[group_label].append(instance) + # Create new groups based on prepared `instances_by_group_name` if self._make_sure_groups_exists(group_names): sort_at_the_end = True # Remove groups that are not available anymore self._remove_groups_except(group_names) + self._remove_instances_except(instance_items) - # Store which groups should be expanded at the end expand_groups = set() + expand_to_items = [] + widgets_by_id = {} + # Process changes in each group item # - create new instance, update existing and remove not existing for group_name, group_item in self._group_items.items(): - # Instance items to remove - # - will contain all existing instance ids at the start - # - instance ids may be removed when existing instances are checked - to_remove = set() - # Mapping of existing instances under group item - existing_mapping = {} - - # Get group index to be able to get children indexes - group_index = self._instance_model.index( - group_item.row(), group_item.column() - ) - - # Iterate over children indexes of group item - for idx in range(group_item.rowCount()): - index = self._instance_model.index(idx, 0, group_index) - instance_id = index.data(INSTANCE_ID_ROLE) - # Add all instance into `to_remove` set - to_remove.add(instance_id) - existing_mapping[instance_id] = idx - # Collect all new instances that are not existing under group # New items - new_items = [] - # Tuples of new instance and instance itself - new_items_with_instance = [] + new_items = collections.defaultdict(list) + # Tuples of model item and instance itself + items_with_instance = [] # Group activity (should be {-1;0;1} at the end) # - 0 when all instances are disabled # - 1 when all instances are enabled # - -1 when it's mixed activity = None for instance in instances_by_group_name[group_name]: - instance_id = instance.id - # Handle group activity - if activity is None: - activity = int(instance.is_active) - elif activity == -1: - pass - elif activity != instance.is_active: - activity = -1 + _queue = collections.deque() + _queue.append((instance, group_item, None)) + while _queue: + instance, parent_item, parent_id = _queue.popleft() + instance_id = instance.id + # Handle group activity + if activity is None: + activity = int(instance.is_active) + elif activity == -1: + pass + elif activity != instance.is_active: + activity = -1 - context_info = context_info_by_id[instance_id] + self._group_by_instance_id[instance_id] = group_name - self._group_by_instance_id[instance_id] = group_name - # Remove instance id from `to_remove` if already exists and - # trigger update of widget - if instance_id in to_remove: - to_remove.remove(instance_id) - widget = self._widgets_by_id[instance_id] - widget.update_instance(instance, context_info) - continue + # Create new item and store it as new + item = self._items_by_id.get(instance_id) + if item is None: + item = QtGui.QStandardItem() + item.setData(instance_id, INSTANCE_ID_ROLE) + self._items_by_id[instance_id] = item + new_items[parent_id].append(item) + elif parent_id != self._parent_id_by_id.get(instance_id): + new_items[parent_id].append(item) - # Create new item and store it as new - item = QtGui.QStandardItem() - item.setData(instance.product_name, SORT_VALUE_ROLE) - item.setData(instance.product_name, GROUP_ROLE) - item.setData(instance_id, INSTANCE_ID_ROLE) - new_items.append(item) - new_items_with_instance.append((item, instance)) + self._parent_id_by_id[instance_id] = parent_id + + children = instances_by_parent_id.pop(instance_id, []) + items_with_instance.append( + (item, instance, bool(children)) + ) + + item.setData(instance.product_name, SORT_VALUE_ROLE) + item.setData(instance.product_name, GROUP_ROLE) + + for child in children: + _queue.append((child, item, instance_id)) # Set checkstate of group checkbox state = QtCore.Qt.PartiallyChecked @@ -670,23 +588,9 @@ class InstanceListView(AbstractInstanceView): elif activity == 1: state = QtCore.Qt.Checked - widget = self._group_widgets[group_name] - widget.set_checkstate(state) - - # Remove items that were not found - idx_to_remove = [] - for instance_id in to_remove: - idx_to_remove.append(existing_mapping[instance_id]) - - # Remove them in reverse order to prevent row index changes - for idx in reversed(sorted(idx_to_remove)): - group_item.removeRows(idx, 1) - - # Cleanup instance related widgets - for instance_id in to_remove: - self._group_by_instance_id.pop(instance_id) - widget = self._widgets_by_id.pop(instance_id) - widget.deleteLater() + if group_name is not None: + widget = self._group_widgets[group_name] + widget.set_checkstate(state) # Process new instance items and add them to model and create # their widgets @@ -695,40 +599,76 @@ class InstanceListView(AbstractInstanceView): sort_at_the_end = True # Add items under group item - group_item.appendRows(new_items) + for parent_id, items in new_items.items(): + if parent_id is None: + parent_item = group_item + else: + parent_item = self._items_by_id[parent_id] - for item, instance in new_items_with_instance: - context_info = context_info_by_id[instance.id] - if not context_info.is_valid: - expand_groups.add(group_name) - item_index = self._instance_model.index( - item.row(), - item.column(), - group_index - ) - proxy_index = self._proxy_model.mapFromSource(item_index) + parent_item.appendRows(items) + + for item, instance, has_children in items_with_instance: + context_info = context_info_by_id[instance.id] + # TODO expand all parents + if not context_info.is_valid: + expand_groups.add(group_name) + expand_to_items.append(item) + item_index = self._instance_model.indexFromItem(item) + proxy_index = self._proxy_model.mapFromSource(item_index) + widget = self._instance_view.indexWidget(proxy_index) + if isinstance(widget, InstanceListItemWidget): + widget.update_instance(instance, context_info) + else: widget = InstanceListItemWidget( instance, context_info, self._instance_view ) - widget.set_active_toggle_enabled( - self._active_toggle_enabled - ) widget.active_changed.connect(self._on_active_changed) widget.double_clicked.connect(self.double_clicked) self._instance_view.setIndexWidget(proxy_index, widget) - self._widgets_by_id[instance.id] = widget + widget.set_active_toggle_enabled( + self._active_toggle_enabled + ) - # Trigger sort at the end of refresh - if sort_at_the_end: - self._proxy_model.sort(0) + widgets_by_id[instance.id] = widget + self._widgets_by_id.pop(instance.id, None) - # Expand groups marked for expanding - for group_name in expand_groups: - group_item = self._group_items[group_name] - proxy_index = self._proxy_model.mapFromSource(group_item.index()) + for widget in self._widgets_by_id.values(): + widget.setVisible(False) + widget.deleteLater() + self._widgets_by_id = widgets_by_id + + # Expand items marked for expanding + items_to_expand = [ + self._group_items[group_name] + for group_name in expand_groups + ] + _marked_ids = set() + for item in expand_to_items: + parent = item.parent() + _items = [] + while True: + # Parent is not set or is group (groups are separate) + if parent is None or parent.data(IS_GROUP_ROLE): + break + instance_id = parent.data(INSTANCE_ID_ROLE) + # Parent was already marked for expanding + if instance_id in _marked_ids: + break + _marked_ids.add(instance_id) + _items.append(parent) + parent = parent.parent() + + items_to_expand.extend(reversed(_items)) + + for item in items_to_expand: + proxy_index = self._proxy_model.mapFromSource(item.index()) self._instance_view.expand(proxy_index) + # Trigger sort at the end of refresh + if sort_at_the_end: + self._proxy_model.sort(0) + def _make_sure_context_item_exists(self): if self._context_item is not None: return False @@ -761,7 +701,7 @@ class InstanceListView(AbstractInstanceView): root_item = self._instance_model.invisibleRootItem() if not convertor_items_by_id: - root_item.removeRow(group_item.row()) + root_item.takeRow(group_item.row()) self._convertor_group_widget.deleteLater() self._convertor_group_widget = None self._convertor_items_by_id = {} @@ -785,9 +725,7 @@ class InstanceListView(AbstractInstanceView): CONVERTOR_ITEM_GROUP, self._instance_view ) widget.toggle_checkbox.setVisible(False) - widget.expand_changed.connect( - self._on_convertor_group_expand_request - ) + self._instance_view.setIndexWidget(proxy_index, widget) self._convertor_group_item = group_item @@ -798,7 +736,7 @@ class InstanceListView(AbstractInstanceView): child_identifier = child_item.data(CONVERTER_IDENTIFIER_ROLE) if child_identifier not in convertor_items_by_id: self._convertor_items_by_id.pop(child_identifier, None) - group_item.removeRows(row, 1) + group_item.takeRow(row) new_items = [] for identifier, convertor_item in convertor_items_by_id.items(): @@ -853,8 +791,10 @@ class InstanceListView(AbstractInstanceView): widget.set_active_toggle_enabled( self._active_toggle_enabled ) - widget.expand_changed.connect(self._on_group_expand_request) widget.toggle_requested.connect(self._on_group_toggle_request) + widget.expand_change_requested.connect( + self._on_expand_toggle_request + ) self._group_widgets[group_name] = widget self._instance_view.setIndexWidget(proxy_index, widget) @@ -868,10 +808,84 @@ class InstanceListView(AbstractInstanceView): continue group_item = self._group_items.pop(group_name) - root_item.removeRow(group_item.row()) + root_item.takeRow(group_item.row()) widget = self._group_widgets.pop(group_name) + widget.setVisible(False) widget.deleteLater() + def _remove_instances_except(self, instance_items: list[InstanceItem]): + parent_id_by_id = { + item.id: item.parent_instance_id + for item in instance_items + } + instance_ids = set(parent_id_by_id) + all_removed_ids = set(self._items_by_id) - instance_ids + queue = collections.deque() + for group_item in self._group_items.values(): + queue.append((group_item, None)) + while queue: + parent_item, parent_id = queue.popleft() + children = [ + parent_item.child(row) + for row in range(parent_item.rowCount()) + ] + for child in children: + instance_id = child.data(INSTANCE_ID_ROLE) + if instance_id not in parent_id_by_id: + parent_item.takeRow(child.row()) + elif parent_id != parent_id_by_id[instance_id]: + parent_item.takeRow(child.row()) + + queue.append((child, instance_id)) + + for instance_id in all_removed_ids: + self._items_by_id.pop(instance_id) + self._group_by_instance_id.pop(instance_id) + self._parent_id_by_id.pop(instance_id) + widget = self._widgets_by_id.pop(instance_id, None) + if widget is not None: + widget.setVisible(False) + widget.deleteLater() + + def _add_missing_parent_item(self): + label = "! Orphaned instances !" + if self._missing_parent_item is None: + item = QtGui.QStandardItem() + item.setData(label, GROUP_ROLE) + item.setData("_", SORT_VALUE_ROLE) + item.setData(True, IS_GROUP_ROLE) + item.setFlags(QtCore.Qt.ItemIsEnabled) + self._missing_parent_item = item + + if self._missing_parent_item.parent() is None: + root_item = self._instance_model.invisibleRootItem() + root_item.appendRow(self._missing_parent_item) + index = self._missing_parent_item.index() + proxy_index = self._proxy_model.mapFromSource(index) + widget = InstanceListGroupWidget(label, self._instance_view) + widget.toggle_checkbox.setVisible(False) + self._instance_view.setIndexWidget(proxy_index, widget) + return self._missing_parent_item + + def _remove_missing_parent_item(self): + if self._missing_parent_item is None: + return + + row = self._missing_parent_item.row() + if row < 0: + return + + parent = self._missing_parent_item.parent() + if parent is None: + parent = self._instance_model.invisibleRootItem() + index = self._missing_parent_item.index() + proxy_index = self._proxy_model.mapFromSource(index) + widget = self._instance_view.indexWidget(proxy_index) + if widget is not None: + widget.setVisible(False) + widget.deleteLater() + parent.takeRow(self._missing_parent_item.row()) + def refresh_instance_states(self, instance_ids=None): """Trigger update of all instances.""" if instance_ids is not None: @@ -925,26 +939,13 @@ class InstanceListView(AbstractInstanceView): def _on_selection_change(self, *_args): self.selection_changed.emit() - def _on_group_expand_request(self, group_name, expanded): + def _on_expand_toggle_request(self, group_name): group_item = self._group_items.get(group_name) if not group_item: return - - group_index = self._instance_model.index( - group_item.row(), group_item.column() - ) - proxy_index = self._proxy_model.mapFromSource(group_index) - self._instance_view.setExpanded(proxy_index, expanded) - - def _on_convertor_group_expand_request(self, _, expanded): - group_item = self._convertor_group_item - if not group_item: - return - group_index = self._instance_model.index( - group_item.row(), group_item.column() - ) - proxy_index = self._proxy_model.mapFromSource(group_index) - self._instance_view.setExpanded(proxy_index, expanded) + proxy_index = self._proxy_model.mapFromSource(group_item.index()) + new_state = not self._instance_view.isExpanded(proxy_index) + self._instance_view.setExpanded(proxy_index, new_state) def _on_group_toggle_request(self, group_name, state): state = checkstate_int_to_enum(state) @@ -962,24 +963,33 @@ class InstanceListView(AbstractInstanceView): active_by_id = {} all_changed = True - for row in range(group_item.rowCount()): - item = group_item.child(row) - instance_id = item.data(INSTANCE_ID_ROLE) - widget = self._widgets_by_id.get(instance_id) - if widget is None: - continue - if widget.is_checkbox_enabled(): - active_by_id[instance_id] = active - else: - all_changed = False + items_to_expand = [group_item] + _queue = collections.deque() + _queue.append(group_item) + while _queue: + item = _queue.popleft() + for row in range(item.rowCount()): + child = item.child(row) + instance_id = child.data(INSTANCE_ID_ROLE) + if child.hasChildren(): + items_to_expand.append(child) + _queue.append(child) + widget = self._widgets_by_id.get(instance_id) + if widget is None: + continue + if widget.is_checkbox_enabled(): + active_by_id[instance_id] = active + else: + all_changed = False self._controller.set_instances_active_state(active_by_id) self._change_active_instances(active_by_id, active) - proxy_index = self._proxy_model.mapFromSource(group_item.index()) - if not self._instance_view.isExpanded(proxy_index): - self._instance_view.expand(proxy_index) + for item in items_to_expand: + proxy_index = self._proxy_model.mapFromSource(item.index()) + if not self._instance_view.isExpanded(proxy_index): + self._instance_view.expand(proxy_index) if not all_changed: # If not all instances were changed, update group checkstate From bcea66c9314eb9f2796cefeb6176c2f9fc485fdc Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 17 Jul 2025 14:31:23 +0200 Subject: [PATCH 039/319] Label update Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/plugins/load/push_to_library.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/load/push_to_library.py b/client/ayon_core/plugins/load/push_to_library.py index 825192c15e..22c10bbad7 100644 --- a/client/ayon_core/plugins/load/push_to_library.py +++ b/client/ayon_core/plugins/load/push_to_library.py @@ -14,7 +14,7 @@ class PushToLibraryProject(load.ProductLoaderPlugin): representations = {"*"} product_types = {"*"} - label = "Push to (Library) project" + label = "Push to project" order = 35 icon = "send" color = "#d8d8d8" From 1c4f466181a892ecb954f523de061e791d435e7e Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 17 Jul 2025 14:31:34 +0200 Subject: [PATCH 040/319] Formatting change Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/models/integrate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 341858148b..20fa5c98e5 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -1148,6 +1148,7 @@ class ProjectPushItemProcess: repre_entity["id"], {"active": False} ) + ) def _copy_version_thumbnail(self): version_thumbnail = ayon_api.get_version_thumbnail( From 60f1fa8961154e81c47c31c2db04719f5ea28fd7 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 21 Jul 2025 19:21:30 +0200 Subject: [PATCH 041/319] remove bundle names from environment variables --- client/ayon_core/tools/launcher/models/actions.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/launcher/models/actions.py b/client/ayon_core/tools/launcher/models/actions.py index adb8d371ed..1945019fef 100644 --- a/client/ayon_core/tools/launcher/models/actions.py +++ b/client/ayon_core/tools/launcher/models/actions.py @@ -513,7 +513,12 @@ class ActionsModel: uri = payload["uri"] else: uri = data["uri"] - run_detached_ayon_launcher_process(uri) + + # Remove bundles from environment variables + env = os.environ.copy() + env.pop("AYON_BUNDLE_NAME", None) + env.pop("AYON_STUDIO_BUNDLE_NAME", None) + run_detached_ayon_launcher_process(uri, env=env) elif response_type in ("query", "navigate"): response.error_message = ( From ec3eaeb75180595fddd494cbf9b3cce97486d94e Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 21 Jul 2025 19:26:47 +0200 Subject: [PATCH 042/319] added log --- client/ayon_core/tools/tray/ui/tray.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/ayon_core/tools/tray/ui/tray.py b/client/ayon_core/tools/tray/ui/tray.py index f090be063e..cea8d4f747 100644 --- a/client/ayon_core/tools/tray/ui/tray.py +++ b/client/ayon_core/tools/tray/ui/tray.py @@ -243,6 +243,11 @@ class TrayManager: project_bundle = os.getenv("AYON_BUNDLE_NAME") studio_bundle = os.getenv("AYON_STUDIO_BUNDLE_NAME") if studio_bundle and project_bundle != studio_bundle: + self.log.info( + f"Project bundle '{project_bundle}' is defined, but tray" + " cannot be running in project scope. Restarting tray to use" + " studio bundle." + ) self.restart() def get_services_submenu(self): From 3c8f3224bce64895c97f26a250e952f828b1da16 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 22 Jul 2025 11:58:20 +0200 Subject: [PATCH 043/319] filter instances without active parents --- .../publish/collect_from_create_context.py | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_from_create_context.py b/client/ayon_core/plugins/publish/collect_from_create_context.py index b99866fed9..8383dfaa96 100644 --- a/client/ayon_core/plugins/publish/collect_from_create_context.py +++ b/client/ayon_core/plugins/publish/collect_from_create_context.py @@ -2,6 +2,8 @@ """ import os +import collections + import pyblish.api from ayon_core.host import IPublishHost @@ -36,18 +38,42 @@ class CollectFromCreateContext(pyblish.api.ContextPlugin): if project_name: context.data["projectName"] = project_name + # Filter active instances and skip instances which have disabled + # parent instance + instances_by_parent_id = collections.defaultdict(list) + filtered_instances = [] for created_instance in create_context.instances: + if not created_instance["active"]: + continue + parent_id = created_instance.parent_instance_id + if parent_id is None: + filtered_instances.append(created_instance) + else: + instances_by_parent_id[parent_id].append(created_instance) + + parent_ids_queue = collections.deque() + parent_ids_queue.extend( + instance.id for instance in filtered_instances + ) + while parent_ids_queue: + parent_id = parent_ids_queue.popleft() + children = instances_by_parent_id[parent_id] + if not children: + continue + filtered_instances.extend(children) + parent_ids_queue.extend(instance.id for instance in children) + + for created_instance in filtered_instances: instance_data = created_instance.data_to_store() - if instance_data["active"]: - thumbnail_path = thumbnail_paths_by_instance_id.get( - created_instance.id - ) - self.create_instance( - context, - instance_data, - created_instance.transient_data, - thumbnail_path - ) + thumbnail_path = thumbnail_paths_by_instance_id.get( + created_instance.id + ) + self.create_instance( + context, + instance_data, + created_instance.transient_data, + thumbnail_path + ) # Update global data to context context.data.update(create_context.context_data_to_store()) From 25aac472ab10c9575cbde22870dd5878233709f1 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 22 Jul 2025 11:58:40 +0200 Subject: [PATCH 044/319] added disable state to list view widget --- client/ayon_core/style/data.json | 1 + client/ayon_core/style/style.css | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/client/ayon_core/style/data.json b/client/ayon_core/style/data.json index 24629ec085..56d2190e09 100644 --- a/client/ayon_core/style/data.json +++ b/client/ayon_core/style/data.json @@ -97,6 +97,7 @@ }, "publisher": { "error": "#AA5050", + "disabled": "#5b6779", "crash": "#FF6432", "success": "#458056", "warning": "#ffc671", diff --git a/client/ayon_core/style/style.css b/client/ayon_core/style/style.css index b26d36fb7e..0d057beb7b 100644 --- a/client/ayon_core/style/style.css +++ b/client/ayon_core/style/style.css @@ -1153,6 +1153,10 @@ PixmapButton:disabled { color: {color:publisher:error}; } +#ListViewProductName[state="disabled"] { + color: {color:publisher:disabled}; +} + #PublishInfoFrame { background: {color:bg}; border-radius: 0.3em; From b50070937965c4a46482947262480f55f992bd08 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 22 Jul 2025 11:58:56 +0200 Subject: [PATCH 045/319] added 'InstanceContextInfo' to create imports --- client/ayon_core/pipeline/create/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/pipeline/create/__init__.py b/client/ayon_core/pipeline/create/__init__.py index ced43528eb..cbe009d95e 100644 --- a/client/ayon_core/pipeline/create/__init__.py +++ b/client/ayon_core/pipeline/create/__init__.py @@ -27,6 +27,7 @@ from .structures import ( CreatorAttributeValues, PublishAttributeValues, PublishAttributes, + InstanceContextInfo, ) from .utils import ( get_last_versions_for_instances, @@ -91,6 +92,7 @@ __all__ = ( "CreatorAttributeValues", "PublishAttributeValues", "PublishAttributes", + "InstanceContextInfo", "get_last_versions_for_instances", "get_next_versions_for_instances", From c8eb0faf3cf300605fbf2854ffbc5f0ef8de4cb1 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 22 Jul 2025 15:31:57 +0200 Subject: [PATCH 046/319] visualize instance parenting in list view --- .../publisher/widgets/list_view_widgets.py | 501 ++++++++++++------ 1 file changed, 331 insertions(+), 170 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 9fb0402810..65bc531d27 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -25,7 +25,7 @@ selection can be enabled disabled using checkbox or keyboard key presses: from __future__ import annotations import collections -import typing +from typing import Optional from qtpy import QtWidgets, QtCore, QtGui @@ -33,7 +33,14 @@ from ayon_core.style import get_objected_colors from ayon_core.tools.utils import NiceCheckbox, BaseClickableFrame from ayon_core.tools.utils.lib import html_escape, checkstate_int_to_enum +from ayon_core.pipeline.create import ( + InstanceContextInfo, +) + from ayon_core.tools.publisher.abstract import AbstractPublisherFrontend +from ayon_core.tools.publisher.models.create import ( + InstanceItem, +) from ayon_core.tools.publisher.constants import ( INSTANCE_ID_ROLE, SORT_VALUE_ROLE, @@ -47,9 +54,6 @@ from ayon_core.tools.publisher.constants import ( from .widgets import AbstractInstanceView -if typing.TYPE_CHECKING: - from ayon_core.tools.publisher.abstract import InstanceItem - class ListItemDelegate(QtWidgets.QStyledItemDelegate): """Generic delegate for instance group. @@ -121,7 +125,13 @@ class InstanceListItemWidget(QtWidgets.QWidget): active_changed = QtCore.Signal(str, bool) double_clicked = QtCore.Signal() - def __init__(self, instance, context_info, parent): + def __init__( + self, + instance: InstanceItem, + context_info: InstanceContextInfo, + parent_is_active: bool, + parent: QtWidgets.QWidget, + ): super().__init__(parent) self._instance_id = instance.id @@ -137,8 +147,6 @@ class InstanceListItemWidget(QtWidgets.QWidget): product_name_label.setObjectName("ListViewProductName") active_checkbox = NiceCheckbox(parent=self) - active_checkbox.setChecked(instance.is_active) - active_checkbox.setVisible(not instance.is_mandatory) layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(2, 0, 2, 0) @@ -146,20 +154,32 @@ class InstanceListItemWidget(QtWidgets.QWidget): layout.addStretch(1) layout.addWidget(active_checkbox) - self.setAttribute(QtCore.Qt.WA_TranslucentBackground) - product_name_label.setAttribute(QtCore.Qt.WA_TranslucentBackground) - active_checkbox.setAttribute(QtCore.Qt.WA_TranslucentBackground) + for widget in ( + self, + product_name_label, + active_checkbox, + ): + widget.setAttribute(QtCore.Qt.WA_TranslucentBackground) active_checkbox.stateChanged.connect(self._on_active_change) self._instance_label_widget = product_name_label self._active_checkbox = active_checkbox - self._has_valid_context = None + # Instance info + self._has_valid_context = context_info.is_valid + self._is_mandatory = instance.is_mandatory + self._instance_is_active = instance.is_active - self._checkbox_enabled = not instance.is_mandatory + # Parent active state is fluent and can change + self._parent_is_active = parent_is_active - self._set_valid_property(context_info.is_valid) + # Widget logic info + self._state = None + self._toggle_is_enabled = True + + self._update_style_state() + self._update_checkbox_state() def mouseDoubleClickEvent(self, event): widget = self.childAt(event.pos()) @@ -167,60 +187,108 @@ class InstanceListItemWidget(QtWidgets.QWidget): if widget is not self._active_checkbox: self.double_clicked.emit() - def _set_valid_property(self, valid): - if self._has_valid_context == valid: - return - self._has_valid_context = valid - state = "" - if not valid: - state = "invalid" - self._instance_label_widget.setProperty("state", state) - self._instance_label_widget.style().polish(self._instance_label_widget) - - def is_active(self): + def is_active(self) -> bool: """Instance is activated.""" return self._active_checkbox.isChecked() - def set_active(self, new_value): - """Change active state of instance and checkbox.""" - old_value = self.is_active() - if new_value is None: - new_value = not old_value - - if new_value != old_value: - self._active_checkbox.blockSignals(True) - self._active_checkbox.setChecked(new_value) - self._active_checkbox.blockSignals(False) - def is_checkbox_enabled(self) -> bool: """Checkbox can be changed by user.""" - return self._checkbox_enabled + return ( + self._parent_is_active + and not self._is_mandatory + ) - def update_instance(self, instance, context_info): + def set_active_toggle_enabled(self, enabled: bool) -> None: + """Toggle can be available for user.""" + self._toggle_is_enabled = enabled + self._update_checkbox_state() + + def set_active(self, new_value: Optional[bool]) -> None: + """Change active state of instance and checkbox by user interaction. + + Args: + new_value (Optional[bool]): New active state of instance. Toggle + if is 'None'. + + """ + # Do not allow to change state if is mandatory or parent is not active + if not self.is_checkbox_enabled(): + return + + if new_value is None: + new_value = not self._active_checkbox.isChecked() + # Update instance active state + self._instance_is_active = new_value + self._set_checked(new_value) + + def update_instance( + self, + instance: InstanceItem, + context_info: InstanceContextInfo, + parent_is_active: bool, + ) -> None: """Update instance object.""" # Check product name self._instance_id = instance.id label = instance.label if label != self._instance_label_widget.text(): self._instance_label_widget.setText(html_escape(label)) - # Check active state - self.set_active(instance.is_active) - self._set_is_mandatory(instance.is_mandatory) - # Check valid states - self._set_valid_property(context_info.is_valid) + + self._is_mandatory = instance.is_mandatory + self._instance_is_active = instance.is_active + self._has_valid_context = context_info.is_valid + self._parent_is_active = parent_is_active + + self._update_checkbox_state() + self._update_style_state() + + def set_parent_is_active(self, active: bool) -> None: + if self._parent_is_active is active: + return + self._parent_is_active = active + self._update_style_state() + self._update_checkbox_state() + + def _set_checked(self, checked: bool) -> None: + """Change checked state in UI without triggering checkstate change.""" + old_value = self._active_checkbox.isChecked() + if checked is not old_value: + self._active_checkbox.blockSignals(True) + self._active_checkbox.setChecked(checked) + self._active_checkbox.blockSignals(False) + + def _update_style_state(self) -> None: + state = "" + if not self._parent_is_active: + state = "disabled" + elif not self._has_valid_context: + state = "invalid" + + if state == self._state: + return + self._state = state + self._instance_label_widget.setProperty("state", state) + self._instance_label_widget.style().polish(self._instance_label_widget) + + def _update_checkbox_state(self) -> None: + self._active_checkbox.setEnabled( + self._toggle_is_enabled + and not self._is_mandatory + and self._parent_is_active + ) + # Hide checkbox for mandatory instances + self._active_checkbox.setVisible(not self._is_mandatory) + + # Visually disable instance if parent is disabled + checked = self._parent_is_active and self._instance_is_active + if checked is not self._active_checkbox.isChecked(): + self._active_checkbox.setChecked(checked) def _on_active_change(self): self.active_changed.emit( self._instance_id, self._active_checkbox.isChecked() ) - def set_active_toggle_enabled(self, enabled): - self._active_checkbox.setEnabled(enabled) - - def _set_is_mandatory(self, is_mandatory: bool) -> None: - self._checkbox_enabled = not is_mandatory - self._active_checkbox.setVisible(not is_mandatory) - class ListContextWidget(QtWidgets.QFrame): """Context (or global attributes) widget.""" @@ -421,7 +489,7 @@ class InstanceListView(AbstractInstanceView): self._active_toggle_enabled = True - def _on_toggle_request(self, toggle): + def _on_toggle_request(self, toggle: int) -> None: if not self._active_toggle_enabled: return @@ -432,20 +500,7 @@ class InstanceListView(AbstractInstanceView): active = True else: active = False - - group_names = set() - for instance_id in selected_instance_ids: - widget = self._widgets_by_id.get(instance_id) - if widget is None: - continue - - widget.set_active(active) - group_name = self._group_by_instance_id.get(instance_id) - if group_name is not None: - group_names.add(group_name) - - for group_name in group_names: - self._update_group_checkstate(group_name) + self._toggle_active_state(selected_instance_ids, active) def _update_group_checkstate(self, group_name): """Update checkstate of one group.""" @@ -454,8 +509,10 @@ class InstanceListView(AbstractInstanceView): return activity = None - for instance_id, _group_name in self._group_by_instance_id.items(): - if _group_name != group_name: + for ( + instance_id, instance_group_name + ) in self._group_by_instance_id.items(): + if instance_group_name != group_name: continue instance_widget = self._widgets_by_id.get(instance_id) @@ -509,13 +566,7 @@ class InstanceListView(AbstractInstanceView): group_label = instance.group_label group_names.add(group_label) instances_by_group_name[group_label].append(instance) - - missing_parent_ids = set(instances_by_parent_id) - instance_ids - for instance_id in missing_parent_ids: - for instance in instances_by_parent_id[instance_id]: - group_label = instance.group_label - group_names.add(group_label) - instances_by_group_name[group_label].append(instance) + self._group_by_instance_id[instance.id] = group_label # Create new groups based on prepared `instances_by_group_name` if self._make_sure_groups_exists(group_names): @@ -525,15 +576,42 @@ class InstanceListView(AbstractInstanceView): self._remove_groups_except(group_names) self._remove_instances_except(instance_items) - expand_groups = set() expand_to_items = [] widgets_by_id = {} + group_items = [ + ( + self._group_widgets[group_name], + instances_by_group_name[group_name], + group_item, + ) + for group_name, group_item in self._group_items.items() + ] + + # Handle orphaned instances + missing_parent_ids = set(instances_by_parent_id) - instance_ids + if not missing_parent_ids: + # Make sure the item is not in view if there are no orhpaned items + self._remove_missing_parent_item() + else: + # Add orphaned group item and append them to 'group_items' + orphans_item = self._add_missing_parent_item() + for instance_id in missing_parent_ids: + group_items.append(( + None, + instances_by_parent_id[instance_id], + orphans_item, + )) # Process changes in each group item # - create new instance, update existing and remove not existing - for group_name, group_item in self._group_items.items(): - # Collect all new instances that are not existing under group - # New items + for group_widget, group_instances, group_item in group_items: + # Group widget is not set if is orphaned + # - This might need to be changed in future if widget could + # be 'None' + is_orpaned_item = group_widget is None + + # Collect all new instances by parent id + # - 'None' is used if parent is group item new_items = collections.defaultdict(list) # Tuples of model item and instance itself items_with_instance = [] @@ -542,7 +620,7 @@ class InstanceListView(AbstractInstanceView): # - 1 when all instances are enabled # - -1 when it's mixed activity = None - for instance in instances_by_group_name[group_name]: + for instance in group_instances: _queue = collections.deque() _queue.append((instance, group_item, None)) while _queue: @@ -556,7 +634,9 @@ class InstanceListView(AbstractInstanceView): elif activity != instance.is_active: activity = -1 - self._group_by_instance_id[instance_id] = group_name + # Remove group name from groups mapping + if parent_id is not None: + self._group_by_instance_id.pop(instance_id, None) # Create new item and store it as new item = self._items_by_id.get(instance_id) @@ -572,7 +652,13 @@ class InstanceListView(AbstractInstanceView): children = instances_by_parent_id.pop(instance_id, []) items_with_instance.append( - (item, instance, bool(children)) + ( + item, + instance, + parent_id, + is_orpaned_item, + bool(children) + ) ) item.setData(instance.product_name, SORT_VALUE_ROLE) @@ -582,15 +668,13 @@ class InstanceListView(AbstractInstanceView): _queue.append((child, item, instance_id)) # Set checkstate of group checkbox - state = QtCore.Qt.PartiallyChecked - if activity == 0: - state = QtCore.Qt.Unchecked - elif activity == 1: - state = QtCore.Qt.Checked - - if group_name is not None: - widget = self._group_widgets[group_name] - widget.set_checkstate(state) + if group_widget is not None: + state = QtCore.Qt.PartiallyChecked + if activity == 0: + state = QtCore.Qt.Unchecked + elif activity == 1: + state = QtCore.Qt.Checked + group_widget.set_checkstate(state) # Process new instance items and add them to model and create # their widgets @@ -607,20 +691,38 @@ class InstanceListView(AbstractInstanceView): parent_item.appendRows(items) - for item, instance, has_children in items_with_instance: + for ( + item, instance, parent_id, is_orpaned_item, has_children + ) in items_with_instance: context_info = context_info_by_id[instance.id] # TODO expand all parents if not context_info.is_valid: - expand_groups.add(group_name) expand_to_items.append(item) + + parent_active = True + if is_orpaned_item: + parent_active = False + + if parent_id: + parent_widget = widgets_by_id.get(parent_id) + parent_active = False + if parent_widget is not None: + parent_active = parent_widget.is_active() item_index = self._instance_model.indexFromItem(item) proxy_index = self._proxy_model.mapFromSource(item_index) widget = self._instance_view.indexWidget(proxy_index) if isinstance(widget, InstanceListItemWidget): - widget.update_instance(instance, context_info) + widget.update_instance( + instance, + context_info, + parent_active, + ) else: widget = InstanceListItemWidget( - instance, context_info, self._instance_view + instance, + context_info, + parent_active, + self._instance_view ) widget.active_changed.connect(self._on_active_changed) widget.double_clicked.connect(self.double_clicked) @@ -639,10 +741,7 @@ class InstanceListView(AbstractInstanceView): self._widgets_by_id = widgets_by_id # Expand items marked for expanding - items_to_expand = [ - self._group_items[group_name] - for group_name in expand_groups - ] + items_to_expand = [] _marked_ids = set() for item in expand_to_items: parent = item.parent() @@ -669,7 +768,7 @@ class InstanceListView(AbstractInstanceView): if sort_at_the_end: self._proxy_model.sort(0) - def _make_sure_context_item_exists(self): + def _make_sure_context_item_exists(self) -> bool: if self._context_item is not None: return False @@ -692,7 +791,7 @@ class InstanceListView(AbstractInstanceView): self._context_item = context_item return True - def _update_convertor_items_group(self): + def _update_convertor_items_group(self) -> bool: created_new_items = False convertor_items_by_id = self._controller.get_convertor_items() group_item = self._convertor_group_item @@ -758,7 +857,7 @@ class InstanceListView(AbstractInstanceView): return created_new_items - def _make_sure_groups_exists(self, group_names): + def _make_sure_groups_exists(self, group_names: set[str]) -> bool: new_group_items = [] for group_name in group_names: if group_name in self._group_items: @@ -800,7 +899,7 @@ class InstanceListView(AbstractInstanceView): return True - def _remove_groups_except(self, group_names): + def _remove_groups_except(self, group_names: set[str]) -> None: # Remove groups that are not available anymore root_item = self._instance_model.invisibleRootItem() for group_name in tuple(self._group_items.keys()): @@ -840,14 +939,14 @@ class InstanceListView(AbstractInstanceView): for instance_id in all_removed_ids: self._items_by_id.pop(instance_id) - self._group_by_instance_id.pop(instance_id) self._parent_id_by_id.pop(instance_id) + self._group_by_instance_id.pop(instance_id, None) widget = self._widgets_by_id.pop(instance_id, None) if widget is not None: widget.setVisible(False) widget.deleteLater() - def _add_missing_parent_item(self): + def _add_missing_parent_item(self) -> QtGui.QStandardItem: label = "! Orphaned instances !" if self._missing_parent_item is None: item = QtGui.QStandardItem() @@ -857,7 +956,7 @@ class InstanceListView(AbstractInstanceView): item.setFlags(QtCore.Qt.ItemIsEnabled) self._missing_parent_item = item - if self._missing_parent_item.parent() is None: + if self._missing_parent_item.row() < 0: root_item = self._instance_model.invisibleRootItem() root_item.appendRow(self._missing_parent_item) index = self._missing_parent_item.index() @@ -867,7 +966,7 @@ class InstanceListView(AbstractInstanceView): self._instance_view.setIndexWidget(proxy_index, widget) return self._missing_parent_item - def _remove_missing_parent_item(self): + def _remove_missing_parent_item(self) -> None: if self._missing_parent_item is None: return @@ -890,34 +989,130 @@ class InstanceListView(AbstractInstanceView): """Trigger update of all instances.""" if instance_ids is not None: instance_ids = set(instance_ids) - context_info_by_id = self._controller.get_instances_context_info() + + context_info_by_id = self._controller.get_instances_context_info( + instance_ids + ) instance_items_by_id = self._controller.get_instance_items_by_id( instance_ids ) - for instance_id, widget in self._widgets_by_id.items(): - if instance_ids is not None and instance_id not in instance_ids: + instance_ids = set(instance_items_by_id) + + group_items = list(self._group_items.values()) + if self._missing_parent_item is not None: + group_items.append(self._missing_parent_item) + + _queue = collections.deque() + for group_item in group_items: + if not group_item.hasChildren(): continue - widget.update_instance( - instance_items_by_id[instance_id], - context_info_by_id[instance_id], - ) + + children = [ + group_item.child(row) + for row in range(group_item.rowCount()) + ] + _queue.append((children, True)) + + while _queue: + if not instance_ids: + break + + children, parent_active = _queue.popleft() + for child in children: + instance_id = child.data(INSTANCE_ID_ROLE) + widget = self._widgets_by_id[instance_id] + if instance_id in instance_ids: + instance_ids.discard(instance_id) + widget.update_instance( + instance_items_by_id[instance_id], + context_info_by_id[instance_id], + parent_active, + ) + if not instance_ids: + break + + if not child.hasChildren(): + continue + + children = [ + child.child(row) + for row in range(child.rowCount()) + ] + _queue.append((children, widget.is_active())) def _on_active_changed(self, changed_instance_id, new_value): selected_instance_ids, _, _ = self.get_selected_items() + if changed_instance_id not in selected_instance_ids: + selected_instance_ids = {changed_instance_id} + self._toggle_active_state( + set(selected_instance_ids), + new_value, + changed_instance_id + ) + + def _toggle_active_state( + self, + instance_ids: set[str], + new_value: Optional[bool], + active_id: Optional[str] = None, + ) -> None: + active_widget = None + if active_id: + active_widget = self._widgets_by_id[active_id] active_by_id = {} - found = False - for instance_id in selected_instance_ids: - active_by_id[instance_id] = new_value - if not found and instance_id == changed_instance_id: - found = True + if active_id and active_id not in instance_ids: + if not active_widget.is_checkbox_enabled(): + return + if new_value is None: + new_value = not active_widget.is_active() + active_by_id[active_id] = new_value + active_widget.set_active(new_value) + else: + # First make sure that the item under mouse is changed if possible + if active_widget and active_widget.is_checkbox_enabled(): + value = new_value + if value is None: + value = not active_widget.is_active() - if not found: - active_by_id = {changed_instance_id: new_value} + active_by_id[active_id] = value + active_widget.set_active(new_value) + instance_ids.discard(active_id) + + # Change the states from top to bottom + group_items = list(self._group_items.values()) + if self._missing_parent_item is not None: + group_items.append(self._missing_parent_item) + + _queue = collections.deque() + for group_item in group_items: + children = [ + group_item.child(row) + for row in range(group_item.rowCount()) + ] + _queue.append((children, True)) + + while _queue: + children, parent_active = _queue.popleft() + for child in children: + instance_id = child.data(INSTANCE_ID_ROLE) + widget = self._widgets_by_id[instance_id] + widget.set_parent_is_active(parent_active) + if parent_active and instance_id in instance_ids: + value = new_value + if value is None: + value = not widget.is_active() + widget.set_active(value) + active_by_id[instance_id] = value + + children = [ + child.child(row) + for row in range(child.rowCount()) + ] + _queue.append((children, widget.is_active())) self._controller.set_instances_active_state(active_by_id) - self._change_active_instances(active_by_id, new_value) group_names = set() for instance_id in active_by_id: group_name = self._group_by_instance_id.get(instance_id) @@ -927,15 +1122,6 @@ class InstanceListView(AbstractInstanceView): for group_name in group_names: self._update_group_checkstate(group_name) - def _change_active_instances(self, instance_ids, new_value): - if not instance_ids: - return - - for instance_id in instance_ids: - widget = self._widgets_by_id.get(instance_id) - if widget: - widget.set_active(new_value) - def _on_selection_change(self, *_args): self.selection_changed.emit() @@ -952,64 +1138,39 @@ class InstanceListView(AbstractInstanceView): if state == QtCore.Qt.PartiallyChecked: return - if state == QtCore.Qt.Checked: - active = True - else: - active = False - group_item = self._group_items.get(group_name) if not group_item: return - active_by_id = {} - all_changed = True - items_to_expand = [group_item] - _queue = collections.deque() - _queue.append(group_item) - while _queue: - item = _queue.popleft() - for row in range(item.rowCount()): - child = item.child(row) - instance_id = child.data(INSTANCE_ID_ROLE) - if child.hasChildren(): - items_to_expand.append(child) - _queue.append(child) - widget = self._widgets_by_id.get(instance_id) - if widget is None: - continue - if widget.is_checkbox_enabled(): - active_by_id[instance_id] = active - else: - all_changed = False + active = state == QtCore.Qt.Checked - self._controller.set_instances_active_state(active_by_id) + instance_ids = set() + for row in range(group_item.rowCount()): + child = group_item.child(row) + instance_id = child.data(INSTANCE_ID_ROLE) + instance_ids.add(instance_id) - self._change_active_instances(active_by_id, active) + self._toggle_active_state(instance_ids, active) - for item in items_to_expand: - proxy_index = self._proxy_model.mapFromSource(item.index()) - if not self._instance_view.isExpanded(proxy_index): - self._instance_view.expand(proxy_index) + proxy_index = self._proxy_model.mapFromSource(group_item.index()) + if not self._instance_view.isExpanded(proxy_index): + self._instance_view.expand(proxy_index) - if not all_changed: - # If not all instances were changed, update group checkstate - self._update_group_checkstate(group_name) - - def has_items(self): + def has_items(self) -> bool: if self._convertor_group_widget is not None: return True if self._group_items: return True return False - def get_selected_items(self): + def get_selected_items(self) -> tuple[list[str], bool, list[str]]: """Get selected instance ids and context selection. Returns: - tuple: Selected instance ids and boolean if context - is selected. - """ + tuple[list[str], bool, list[str]]: Selected instance ids, + boolean if context is selected and selected convertor ids. + """ instance_ids = [] convertor_identifiers = [] context_selected = False @@ -1133,7 +1294,7 @@ class InstanceListView(AbstractInstanceView): | QtCore.QItemSelectionModel.Rows ) - def set_active_toggle_enabled(self, enabled): + def set_active_toggle_enabled(self, enabled: bool) -> bool: if self._active_toggle_enabled is enabled: return From 293e5fe2e9d759e970d17781cde9c24c1b585c6f Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 01:14:11 +0200 Subject: [PATCH 047/319] Use `save_next_version` from Workfiles API https://github.com/ynput/ayon-core/pull/1275 in `version_up_current_workfile` --- client/ayon_core/pipeline/context_tools.py | 53 ++-------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index cccdafe6f1..308dd1bf44 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -580,53 +580,6 @@ def get_process_id(): def version_up_current_workfile(): - """Function to increment and save workfile - """ - host = registered_host() - - project_name = get_current_project_name() - folder_path = get_current_folder_path() - task_name = get_current_task_name() - host_name = get_current_host_name() - - template_key = get_workfile_template_key_from_context( - project_name, - folder_path, - task_name, - host_name, - ) - anatomy = Anatomy(project_name) - - data = get_template_data_with_names( - project_name, folder_path, task_name, host_name - ) - data["root"] = anatomy.roots - - work_template = anatomy.get_template_item("work", template_key) - - # Define saving file extension - extensions = host.get_workfile_extensions() - current_file = host.get_current_workfile() - if current_file: - extensions = [os.path.splitext(current_file)[-1]] - - work_root = work_template["directory"].format_strict(data) - file_template = work_template["file"].template - last_workfile_path = get_last_workfile( - work_root, file_template, data, extensions, True - ) - # `get_last_workfile` will return the first expected file version - # if no files exist yet. In that case, if they do not exist we will - # want to save v001 - new_workfile_path = last_workfile_path - if os.path.exists(new_workfile_path): - new_workfile_path = version_up(new_workfile_path) - - # Raise an error if the parent folder doesn't exist as `host.save_workfile` - # is not supposed/able to create missing folders. - parent_folder = os.path.dirname(new_workfile_path) - if not os.path.exists(parent_folder): - raise MissingWorkdirError( - f"Work area directory '{parent_folder}' does not exist.") - - host.save_workfile(new_workfile_path) + """Function to increment and save workfile""" + from ayon_core.pipeline.workfile.utils import save_next_version + save_next_version() From 4d142ab6289f7fafc3e6ca8d43110998eb00dab6 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:48:49 +0200 Subject: [PATCH 048/319] fill extension in template data --- client/ayon_core/pipeline/workfile/utils.py | 51 ++++++++++++++++----- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index 77c1953e4d..d5c717bd6d 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -411,8 +411,8 @@ def save_next_version( ) -> None: """Save workfile using current context, version and comment. - Helper function to save workfile using current context. Last workfile - version + 1 is used if is not passed in. + Helper function to save a workfile using the current context. Last + workfile version + 1 is used if is not passed in. Args: version (Optional[int]): Workfile version that will be used. Last @@ -480,10 +480,8 @@ def save_next_version( project_settings=project_settings, ) rootless_dir = workdir.rootless + last_workfile = None if version is None: - workfile_extensions = host.get_workfile_extensions() - if not workfile_extensions: - raise ValueError("Host does not have defined file extensions") workfiles = host.list_workfiles( project_name, folder_entity, task_entity, prepared_data=ListWorkfilesOptionalData( @@ -493,14 +491,18 @@ def save_next_version( template_key=template_key, ) ) - versions = { - workfile.version - for workfile in workfiles - if workfile.version is not None - } + for workfile in workfiles: + if workfile.version is None: + continue + if ( + last_workfile is None + or last_workfile.version < workfile.version + ): + last_workfile = workfile + version = None - if versions: - version = max(versions) + 1 + if last_workfile is not None: + version = last_workfile.version + 1 if version is None: version = get_versioning_start( @@ -514,6 +516,26 @@ def save_next_version( template_data["version"] = version template_data["comment"] = comment + # Resolve extension + # - Don't fill any if the host does not have defined any -> e.g. if host + # uses directory instead of a file. + # 1. Use the current file extension. + # 2. Use the last known workfile extension. + # 3. Use the first extensions from 'get_workfile_extensions'. + ext = None + workfile_extensions = host.get_workfile_extensions() + if workfile_extensions: + current_path = host.get_current_workfile() + if current_path: + ext = os.path.splitext(current_path)[1].lstrip(".") + elif last_workfile is not None: + ext = os.path.splitext(last_workfile.filepath)[1].lstrip(".") + else: + ext = next(iter(workfile_extensions), None) + + if ext: + template_data["ext"] = ext + filename = file_template.format_strict(template_data) workfile_path = os.path.join(workdir, filename) rootless_path = f"{rootless_dir}/{filename}" @@ -632,6 +654,11 @@ def copy_workfile_to_context( if comment: template_data["comment"] = comment + workfile_extensions = host.get_workfile_extensions() + if workfile_extensions: + ext = os.path.splitext(src_workfile_path)[1].lstrip(".") + template_data["ext"] = ext + workfile_template = anatomy.get_template_item( "work", template_key, "path" ) From 94b96345552beaccf6a16530d7a8b89f9035235d Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:25:55 +0200 Subject: [PATCH 049/319] Fix logged warnings --- .../plugins/publish/collect_scene_loaded_versions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 1abb8e29d2..c8d9747091 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -27,12 +27,13 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): def process(self, context): host = registered_host() if host is None: - self.log.warn("No registered host.") + self.log.warning("No registered host.") return if not hasattr(host, "ls"): host_name = host.__name__ - self.log.warn("Host %r doesn't have ls() implemented." % host_name) + self.log.warning( + f"Host {host_name} doesn't have ls() implemented.") return loaded_versions = [] From f0ea841ebf339a14940792d268e46918c2c60a3c Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:29:23 +0200 Subject: [PATCH 050/319] Use `ILoadHost.get_containers()` when available --- .../publish/collect_scene_loaded_versions.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index c8d9747091..34d3e5b136 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -1,7 +1,9 @@ import ayon_api import ayon_api.utils +from ayon_core.host import ILoadHost from ayon_core.pipeline import registered_host + import pyblish.api @@ -30,14 +32,19 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): self.log.warning("No registered host.") return - if not hasattr(host, "ls"): + if isinstance(host, ILoadHost): + containers = list(host.get_containers()) + elif hasattr(host, "ls"): + # Backwards compatibility for legacy host implementations + containers = list(host.ls()) + else: host_name = host.__name__ self.log.warning( - f"Host {host_name} doesn't have ls() implemented.") + f"Host {host_name} does not implement ILoadHost " + f"nor does it have ls() implemented. Skipping querying of " + f"loaded versions in scene.") return - loaded_versions = [] - containers = list(host.ls()) repre_ids = { container["representation"] for container in containers @@ -62,6 +69,7 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): # QUESTION should we add same representation id when loaded multiple # times? + loaded_versions = [] for con in containers: repre_id = con["representation"] repre_entity = repre_entities_by_id.get(repre_id) From 5a44efd2ad60cbd380c706217f896106958afb1c Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:31:29 +0200 Subject: [PATCH 051/319] Opt-out early if there are no containers in the scene file --- .../plugins/publish/collect_scene_loaded_versions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 34d3e5b136..e3e938b65b 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -45,6 +45,11 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): f"loaded versions in scene.") return + if not containers: + # Opt out early if there are no containers + self.log.debug("No loaded containers found in scene.") + return + repre_ids = { container["representation"] for container in containers From 8b8cff8ea5036e7a49e3b61e036f7beec35642fb Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:32:48 +0200 Subject: [PATCH 052/319] Add debug log --- .../ayon_core/plugins/publish/collect_scene_loaded_versions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index e3e938b65b..ea949eb087 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -94,4 +94,5 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): } loaded_versions.append(version) + self.log.debug(f"Collected {len(loaded_versions)} loaded versions.") context.data["loadedVersions"] = loaded_versions From 6def9655f07f8c1dcb80d38a1cb52ff617f03e2e Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:39:08 +0200 Subject: [PATCH 053/319] Do not use deprecated `Logger.warn`, use `Logger.warning` instead --- client/ayon_core/plugins/publish/integrate_inputlinks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/integrate_inputlinks.py b/client/ayon_core/plugins/publish/integrate_inputlinks.py index a3b6a228d6..be399a95fc 100644 --- a/client/ayon_core/plugins/publish/integrate_inputlinks.py +++ b/client/ayon_core/plugins/publish/integrate_inputlinks.py @@ -105,7 +105,7 @@ class IntegrateInputLinksAYON(pyblish.api.ContextPlugin): created links by its type """ if workfile_instance is None: - self.log.warn("No workfile in this publish session.") + self.log.warning("No workfile in this publish session.") return workfile_version_id = workfile_instance.data["versionEntity"]["id"] From ecd3538dfd481d7fe3c4a4388d3affe7f7d4b615 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:46:52 +0200 Subject: [PATCH 054/319] Update client/ayon_core/plugins/publish/collect_scene_loaded_versions.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../ayon_core/plugins/publish/collect_scene_loaded_versions.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index ea949eb087..9574c8c211 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -34,9 +34,6 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): if isinstance(host, ILoadHost): containers = list(host.get_containers()) - elif hasattr(host, "ls"): - # Backwards compatibility for legacy host implementations - containers = list(host.ls()) else: host_name = host.__name__ self.log.warning( From 737f3acde17b3d5fb344b7bdeb67cd7deb22c210 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 23 Jul 2025 11:47:19 +0200 Subject: [PATCH 055/319] parent instance id is handled with special attributes --- client/ayon_core/pipeline/create/context.py | 44 +++++++++++++++ .../ayon_core/pipeline/create/structures.py | 54 +++++++++++++++++-- 2 files changed, 93 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index 929cc59d2a..f2bca97cfe 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -80,6 +80,7 @@ INSTANCE_ADDED_TOPIC = "instances.added" INSTANCE_REMOVED_TOPIC = "instances.removed" VALUE_CHANGED_TOPIC = "values.changed" INSTANCE_REQUIREMENT_CHANGED_TOPIC = "instance.requirement.changed" +INSTANCE_PARENT_CHANGED_TOPIC = "instance.parent.changed" PRE_CREATE_ATTR_DEFS_CHANGED_TOPIC = "pre.create.attr.defs.changed" CREATE_ATTR_DEFS_CHANGED_TOPIC = "create.attr.defs.changed" PUBLISH_ATTR_DEFS_CHANGED_TOPIC = "publish.attr.defs.changed" @@ -262,6 +263,8 @@ class CreateContext: # - right now used only for 'mandatory' but can be extended # in future "requirement_change": BulkInfo(), + # Instance parent changed + "parent_change": BulkInfo(), } self._bulk_order = [] @@ -1364,6 +1367,13 @@ class CreateContext: ) as bulk_info: yield bulk_info + @contextmanager + def bulk_instance_parent_change(self, sender: Optional[str] = None): + with self._bulk_context( + "parent_change", sender + ) as bulk_info: + yield bulk_info + @contextmanager def bulk_publish_attr_defs_change(self, sender: Optional[str] = None): with self._bulk_context("publish_attrs_change", sender) as bulk_info: @@ -1444,6 +1454,19 @@ class CreateContext: with self.bulk_instance_requirement_change() as bulk_item: bulk_item.append(instance_id) + def instance_parent_changed(self, instance_id: str) -> None: + """Instance parent changed. + + Triggered by `CreatedInstance`. + + Args: + instance_id (Optional[str]): Instance id. + + """ + if self._is_instance_events_ready(instance_id): + with self.bulk_instance_parent_change() as bulk_item: + bulk_item.append(instance_id) + # --- context change callbacks --- def publish_attribute_value_changed( self, plugin_name: str, value: dict[str, Any] @@ -2305,6 +2328,8 @@ class CreateContext: self._bulk_publish_attrs_change_finished(data, sender) elif key == "requirement_change": self._bulk_instance_requirement_change_finished(data, sender) + elif key == "parent_change": + self._bulk_instance_parent_change_finished(data, sender) def _bulk_add_instances_finished( self, @@ -2518,3 +2543,22 @@ class CreateContext: {"instances": instances}, sender, ) + + def _bulk_instance_parent_change_finished( + self, + instance_ids: list[str], + sender: Optional[str], + ): + if not instance_ids: + return + + instances = [ + self.get_instance_by_id(instance_id) + for instance_id in set(instance_ids) + ] + + self._emit_event( + INSTANCE_PARENT_CHANGED_TOPIC, + {"instances": instances}, + sender, + ) \ No newline at end of file diff --git a/client/ayon_core/pipeline/create/structures.py b/client/ayon_core/pipeline/create/structures.py index 3048ae2829..562a3a581d 100644 --- a/client/ayon_core/pipeline/create/structures.py +++ b/client/ayon_core/pipeline/create/structures.py @@ -1,6 +1,7 @@ import copy import collections from uuid import uuid4 +from enum import Enum import typing from typing import Optional, Dict, List, Any @@ -22,6 +23,18 @@ if typing.TYPE_CHECKING: from .creator_plugins import BaseCreator +class IntEnum(int, Enum): + """An int-based Enum class that allows for int comparison.""" + + def __int__(self) -> int: + return self.value + + +class ParentFlags(IntEnum): + # Delete instance if parent is deleted + parent_lifetime = 1 + + class ConvertorItem: """Item representing convertor plugin. @@ -507,7 +520,9 @@ class CreatedInstance: if transient_data is None: transient_data = {} self._transient_data = transient_data - self._is_mandatory = False + self._is_mandatory: bool = False + self._parent_instance_id: Optional[str] = None + self._parent_flags: int = 0 # Create a copy of passed data to avoid changing them on the fly data = copy.deepcopy(data or {}) @@ -653,10 +668,6 @@ class CreatedInstance: def product_name(self): return self._data["productName"] - @property - def parent_instance_id(self) -> Optional[str]: - return self._data.get("parentInstanceId") - @property def label(self): label = self._data.get("label") @@ -756,6 +767,39 @@ class CreatedInstance: self["active"] = True self._create_context.instance_requirement_changed(self.id) + @property + def parent_instance_id(self) -> Optional[str]: + return self._parent_instance_id + + @property + def parent_flags(self) -> int: + return self._parent_flags + + def set_parent( + self, instance_id: Optional[str], flags: int + ) -> None: + """Set parent instance id and parenting flags. + + Args: + instance_id (Optional[str]): Parent instance id. + flags (int): Parenting flags. + + """ + changed = False + if instance_id != self._parent_instance_id: + changed = True + self._parent_instance_id = instance_id + + if flags is None: + flags = 0 + + if self._parent_flags != flags: + self._parent_flags = flags + changed = True + + if changed: + self._create_context.instance_parent_changed(self.id) + def changes(self): """Calculate and return changes.""" From 654833054901c0e53b9e2683328fad46610446cb Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:47:38 +0200 Subject: [PATCH 056/319] Reformat code --- .../plugins/publish/collect_scene_loaded_versions.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 9574c8c211..ee448e7911 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -32,16 +32,15 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): self.log.warning("No registered host.") return - if isinstance(host, ILoadHost): - containers = list(host.get_containers()) - else: + if not isinstance(host, ILoadHost): host_name = host.__name__ self.log.warning( - f"Host {host_name} does not implement ILoadHost " - f"nor does it have ls() implemented. Skipping querying of " - f"loaded versions in scene.") + f"Host {host_name} does not implement ILoadHost. " + "Skipping querying of loaded versions in scene." + ) return + containers = list(host.get_containers()) if not containers: # Opt out early if there are no containers self.log.debug("No loaded containers found in scene.") From ff7a63099be3a8437cce18e310b89d1476a7ba7b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 23 Jul 2025 11:47:57 +0200 Subject: [PATCH 057/319] handle parent lifetime flag --- client/ayon_core/pipeline/create/__init__.py | 2 + client/ayon_core/pipeline/create/context.py | 130 ++++++++++++------- 2 files changed, 86 insertions(+), 46 deletions(-) diff --git a/client/ayon_core/pipeline/create/__init__.py b/client/ayon_core/pipeline/create/__init__.py index cbe009d95e..c8c780504f 100644 --- a/client/ayon_core/pipeline/create/__init__.py +++ b/client/ayon_core/pipeline/create/__init__.py @@ -21,6 +21,7 @@ from .exceptions import ( TemplateFillError, ) from .structures import ( + ParentFlags, CreatedInstance, ConvertorItem, AttributeValues, @@ -86,6 +87,7 @@ __all__ = ( "TaskNotSetError", "TemplateFillError", + "ParentFlags", "CreatedInstance", "ConvertorItem", "AttributeValues", diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index f2bca97cfe..1cf8f08eff 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -41,7 +41,12 @@ from .exceptions import ( HostMissRequiredMethod, ) from .changes import TrackChangesItem -from .structures import PublishAttributes, ConvertorItem, InstanceContextInfo +from .structures import ( + PublishAttributes, + ConvertorItem, + InstanceContextInfo, + ParentFlags, +) from .creator_plugins import ( Creator, AutoCreator, @@ -2069,63 +2074,96 @@ class CreateContext: sender (Optional[str]): Sender of the event. """ + instance_ids_by_parent_id = collections.defaultdict(set) + for instance in self.instances: + instance_ids_by_parent_id[instance.parent_instance_id].add( + instance.id + ) + + instances_to_remove = list(instances) + ids_to_remove = { + instance.id + for instance in instances_to_remove + } + _queue = collections.deque() + _queue.extend(instances_to_remove) + while _queue: + instance = _queue.popleft() + ids_to_remove.add(instance.id) + children_ids = instance_ids_by_parent_id[instance.id] + for children_id in children_ids: + if children_id in ids_to_remove: + continue + instance = self._instances_by_id[children_id] + if instance.parent_flags & ParentFlags.parent_lifetime: + instances_to_remove.append(instance) + ids_to_remove.add(instance.id) + _queue.append(instance) + instances_by_identifier = collections.defaultdict(list) - for instance in instances: + for instance in instances_to_remove: identifier = instance.creator_identifier instances_by_identifier[identifier].append(instance) # Just remove instances from context if creator is not available missing_creators = set(instances_by_identifier) - set(self.creators) - instances = [] + miss_creator_instances = [] for identifier in missing_creators: - instances.extend( - instance - for instance in instances_by_identifier[identifier] - ) + miss_creator_instances.extend(instances_by_identifier[identifier]) - self._remove_instances(instances, sender) + with self.bulk_remove_instances(sender): + self._remove_instances(miss_creator_instances, sender) - error_message = "Instances removement of creator \"{}\" failed. {}" - failed_info = [] - # Remove instances by creator plugin order - for creator in self.get_sorted_creators( - instances_by_identifier.keys() - ): - identifier = creator.identifier - creator_instances = instances_by_identifier[identifier] + error_message = "Instances removement of creator \"{}\" failed. {}" + failed_info = [] + # Remove instances by creator plugin order + for creator in self.get_sorted_creators( + instances_by_identifier.keys() + ): + identifier = creator.identifier + # Filter instances by current state of 'CreateContext' + # - in case instances were already removed as subroutine of + # previous create plugin. + creator_instances = [ + instance + for instance in instances_by_identifier[identifier] + if instance.id in self._instances_by_id + ] + if not creator_instances: + continue - label = creator.label - failed = False - add_traceback = False - exc_info = None - try: - creator.remove_instances(creator_instances) + label = creator.label + failed = False + add_traceback = False + exc_info = None + try: + creator.remove_instances(creator_instances) - except CreatorError: - failed = True - exc_info = sys.exc_info() - self.log.warning( - error_message.format(identifier, exc_info[1]) - ) - - except (KeyboardInterrupt, SystemExit): - raise - - except: # noqa: E722 - failed = True - add_traceback = True - exc_info = sys.exc_info() - self.log.warning( - error_message.format(identifier, ""), - exc_info=True - ) - - if failed: - failed_info.append( - prepare_failed_creator_operation_info( - identifier, label, exc_info, add_traceback + except CreatorError: + failed = True + exc_info = sys.exc_info() + self.log.warning( + error_message.format(identifier, exc_info[1]) + ) + + except (KeyboardInterrupt, SystemExit): + raise + + except: # noqa: E722 + failed = True + add_traceback = True + exc_info = sys.exc_info() + self.log.warning( + error_message.format(identifier, ""), + exc_info=True + ) + + if failed: + failed_info.append( + prepare_failed_creator_operation_info( + identifier, label, exc_info, add_traceback + ) ) - ) if failed_info: raise CreatorsRemoveFailed(failed_info) From 3941040d23e14aebfaa7b8c1d561ea011d8b34eb Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 12:22:28 +0200 Subject: [PATCH 058/319] Update client/ayon_core/plugins/publish/collect_scene_loaded_versions.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../ayon_core/plugins/publish/collect_scene_loaded_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index ee448e7911..524381f656 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -33,7 +33,7 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): return if not isinstance(host, ILoadHost): - host_name = host.__name__ + host_name = host.name self.log.warning( f"Host {host_name} does not implement ILoadHost. " "Skipping querying of loaded versions in scene." From 55a7db79899be57494591e434b447bc3319245c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Wed, 23 Jul 2025 16:59:20 +0200 Subject: [PATCH 059/319] :recycle: revive linked assets/folders in template builder Adding back linked assets/folder feature that was there in template builder in OpenPype. This is now working with template type links of AYON. --- .../workfile/workfile_template_builder.py | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index b0fad8d2a1..276f90af80 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -313,7 +313,8 @@ class AbstractTemplateBuilder(ABC): if not folder_entity: return [] links = get_folder_links( - project_name, folder_entity["id"], link_direction="in" + project_name, + folder_entity["id"], link_types=["template"], link_direction="in" ) linked_folder_ids = { link["entityId"] @@ -1429,8 +1430,7 @@ class PlaceholderLoadMixin(object): builder_type_enum_items = [ {"label": "Current folder", "value": "context_folder"}, - # TODO implement linked folders - # {"label": "Linked folders", "value": "linked_folders"}, + {"label": "Linked folders", "value": "linked_folders"}, {"label": "All folders", "value": "all_folders"}, ] build_type_label = "Folder Builder Type" @@ -1607,10 +1607,7 @@ class PlaceholderLoadMixin(object): builder_type = placeholder.data["builder_type"] folder_ids = [] - if builder_type == "context_folder": - folder_ids = [current_folder_entity["id"]] - - elif builder_type == "all_folders": + if builder_type == "all_folders": folder_ids = { folder_entity["id"] for folder_entity in get_folders( @@ -1620,6 +1617,19 @@ class PlaceholderLoadMixin(object): ) } + elif builder_type == "context_folder": + folder_ids = [current_folder_entity["id"]] + + elif builder_type == "linked_folders": + # Get all linked folders for the current folder + if hasattr(self, "builder") and isinstance( + self.builder, AbstractTemplateBuilder): + # self.builder: AbstractTemplateBuilder + folder_ids = [ + linked_folder_entity["id"] + for linked_folder_entity in self.builder.linked_folder_entities # noqa: E501 + ] + if not folder_ids: return [] From cc9be12d22e7f5eb524d5f6eabfdb1ee9a049f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Wed, 23 Jul 2025 17:16:11 +0200 Subject: [PATCH 060/319] :recycle: break the long line --- .../ayon_core/pipeline/workfile/workfile_template_builder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index 276f90af80..bfa192d834 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -1627,7 +1627,8 @@ class PlaceholderLoadMixin(object): # self.builder: AbstractTemplateBuilder folder_ids = [ linked_folder_entity["id"] - for linked_folder_entity in self.builder.linked_folder_entities # noqa: E501 + for linked_folder_entity in ( + self.builder.linked_folder_entities) ] if not folder_ids: From 50e6c541f982a52ede822f70eb72074888f038c6 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 10:59:34 +0200 Subject: [PATCH 061/319] reuse comment from last workfile --- client/ayon_core/pipeline/workfile/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index d5c717bd6d..36e72bb55a 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -417,7 +417,9 @@ def save_next_version( Args: version (Optional[int]): Workfile version that will be used. Last version + 1 is used if is not passed in. - comment (optional[str]): Workfile comment. + comment (optional[str]): Workfile comment. Pass '""' to clear comment. + The last workfile comment is used if it is not passed in and + passed 'version' is 'None'. description (Optional[str]): Workfile description. prepared_data (Optional[SaveWorkfileOptionalData]): Prepared data for speed enhancements. @@ -513,6 +515,9 @@ def save_next_version( product_type="workfile" ) + if comment is None and last_workfile is not None: + comment = last_workfile.comment + template_data["version"] = version template_data["comment"] = comment From eea1f4cb6a9057a1cf5c4a00e5ba26ecd07985d8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:05:41 +0200 Subject: [PATCH 062/319] re-use comment from current file --- client/ayon_core/pipeline/workfile/utils.py | 24 +++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index 36e72bb55a..a6e4dad2b4 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -429,6 +429,11 @@ def save_next_version( from ayon_core.pipeline.context_tools import registered_host host = registered_host() + current_path = host.get_current_workfile() + if not current_path: + current_path = None + else: + current_path = os.path.normpath(current_path) context = host.get_current_context() project_name = context["project_name"] @@ -483,6 +488,7 @@ def save_next_version( ) rootless_dir = workdir.rootless last_workfile = None + current_workfile = None if version is None: workfiles = host.list_workfiles( project_name, folder_entity, task_entity, @@ -496,6 +502,10 @@ def save_next_version( for workfile in workfiles: if workfile.version is None: continue + + if current_workfile is None and workfile.filepath == current_path: + current_workfile = workfile + if ( last_workfile is None or last_workfile.version < workfile.version @@ -515,11 +525,18 @@ def save_next_version( product_type="workfile" ) - if comment is None and last_workfile is not None: - comment = last_workfile.comment + # Re-use comment if is not set + if comment is None: + if current_workfile is not None: + # Use 'comment' from the current workfile if is set + comment = current_workfile.comment + elif last_workfile is not None: + # Use 'comment' from the last workfile + comment = last_workfile.comment template_data["version"] = version - template_data["comment"] = comment + if comment: + template_data["comment"] = comment # Resolve extension # - Don't fill any if the host does not have defined any -> e.g. if host @@ -530,7 +547,6 @@ def save_next_version( ext = None workfile_extensions = host.get_workfile_extensions() if workfile_extensions: - current_path = host.get_current_workfile() if current_path: ext = os.path.splitext(current_path)[1].lstrip(".") elif last_workfile is not None: From 4b5431f26718169a93cda20706b37f343f441e8b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:07:09 +0200 Subject: [PATCH 063/319] added helper functions to workfile __init__.py --- client/ayon_core/pipeline/workfile/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/__init__.py b/client/ayon_core/pipeline/workfile/__init__.py index c6a0e0d80b..7acaf69a7c 100644 --- a/client/ayon_core/pipeline/workfile/__init__.py +++ b/client/ayon_core/pipeline/workfile/__init__.py @@ -22,9 +22,11 @@ from .utils import ( should_open_workfiles_tool_on_launch, MissingWorkdirError, + save_workfile_info, save_current_workfile_to, save_workfile_with_current_context, - save_workfile_info, + save_next_version, + copy_workfile_to_context, find_workfile_rootless_path, ) @@ -63,9 +65,11 @@ __all__ = ( "should_open_workfiles_tool_on_launch", "MissingWorkdirError", + "save_workfile_info", "save_current_workfile_to", "save_workfile_with_current_context", - "save_workfile_info", + "save_next_version", + "copy_workfile_to_context", "BuildWorkfile", From 15854f07060838d9e3c5008feeb4551d5da898c5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:49:00 +0200 Subject: [PATCH 064/319] revert some of the logic --- client/ayon_core/pipeline/workfile/utils.py | 43 +++++++++------------ 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index a6e4dad2b4..3812fb6471 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -418,8 +418,7 @@ def save_next_version( version (Optional[int]): Workfile version that will be used. Last version + 1 is used if is not passed in. comment (optional[str]): Workfile comment. Pass '""' to clear comment. - The last workfile comment is used if it is not passed in and - passed 'version' is 'None'. + The current workfile comment is used if it is not passed. description (Optional[str]): Workfile description. prepared_data (Optional[SaveWorkfileOptionalData]): Prepared data for speed enhancements. @@ -489,7 +488,7 @@ def save_next_version( rootless_dir = workdir.rootless last_workfile = None current_workfile = None - if version is None: + if version is None or comment is None: workfiles = host.list_workfiles( project_name, folder_entity, task_entity, prepared_data=ListWorkfilesOptionalData( @@ -500,39 +499,33 @@ def save_next_version( ) ) for workfile in workfiles: - if workfile.version is None: - continue - if current_workfile is None and workfile.filepath == current_path: current_workfile = workfile + if workfile.version is None: + continue + if ( last_workfile is None or last_workfile.version < workfile.version ): last_workfile = workfile - version = None - if last_workfile is not None: - version = last_workfile.version + 1 + if version is None and last_workfile is not None: + version = last_workfile.version + 1 - if version is None: - version = get_versioning_start( - project_name, - host.name, - task_name=task_entity["name"], - task_type=task_entity["taskType"], - product_type="workfile" - ) + if version is None: + version = get_versioning_start( + project_name, + host.name, + task_name=task_entity["name"], + task_type=task_entity["taskType"], + product_type="workfile" + ) - # Re-use comment if is not set - if comment is None: - if current_workfile is not None: - # Use 'comment' from the current workfile if is set - comment = current_workfile.comment - elif last_workfile is not None: - # Use 'comment' from the last workfile - comment = last_workfile.comment + # Re-use comment from the current workfile if is not passed in + if comment is None and current_workfile is not None: + comment = current_workfile.comment template_data["version"] = version if comment: From 583dae949dabe0abd75fb1bb311dbe6547a1730d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:57:25 +0200 Subject: [PATCH 065/319] strip dot of extension --- client/ayon_core/pipeline/workfile/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index 3812fb6471..354449bd3e 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -541,11 +541,12 @@ def save_next_version( workfile_extensions = host.get_workfile_extensions() if workfile_extensions: if current_path: - ext = os.path.splitext(current_path)[1].lstrip(".") + ext = os.path.splitext(current_path)[1] elif last_workfile is not None: - ext = os.path.splitext(last_workfile.filepath)[1].lstrip(".") + ext = os.path.splitext(last_workfile.filepath)[1] else: ext = next(iter(workfile_extensions), None) + ext = ext.lstrip(".") if ext: template_data["ext"] = ext From 4204de3ab2482903f1c84b597e29487dfbadf6a4 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:34:53 +0200 Subject: [PATCH 066/319] pass variant to actions list --- client/ayon_core/tools/launcher/models/actions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/launcher/models/actions.py b/client/ayon_core/tools/launcher/models/actions.py index adb8d371ed..1a8e423751 100644 --- a/client/ayon_core/tools/launcher/models/actions.py +++ b/client/ayon_core/tools/launcher/models/actions.py @@ -399,7 +399,11 @@ class ActionsModel: return cache.get_data() try: - response = ayon_api.post("actions/list", **request_data) + # 'variant' query is supported since AYON backend 1.10.4 + query = urlencode({"variant": self._variant}) + response = ayon_api.post( + f"actions/list?{query}", **request_data + ) response.raise_for_status() except Exception: self.log.warning("Failed to collect webactions.", exc_info=True) From a4ec6c4a774008dd66af401957f05d1e55569e8c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:40:59 +0200 Subject: [PATCH 067/319] Remove redundant default value Co-authored-by: Roy Nieterau --- client/ayon_core/pipeline/workfile/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index 354449bd3e..6666853998 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -545,7 +545,7 @@ def save_next_version( elif last_workfile is not None: ext = os.path.splitext(last_workfile.filepath)[1] else: - ext = next(iter(workfile_extensions), None) + ext = next(iter(workfile_extensions)) ext = ext.lstrip(".") if ext: From 351167a8d62fc59ddd693b9ab45ecad65eecc177 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 24 Jul 2025 13:33:35 +0200 Subject: [PATCH 068/319] Remove unused imports --- client/ayon_core/pipeline/context_tools.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 308dd1bf44..b06d34b26f 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -16,7 +16,6 @@ from ayon_core.host import HostBase from ayon_core.lib import ( is_in_tests, initialize_ayon_connection, - version_up ) from ayon_core.addon import load_addons, AddonsManager from ayon_core.settings import get_project_settings @@ -24,12 +23,7 @@ from ayon_core.settings import get_project_settings from .publish.lib import filter_pyblish_plugins from .anatomy import Anatomy from .template_data import get_template_data_with_names -from .workfile import ( - get_custom_workfile_template_by_string_context, - get_workfile_template_key_from_context, - get_last_workfile, - MissingWorkdirError, -) +from .workfile import get_custom_workfile_template_by_string_context from . import ( register_loader_plugin_path, register_inventory_action_path, From 2d3259aac6170d82106a8f469376cd076b22baea Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 24 Jul 2025 13:36:14 +0200 Subject: [PATCH 069/319] Import from a level up --- client/ayon_core/pipeline/context_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index b06d34b26f..9b29fa0b3a 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -575,5 +575,5 @@ def get_process_id(): def version_up_current_workfile(): """Function to increment and save workfile""" - from ayon_core.pipeline.workfile.utils import save_next_version + from ayon_core.pipeline.workfile import save_next_version save_next_version() From 39c72809b9c13d773fc1abb217658c3d495bff9f Mon Sep 17 00:00:00 2001 From: Ynbot Date: Thu, 24 Jul 2025 12:05:37 +0000 Subject: [PATCH 070/319] [Automated] Add generated package files from main --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 509c4a8d14..5e5ea1ca3a 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.4.1+dev" +__version__ = "1.5.0" diff --git a/package.py b/package.py index 039bf0379c..f10bbe29cb 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.4.1+dev" +version = "1.5.0" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 68e1ed39a3..9e1046dc43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.4.1+dev" +version = "1.5.0" description = "" authors = ["Ynput Team "] readme = "README.md" From 34d2c6e6e1f21c452e0c50524b33eefcb6087fd3 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Thu, 24 Jul 2025 12:06:16 +0000 Subject: [PATCH 071/319] [Automated] Update version in package.py for develop --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 5e5ea1ca3a..7f55a17a01 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.5.0" +__version__ = "1.5.0+dev" diff --git a/package.py b/package.py index f10bbe29cb..807e4e4b35 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.5.0" +version = "1.5.0+dev" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 9e1046dc43..e7977a5579 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.5.0" +version = "1.5.0+dev" description = "" authors = ["Ynput Team "] readme = "README.md" From 7382eb338c82618a7ab2161630a8be176c66fa3a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 24 Jul 2025 12:07:11 +0000 Subject: [PATCH 072/319] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 9fb6ee645d..9202190f8b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to AYON Tray options: + - 1.5.0 - 1.4.1 - 1.4.0 - 1.3.2 From 3cba26a85f4ca068a1229a146a36d981a388a31b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:21:19 +0200 Subject: [PATCH 073/319] moved 'get_current_project_settings' to pipeline context tools --- client/ayon_core/pipeline/context_tools.py | 18 +++++++++++++ client/ayon_core/settings/lib.py | 30 +++++++++++++--------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 9b29fa0b3a..0877f2f049 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -360,6 +360,24 @@ def get_current_task_name(): return get_global_context()["task_name"] +def get_current_project_settings() -> dict[str, Any]: + """Project settings for the current context project. + + Returns: + dict[str, Any]: Project settings for the current context project. + + Raises: + ValueError: If current project is not set. + + """ + project_name = get_current_project_name() + if not project_name: + raise ValueError( + "Current project is not set. Can't get project settings." + ) + return get_project_settings(project_name) + + def get_current_project_entity(fields=None): """Helper function to get project document based on global Session. diff --git a/client/ayon_core/settings/lib.py b/client/ayon_core/settings/lib.py index 72af07799f..fbbd860397 100644 --- a/client/ayon_core/settings/lib.py +++ b/client/ayon_core/settings/lib.py @@ -4,6 +4,7 @@ import logging import collections import copy import time +import warnings import ayon_api @@ -175,17 +176,22 @@ def get_project_environments(project_name, project_settings=None): def get_current_project_settings(): - """Project settings for current context project. + """DEPRECATE Project settings for current context project. + + Function requires access to pipeline context which is in + 'ayon_core.pipeline'. + + Returns: + dict[str, Any]: Project settings for current context project. - Project name should be stored in environment variable `AYON_PROJECT_NAME`. - This function should be used only in host context where environment - variable must be set and should not happen that any part of process will - change the value of the environment variable. """ - project_name = os.environ.get("AYON_PROJECT_NAME") - if not project_name: - raise ValueError( - "Missing context project in environment" - " variable `AYON_PROJECT_NAME`." - ) - return get_project_settings(project_name) + warnings.warn( + "Used deprecated function 'get_current_project_settings' in" + " 'ayon_core.settings'. The function was moved to" + " 'ayon_core.pipeline.context_tools'.", + DeprecationWarning, + stacklevel=2 + ) + from ayon_core.pipeline.context_tools import get_current_project_settings + + return get_current_project_settings() From 7f4f7be8b36b5a24ad63a58ba9a05036ef40e443 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:22:51 +0200 Subject: [PATCH 074/319] use anatomy if roots are not filled --- client/ayon_core/pipeline/load/utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/pipeline/load/utils.py b/client/ayon_core/pipeline/load/utils.py index 3c50d76fb5..836fc5e096 100644 --- a/client/ayon_core/pipeline/load/utils.py +++ b/client/ayon_core/pipeline/load/utils.py @@ -720,11 +720,13 @@ def get_representation_path(representation, root=None): str: fullpath of the representation """ - if root is None: - from ayon_core.pipeline import registered_root + from ayon_core.pipeline import get_current_project_name, Anatomy - root = registered_root() + anatomy = Anatomy(get_current_project_name()) + return get_representation_path_with_anatomy( + representation, anatomy + ) def path_from_representation(): try: @@ -772,7 +774,7 @@ def get_representation_path(representation, root=None): dir_path, file_name = os.path.split(path) if not os.path.exists(dir_path): - return + return None base_name, ext = os.path.splitext(file_name) file_name_items = None @@ -782,7 +784,7 @@ def get_representation_path(representation, root=None): file_name_items = base_name.split("%") if not file_name_items: - return + return None filename_start = file_name_items[0] From 97cd8a2ec960bbca158dad49c2522a2828011fc3 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:23:07 +0200 Subject: [PATCH 075/319] mark registered root as deprecated --- client/ayon_core/pipeline/context_tools.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 0877f2f049..89963a6205 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -69,7 +69,7 @@ def _get_addons_manager(): def register_root(path): - """Register currently active root""" + """DEPRECATED Register currently active root.""" log.info("Registering root: %s" % path) _registered_root["_"] = path @@ -88,8 +88,14 @@ def registered_root(): Returns: dict[str, str]: Root paths. - """ + """ + warnings.warn( + "Used deprecated function 'registered_root'. Please use 'Anatomy'" + " to get roots.", + DeprecationWarning, + stacklevel=2, + ) return _registered_root["_"] From 2d341f6e552c76604a31df60ac875a7dbd7ce1b1 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:23:26 +0200 Subject: [PATCH 076/319] use 'get_current_host_name' to get host name --- client/ayon_core/pipeline/context_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 89963a6205..2b4f9d45b8 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -183,7 +183,7 @@ def install_ayon_plugins(project_name=None, host_name=None): register_inventory_action_path(INVENTORY_PATH) if host_name is None: - host_name = os.environ.get("AYON_HOST_NAME") + host_name = get_current_host_name() addons_manager = _get_addons_manager() publish_plugin_dirs = addons_manager.collect_publish_plugin_paths( From 28eac4b18bc69ca4117d0cd6bdf6a9e2363d7e38 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:24:16 +0200 Subject: [PATCH 077/319] added HostBase validation --- client/ayon_core/pipeline/context_tools.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 2b4f9d45b8..e8a770ec54 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -99,13 +99,18 @@ def registered_root(): return _registered_root["_"] -def install_host(host): +def install_host(host: HostBase) -> None: """Install `host` into the running Python session. Args: host (HostBase): A host interface object. """ + if not isinstance(host, HostBase): + log.error( + f"Host must be a subclass of 'HostBase', got '{type(host)}'." + ) + global _is_installed _is_installed = True From ab60d611105a58901bdf8467a9d59ff34598ed13 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:24:31 +0200 Subject: [PATCH 078/319] mark 'version_up_current_workfile' as deprecated --- client/ayon_core/pipeline/context_tools.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index e8a770ec54..423e8f7216 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -1,5 +1,6 @@ """Core pipeline functionality""" from __future__ import annotations + import os import logging import platform @@ -575,6 +576,7 @@ def change_current_context( " It is not necessary to pass it in anymore." ), DeprecationWarning, + stacklevel=2, ) host = registered_host() @@ -603,6 +605,16 @@ def get_process_id(): def version_up_current_workfile(): - """Function to increment and save workfile""" + """DEPRECATED Function to increment and save workfile. + + Please use 'save_next_version' from 'ayon_core.pipeline.workfile' instead. + + """ + warnings.warn( + "Used deprecated 'version_up_current_workfile' please use" + " 'save_next_version' from 'ayon_core.pipeline.workfile' instead.", + DeprecationWarning, + stacklevel=2, + ) from ayon_core.pipeline.workfile import save_next_version save_next_version() From 32ea97af45bef30951c65e235f541cc2f2827e46 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 16:04:03 +0200 Subject: [PATCH 079/319] define settings category on core plugins --- client/ayon_core/plugins/publish/cleanup.py | 2 ++ client/ayon_core/plugins/publish/cleanup_farm.py | 2 ++ client/ayon_core/plugins/publish/collect_audio.py | 1 + client/ayon_core/plugins/publish/collect_frames_fix.py | 1 + client/ayon_core/plugins/publish/collect_scene_version.py | 3 ++- client/ayon_core/plugins/publish/extract_burnin.py | 1 + client/ayon_core/plugins/publish/extract_color_transcode.py | 2 ++ client/ayon_core/plugins/publish/extract_review.py | 1 + client/ayon_core/plugins/publish/extract_thumbnail.py | 1 + .../plugins/publish/extract_usd_layer_contributions.py | 6 +++++- client/ayon_core/plugins/publish/integrate_hero_version.py | 2 ++ client/ayon_core/plugins/publish/integrate_product_group.py | 2 ++ .../publish/preintegrate_thumbnail_representation.py | 2 ++ client/ayon_core/plugins/publish/validate_containers.py | 1 + client/ayon_core/plugins/publish/validate_intent.py | 2 ++ client/ayon_core/plugins/publish/validate_version.py | 1 + 16 files changed, 28 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/cleanup.py b/client/ayon_core/plugins/publish/cleanup.py index 681fe700a3..03eaaf9c6e 100644 --- a/client/ayon_core/plugins/publish/cleanup.py +++ b/client/ayon_core/plugins/publish/cleanup.py @@ -38,6 +38,8 @@ class CleanUp(pyblish.api.InstancePlugin): "webpublisher", "shell" ] + settings_category = "core" + exclude_families = ["clip"] optional = True active = True diff --git a/client/ayon_core/plugins/publish/cleanup_farm.py b/client/ayon_core/plugins/publish/cleanup_farm.py index e655437ced..8d1c8de425 100644 --- a/client/ayon_core/plugins/publish/cleanup_farm.py +++ b/client/ayon_core/plugins/publish/cleanup_farm.py @@ -13,6 +13,8 @@ class CleanUpFarm(pyblish.api.ContextPlugin): order = pyblish.api.IntegratorOrder + 11 label = "Clean Up Farm" + + settings_category = "core" enabled = True # Keep "filesequence" for backwards compatibility of older jobs diff --git a/client/ayon_core/plugins/publish/collect_audio.py b/client/ayon_core/plugins/publish/collect_audio.py index 57c69ef2b2..c0b263fa6f 100644 --- a/client/ayon_core/plugins/publish/collect_audio.py +++ b/client/ayon_core/plugins/publish/collect_audio.py @@ -41,6 +41,7 @@ class CollectAudio(pyblish.api.ContextPlugin): "max", "circuit", ] + settings_category = "core" audio_product_name = "audioMain" diff --git a/client/ayon_core/plugins/publish/collect_frames_fix.py b/client/ayon_core/plugins/publish/collect_frames_fix.py index 0f7d5b692a..4270af5541 100644 --- a/client/ayon_core/plugins/publish/collect_frames_fix.py +++ b/client/ayon_core/plugins/publish/collect_frames_fix.py @@ -23,6 +23,7 @@ class CollectFramesFixDef( targets = ["local"] hosts = ["nuke"] families = ["render", "prerender"] + settings_category = "core" rewrite_version_enable = False diff --git a/client/ayon_core/plugins/publish/collect_scene_version.py b/client/ayon_core/plugins/publish/collect_scene_version.py index 7979b66abe..e6e81ea074 100644 --- a/client/ayon_core/plugins/publish/collect_scene_version.py +++ b/client/ayon_core/plugins/publish/collect_scene_version.py @@ -12,9 +12,10 @@ class CollectSceneVersion(pyblish.api.ContextPlugin): """ order = pyblish.api.CollectorOrder - label = 'Collect Scene Version' + label = "Collect Scene Version" # configurable in Settings hosts = ["*"] + settings_category = "core" # in some cases of headless publishing (for example webpublisher using PS) # you want to ignore version from name and let integrate use next version diff --git a/client/ayon_core/plugins/publish/extract_burnin.py b/client/ayon_core/plugins/publish/extract_burnin.py index fa7fd4e504..f962032680 100644 --- a/client/ayon_core/plugins/publish/extract_burnin.py +++ b/client/ayon_core/plugins/publish/extract_burnin.py @@ -57,6 +57,7 @@ class ExtractBurnin(publish.Extractor): "unreal", "circuit", ] + settings_category = "core" optional = True diff --git a/client/ayon_core/plugins/publish/extract_color_transcode.py b/client/ayon_core/plugins/publish/extract_color_transcode.py index 8a276cf608..bbb6f9585b 100644 --- a/client/ayon_core/plugins/publish/extract_color_transcode.py +++ b/client/ayon_core/plugins/publish/extract_color_transcode.py @@ -55,6 +55,8 @@ class ExtractOIIOTranscode(publish.Extractor): label = "Transcode color spaces" order = pyblish.api.ExtractorOrder + 0.019 + settings_category = "core" + optional = True # Supported extensions diff --git a/client/ayon_core/plugins/publish/extract_review.py b/client/ayon_core/plugins/publish/extract_review.py index 1e4997cfb4..377010d9e0 100644 --- a/client/ayon_core/plugins/publish/extract_review.py +++ b/client/ayon_core/plugins/publish/extract_review.py @@ -165,6 +165,7 @@ class ExtractReview(pyblish.api.InstancePlugin): "photoshop" ] + settings_category = "core" # Supported extensions image_exts = {"exr", "jpg", "jpeg", "png", "dpx", "tga", "tiff", "tif"} video_exts = {"mov", "mp4"} diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 66acb15312..5d9f83fb42 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -43,6 +43,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): "houdini", "circuit", ] + settings_category = "core" enabled = False integrate_thumbnail = False diff --git a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py index ec1fddc6b1..c2fa61e1fe 100644 --- a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py +++ b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py @@ -255,7 +255,7 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin, order = pyblish.api.CollectorOrder + 0.35 label = "Collect USD Layer Contributions (Asset/Shot)" families = ["usd"] - enabled = True + settings_category = "core" # A contribution defines a contribution into a (department) layer which # will get layered into the target product, usually the asset or shot. @@ -633,6 +633,8 @@ class ExtractUSDLayerContribution(publish.Extractor): label = "Extract USD Layer Contributions (Asset/Shot)" order = pyblish.api.ExtractorOrder + 0.45 + settings_category = "core" + use_ayon_entity_uri = False def process(self, instance): @@ -795,6 +797,8 @@ class ExtractUSDAssetContribution(publish.Extractor): label = "Extract USD Asset/Shot Contributions" order = ExtractUSDLayerContribution.order + 0.01 + settings_category = "core" + use_ayon_entity_uri = False def process(self, instance): diff --git a/client/ayon_core/plugins/publish/integrate_hero_version.py b/client/ayon_core/plugins/publish/integrate_hero_version.py index 43f93da293..90e6f15568 100644 --- a/client/ayon_core/plugins/publish/integrate_hero_version.py +++ b/client/ayon_core/plugins/publish/integrate_hero_version.py @@ -61,6 +61,8 @@ class IntegrateHeroVersion( # Must happen after IntegrateNew order = pyblish.api.IntegratorOrder + 0.1 + settings_category = "core" + optional = True active = True diff --git a/client/ayon_core/plugins/publish/integrate_product_group.py b/client/ayon_core/plugins/publish/integrate_product_group.py index 90887a359d..8904d21d69 100644 --- a/client/ayon_core/plugins/publish/integrate_product_group.py +++ b/client/ayon_core/plugins/publish/integrate_product_group.py @@ -24,6 +24,8 @@ class IntegrateProductGroup(pyblish.api.InstancePlugin): order = pyblish.api.IntegratorOrder - 0.1 label = "Product Group" + settings_category = "core" + # Attributes set by settings product_grouping_profiles = None diff --git a/client/ayon_core/plugins/publish/preintegrate_thumbnail_representation.py b/client/ayon_core/plugins/publish/preintegrate_thumbnail_representation.py index 8bd67c0183..900febc236 100644 --- a/client/ayon_core/plugins/publish/preintegrate_thumbnail_representation.py +++ b/client/ayon_core/plugins/publish/preintegrate_thumbnail_representation.py @@ -22,6 +22,8 @@ class PreIntegrateThumbnails(pyblish.api.InstancePlugin): label = "Override Integrate Thumbnail Representations" order = pyblish.api.IntegratorOrder - 0.1 + settings_category = "core" + integrate_profiles = [] def process(self, instance): diff --git a/client/ayon_core/plugins/publish/validate_containers.py b/client/ayon_core/plugins/publish/validate_containers.py index 520e7a7ce9..fda3d93627 100644 --- a/client/ayon_core/plugins/publish/validate_containers.py +++ b/client/ayon_core/plugins/publish/validate_containers.py @@ -31,6 +31,7 @@ class ValidateOutdatedContainers( label = "Validate Outdated Containers" order = pyblish.api.ValidatorOrder + settings_category = "core" optional = True actions = [ShowInventory] diff --git a/client/ayon_core/plugins/publish/validate_intent.py b/client/ayon_core/plugins/publish/validate_intent.py index 71df652e92..fa5e5af093 100644 --- a/client/ayon_core/plugins/publish/validate_intent.py +++ b/client/ayon_core/plugins/publish/validate_intent.py @@ -14,6 +14,8 @@ class ValidateIntent(pyblish.api.ContextPlugin): order = pyblish.api.ValidatorOrder label = "Validate Intent" + settings_category = "core" + enabled = False # Can be modified by settings diff --git a/client/ayon_core/plugins/publish/validate_version.py b/client/ayon_core/plugins/publish/validate_version.py index 0359f8fb53..d63c4e1f03 100644 --- a/client/ayon_core/plugins/publish/validate_version.py +++ b/client/ayon_core/plugins/publish/validate_version.py @@ -17,6 +17,7 @@ class ValidateVersion(pyblish.api.InstancePlugin, OptionalPyblishPluginMixin): order = pyblish.api.ValidatorOrder label = "Validate Version" + settings_category = "core" optional = False active = True From 2e345fb297604b9bff86c8c124e50eb723b1b04e Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 16:35:59 +0200 Subject: [PATCH 080/319] warn if 'settings_category' is not filled but settings are received --- client/ayon_core/pipeline/publish/lib.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index fb84417730..cd6a7bca75 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -354,12 +354,17 @@ def get_plugin_settings(plugin, project_settings, log, category=None): # Use project settings based on a category name if category: try: - return ( + output = ( project_settings [category] ["publish"] [plugin.__name__] ) + warnings.warn( + f"Please fill 'settings_category' for plugin '{plugin.__name__}'.", + DeprecationWarning + ) + return output except KeyError: pass @@ -384,12 +389,17 @@ def get_plugin_settings(plugin, project_settings, log, category=None): category_from_file = "core" try: - return ( + output = ( project_settings [category_from_file] [plugin_kind] [plugin.__name__] ) + warnings.warn( + f"Please fill 'settings_category' for plugin '{plugin.__name__}'.", + DeprecationWarning + ) + return output except KeyError: pass return {} From 1bdd64ae3de81473796ed52ac3f59dde47fca55b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:03:17 +0200 Subject: [PATCH 081/319] allow path to python file --- client/ayon_core/pipeline/publish/lib.py | 37 +++++++++++++----------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index fb84417730..ddb1c46def 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -243,32 +243,35 @@ def publish_plugins_discover( for path in paths: path = os.path.normpath(path) - if not os.path.isdir(path): - continue + filenames = [] + if os.path.isdir(path): + filenames.extend( + name + for name in os.listdir(path) + if ( + os.path.isfile(os.path.join(path, name)) + and not name.startswith("_") + ) + ) + else: + filenames.append(os.path.basename(path)) + path = os.path.dirname(path) - for fname in os.listdir(path): - if fname.startswith("_"): - continue - - abspath = os.path.join(path, fname) - - if not os.path.isfile(abspath): - continue - - mod_name, mod_ext = os.path.splitext(fname) - - if mod_ext != ".py": + for filename in filenames: + mod_name, mod_ext = os.path.splitext(filename) + if mod_ext.lower() != ".py": continue + filepath = os.path.join(path, filename) try: module = import_filepath( - abspath, mod_name, sys_module_name=mod_name) + filepath, mod_name, sys_module_name=mod_name except Exception as err: # noqa: BLE001 # we need broad exception to catch all possible errors. - result.crashed_file_paths[abspath] = sys.exc_info() + result.crashed_file_paths[filepath] = sys.exc_info() - log.debug('Skipped: "%s" (%s)', mod_name, err) + log.debug('Skipped: "%s" (%s)', filepath, err) continue for plugin in pyblish.plugin.plugins_from_module(module): From c398e1fca35c5c379acb53b1c47bce8a493affb9 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:03:37 +0200 Subject: [PATCH 082/319] hash dirpath for sys modules --- client/ayon_core/pipeline/publish/lib.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index ddb1c46def..c0b138c7f2 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -5,6 +5,7 @@ import sys import inspect import copy import warnings +import hashlib import xml.etree.ElementTree from typing import TYPE_CHECKING, Optional, Union, List @@ -257,15 +258,18 @@ def publish_plugins_discover( filenames.append(os.path.basename(path)) path = os.path.dirname(path) + dirpath_hash = hashlib.md5(path.encode("utf-8")).hexdigest() for filename in filenames: mod_name, mod_ext = os.path.splitext(filename) if mod_ext.lower() != ".py": continue filepath = os.path.join(path, filename) + sys_module_name = f"{dirpath_hash}.{mod_name}" try: module = import_filepath( - filepath, mod_name, sys_module_name=mod_name + filepath, mod_name, sys_module_name=sys_module_name + ) except Exception as err: # noqa: BLE001 # we need broad exception to catch all possible errors. From cdb719494ef86728f22440e137320e2aa91c6216 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:19:26 +0200 Subject: [PATCH 083/319] use same name for both sys module and module --- client/ayon_core/pipeline/publish/lib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index c0b138c7f2..d360526024 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -260,15 +260,15 @@ def publish_plugins_discover( dirpath_hash = hashlib.md5(path.encode("utf-8")).hexdigest() for filename in filenames: - mod_name, mod_ext = os.path.splitext(filename) - if mod_ext.lower() != ".py": + basename, ext = os.path.splitext(filename) + if ext.lower() != ".py": continue filepath = os.path.join(path, filename) - sys_module_name = f"{dirpath_hash}.{mod_name}" + module_name = f"{dirpath_hash}.{basename}" try: module = import_filepath( - filepath, mod_name, sys_module_name=sys_module_name + filepath, module_name, sys_module_name=module_name ) except Exception as err: # noqa: BLE001 From feece4a7c30f32603c58d11d201aa73d494ed040 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:29:12 +0200 Subject: [PATCH 084/319] fix line length --- client/ayon_core/pipeline/publish/lib.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index cd6a7bca75..dfaba0e7a9 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -361,7 +361,8 @@ def get_plugin_settings(plugin, project_settings, log, category=None): [plugin.__name__] ) warnings.warn( - f"Please fill 'settings_category' for plugin '{plugin.__name__}'.", + "Please fill 'settings_category'" + f" for plugin '{plugin.__name__}'.", DeprecationWarning ) return output @@ -396,7 +397,8 @@ def get_plugin_settings(plugin, project_settings, log, category=None): [plugin.__name__] ) warnings.warn( - f"Please fill 'settings_category' for plugin '{plugin.__name__}'.", + "Please fill 'settings_category'" + f" for plugin '{plugin.__name__}'.", DeprecationWarning ) return output From 4e39e86037d878eed6e5359f1891587b5d909ec5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 10:28:29 +0200 Subject: [PATCH 085/319] Add 'enabled' attribute back --- .../ayon_core/plugins/publish/extract_usd_layer_contributions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py index c2fa61e1fe..0dc9a5e34d 100644 --- a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py +++ b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py @@ -255,6 +255,7 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin, order = pyblish.api.CollectorOrder + 0.35 label = "Collect USD Layer Contributions (Asset/Shot)" families = ["usd"] + enabled = True settings_category = "core" # A contribution defines a contribution into a (department) layer which From 8553e44e13f83a4f1ba61d5f9d3c56c9463fb355 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 11:48:22 +0200 Subject: [PATCH 086/319] added share active flag --- client/ayon_core/pipeline/create/context.py | 1 + .../ayon_core/pipeline/create/structures.py | 5 +++ .../publish/collect_from_create_context.py | 45 +++++++++++-------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index 1cf8f08eff..383247ecb4 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -2087,6 +2087,7 @@ class CreateContext: } _queue = collections.deque() _queue.extend(instances_to_remove) + # Add children with parent lifetime flag while _queue: instance = _queue.popleft() ids_to_remove.add(instance.id) diff --git a/client/ayon_core/pipeline/create/structures.py b/client/ayon_core/pipeline/create/structures.py index 562a3a581d..b2be377b42 100644 --- a/client/ayon_core/pipeline/create/structures.py +++ b/client/ayon_core/pipeline/create/structures.py @@ -33,6 +33,11 @@ class IntEnum(int, Enum): class ParentFlags(IntEnum): # Delete instance if parent is deleted parent_lifetime = 1 + # Active state is propagated from parent to children + # - the active state is propagated in collection phase + # NOTE It might be helpful to have a function that would return "real" + # active state for instances + share_active = 1 << 1 class ConvertorItem: diff --git a/client/ayon_core/plugins/publish/collect_from_create_context.py b/client/ayon_core/plugins/publish/collect_from_create_context.py index 8383dfaa96..7b8aeee457 100644 --- a/client/ayon_core/plugins/publish/collect_from_create_context.py +++ b/client/ayon_core/plugins/publish/collect_from_create_context.py @@ -8,7 +8,7 @@ import pyblish.api from ayon_core.host import IPublishHost from ayon_core.pipeline import registered_host -from ayon_core.pipeline.create import CreateContext +from ayon_core.pipeline.create import CreateContext, ParentFlags class CollectFromCreateContext(pyblish.api.ContextPlugin): @@ -38,30 +38,39 @@ class CollectFromCreateContext(pyblish.api.ContextPlugin): if project_name: context.data["projectName"] = project_name - # Filter active instances and skip instances which have disabled - # parent instance + # Separate root instances and parented instances instances_by_parent_id = collections.defaultdict(list) - filtered_instances = [] + root_instances = [] for created_instance in create_context.instances: - if not created_instance["active"]: - continue parent_id = created_instance.parent_instance_id if parent_id is None: - filtered_instances.append(created_instance) + root_instances.append(created_instance) else: instances_by_parent_id[parent_id].append(created_instance) - parent_ids_queue = collections.deque() - parent_ids_queue.extend( - instance.id for instance in filtered_instances - ) - while parent_ids_queue: - parent_id = parent_ids_queue.popleft() - children = instances_by_parent_id[parent_id] - if not children: - continue - filtered_instances.extend(children) - parent_ids_queue.extend(instance.id for instance in children) + # Traverse instances from top to bottom + # - All instances without an existing parent are automatically + # eliminated + filtered_instances = [] + _queue = collections.deque() + _queue.append((root_instances, True)) + while _queue: + created_instances, parent_is_active = _queue.popleft() + for created_instance in created_instances: + is_active = created_instance["active"] + # Use a parent's active state if parent flags defines that + if ( + is_active + and created_instance.parent_flags & ParentFlags.share_active + ): + is_active = parent_is_active + + if is_active: + filtered_instances.append(created_instance) + + children = instances_by_parent_id[created_instance.id] + if children: + _queue.append((children, is_active)) for created_instance in filtered_instances: instance_data = created_instance.data_to_store() From fd26c2039495b3f83bf8c3c08de2edc5b449c257 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 28 Jul 2025 15:00:44 +0200 Subject: [PATCH 087/319] Fix typo --- client/ayon_core/tools/push_to_project/models/integrate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 20fa5c98e5..341858148b 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -1148,7 +1148,6 @@ class ProjectPushItemProcess: repre_entity["id"], {"active": False} ) - ) def _copy_version_thumbnail(self): version_thumbnail = ayon_api.get_version_thumbnail( From bcf87dec1060d1dfef2e8d4249f4ebee698829ba Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 28 Jul 2025 15:01:12 +0200 Subject: [PATCH 088/319] Removed unnecessary _library_only --- client/ayon_core/tools/push_to_project/control.py | 8 -------- client/ayon_core/tools/push_to_project/ui/window.py | 6 ++---- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index f24d11d0b7..eb985a3f8c 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -130,14 +130,6 @@ class PushToContextController: self._src_label = self._prepare_source_label() return self._src_label - def get_library_only(self): - """Returns state of library filter""" - return self._library_only - - def set_library_only(self, state: bool): - """Change state of library filter""" - self._library_only = state - def get_project_items(self, sender=None): return self._projects_model.get_project_items(sender) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 49093b8a00..6b0363adee 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -85,13 +85,12 @@ class PushToContextSelectWindow(QtWidgets.QWidget): header_widget = QtWidgets.QWidget(main_context_widget) - library_only = self._controller.get_library_only() library_only_label = QtWidgets.QLabel( "Show only libraries", header_widget ) library_only_checkbox = NiceCheckbox( - library_only, parent=header_widget) + True, parent=header_widget) header_label = QtWidgets.QLabel( controller.get_source_label(), @@ -113,7 +112,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): projects_combobox = ProjectsCombobox(controller, context_widget) projects_combobox.set_select_item_visible(True) - projects_combobox.set_standard_filter_enabled(library_only) + projects_combobox.set_standard_filter_enabled(True) context_splitter = QtWidgets.QSplitter( QtCore.Qt.Vertical, context_widget @@ -409,7 +408,6 @@ class PushToContextSelectWindow(QtWidgets.QWidget): def _on_library_only_change(self, state: int) -> None: """Change toggle state, reset filter, recalculate dropdown""" state = bool(state) - self._controller.set_library_only(state) self._projects_combobox.set_standard_filter_enabled(state) self._projects_combobox.refresh() From e80ba294fb5b184ccb4bf349b23bbb0f551cbd34 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:21:35 +0200 Subject: [PATCH 089/319] added parent changes callback --- client/ayon_core/pipeline/create/context.py | 29 +++++++++++++++++++ .../tools/publisher/models/create.py | 13 +++++++++ 2 files changed, 42 insertions(+) diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index 383247ecb4..5e069cd62e 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -1091,6 +1091,35 @@ class CreateContext: INSTANCE_REQUIREMENT_CHANGED_TOPIC, callback ) + def add_instance_parent_change_callback( + self, callback: Callable + ) -> "EventCallback": + """Register callback to listen to instance parent changes. + + Instance changed parent or parent flags. + + Data structure of event: + + ```python + { + "instances": [CreatedInstance, ...], + "create_context": CreateContext + } + ``` + + Args: + callback (Callable): Callback function that will be called when + instance requirement changed. + + Returns: + EventCallback: Created callback object which can be used to + stop listening. + + """ + return self._event_hub.add_callback( + INSTANCE_PARENT_CHANGED_TOPIC, callback + ) + def context_data_to_store(self) -> dict[str, Any]: """Data that should be stored by host function. diff --git a/client/ayon_core/tools/publisher/models/create.py b/client/ayon_core/tools/publisher/models/create.py index 058077aadd..15addd06b8 100644 --- a/client/ayon_core/tools/publisher/models/create.py +++ b/client/ayon_core/tools/publisher/models/create.py @@ -493,6 +493,9 @@ class CreateModel: self._create_context.add_instance_requirement_change_callback( self._cc_instance_requirement_changed ) + self._create_context.add_instance_parent_change_callback( + self._cc_instance_parent_changed + ) self._create_context.reset_finalization() @@ -1198,6 +1201,16 @@ class CreateModel: {"instance_ids": instance_ids}, ) + def _cc_instance_parent_changed(self, event): + instance_ids = { + instance.id + for instance in event.data["instances"] + } + self._emit_event( + "create.model.instance.parent.changed", + {"instance_ids": instance_ids}, + ) + def _get_allowed_creators_pattern(self) -> Union[Pattern, None]: """Provide regex pattern for configured creator labels in this context From 9ad1a5e830993401f1653adb38866e4ab318b014 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:21:52 +0200 Subject: [PATCH 090/319] added parent flags to UI --- client/ayon_core/tools/publisher/models/create.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/ayon_core/tools/publisher/models/create.py b/client/ayon_core/tools/publisher/models/create.py index 15addd06b8..0b0d287448 100644 --- a/client/ayon_core/tools/publisher/models/create.py +++ b/client/ayon_core/tools/publisher/models/create.py @@ -220,6 +220,7 @@ class InstanceItem: is_mandatory: bool, has_promised_context: bool, parent_instance_id: Optional[str], + parent_flags: int, ): self._instance_id: str = instance_id self._creator_identifier: str = creator_identifier @@ -234,6 +235,7 @@ class InstanceItem: self._is_mandatory: bool = is_mandatory self._has_promised_context: bool = has_promised_context self._parent_instance_id: Optional[str] = parent_instance_id + self._parent_flags: int = parent_flags @property def id(self): @@ -267,6 +269,10 @@ class InstanceItem: def parent_instance_id(self): return self._parent_instance_id + @property + def parent_flags(self) -> int: + return self._parent_flags + def get_variant(self): return self._variant @@ -319,6 +325,7 @@ class InstanceItem: instance.is_mandatory, instance.has_promised_context, instance.parent_instance_id, + instance.parent_flags, ) From 3e0705aad8b831ccbc62ee484cacf2de3a4fb8f4 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:31:20 +0200 Subject: [PATCH 091/319] handle add parent flags handling --- .../publisher/widgets/list_view_widgets.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 65bc531d27..21762eed64 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -35,6 +35,7 @@ from ayon_core.tools.utils.lib import html_escape, checkstate_int_to_enum from ayon_core.pipeline.create import ( InstanceContextInfo, + ParentFlags, ) from ayon_core.tools.publisher.abstract import AbstractPublisherFrontend @@ -170,6 +171,7 @@ class InstanceListItemWidget(QtWidgets.QWidget): self._has_valid_context = context_info.is_valid self._is_mandatory = instance.is_mandatory self._instance_is_active = instance.is_active + self._parent_flags = instance.parent_flags # Parent active state is fluent and can change self._parent_is_active = parent_is_active @@ -238,10 +240,20 @@ class InstanceListItemWidget(QtWidgets.QWidget): self._instance_is_active = instance.is_active self._has_valid_context = context_info.is_valid self._parent_is_active = parent_is_active + self._parent_flags = instance.parent_flags self._update_checkbox_state() self._update_style_state() + def is_parent_active(self) -> bool: + return self._parent_is_active + + def _used_parent_active(self): + parent_enabled = True + if self._parent_flags & ParentFlags.share_active: + parent_enabled = self._parent_is_active + return parent_enabled + def set_parent_is_active(self, active: bool) -> None: if self._parent_is_active is active: return @@ -259,7 +271,7 @@ class InstanceListItemWidget(QtWidgets.QWidget): def _update_style_state(self) -> None: state = "" - if not self._parent_is_active: + if not self._used_parent_active(): state = "disabled" elif not self._has_valid_context: state = "invalid" @@ -271,16 +283,18 @@ class InstanceListItemWidget(QtWidgets.QWidget): self._instance_label_widget.style().polish(self._instance_label_widget) def _update_checkbox_state(self) -> None: + parent_enabled = self._used_parent_active() + self._active_checkbox.setEnabled( self._toggle_is_enabled and not self._is_mandatory - and self._parent_is_active + and parent_enabled ) # Hide checkbox for mandatory instances self._active_checkbox.setVisible(not self._is_mandatory) # Visually disable instance if parent is disabled - checked = self._parent_is_active and self._instance_is_active + checked = parent_enabled and self._instance_is_active if checked is not self._active_checkbox.isChecked(): self._active_checkbox.setChecked(checked) From 205277f05242d390e885c2a6603010cdac7582df Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:31:33 +0200 Subject: [PATCH 092/319] listen to parent changes --- .../ayon_core/tools/publisher/widgets/overview_widget.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/ayon_core/tools/publisher/widgets/overview_widget.py b/client/ayon_core/tools/publisher/widgets/overview_widget.py index 46395328e0..d78b143ce6 100644 --- a/client/ayon_core/tools/publisher/widgets/overview_widget.py +++ b/client/ayon_core/tools/publisher/widgets/overview_widget.py @@ -159,6 +159,10 @@ class OverviewWidget(QtWidgets.QFrame): "create.model.instance.requirement.changed", self._on_instance_requirement_changed ) + controller.register_event_callback( + "create.model.instance.parent.changed", + self._on_instance_parent_changed + ) self._product_content_widget = product_content_widget self._product_content_layout = product_content_layout @@ -361,6 +365,9 @@ class OverviewWidget(QtWidgets.QFrame): def _on_instance_requirement_changed(self, event): self._refresh_instance_states(event["instance_ids"]) + def _on_instance_parent_changed(self, event): + self._refresh_instance_states(event["instance_ids"]) + def _refresh_instance_states(self, instance_ids): current_idx = self._product_views_layout.currentIndex() for idx in range(self._product_views_layout.count()): From 6c12e1973d352a309599a89d070a6ffadd8e7f59 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:37:14 +0200 Subject: [PATCH 093/319] take all children from missing parent item --- .../tools/publisher/widgets/list_view_widgets.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 21762eed64..c7203351de 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -998,6 +998,16 @@ class InstanceListView(AbstractInstanceView): widget.setVisible(False) widget.deleteLater() parent.takeRow(self._missing_parent_item.row()) + _queue = collections.deque() + _queue.append(self._missing_parent_item) + while _queue: + item = _queue.popleft() + for _ in range(item.rowCount()): + child = item.child(0) + _queue.append(child) + item.takeRow(0) + + self._missing_parent_item = None def refresh_instance_states(self, instance_ids=None): """Trigger update of all instances.""" From 42a2c2da5992c94cd576b41003f5f06af3b6dc0b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:37:30 +0200 Subject: [PATCH 094/319] fix parenting changes propagation --- .../publisher/widgets/list_view_widgets.py | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index c7203351de..798e382fcf 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -659,7 +659,8 @@ class InstanceListView(AbstractInstanceView): item.setData(instance_id, INSTANCE_ID_ROLE) self._items_by_id[instance_id] = item new_items[parent_id].append(item) - elif parent_id != self._parent_id_by_id.get(instance_id): + + elif item.parent() is not parent_item: new_items[parent_id].append(item) self._parent_id_by_id[instance_id] = parent_id @@ -1037,6 +1038,7 @@ class InstanceListView(AbstractInstanceView): ] _queue.append((children, True)) + discarted_ids = set() while _queue: if not instance_ids: break @@ -1045,15 +1047,20 @@ class InstanceListView(AbstractInstanceView): for child in children: instance_id = child.data(INSTANCE_ID_ROLE) widget = self._widgets_by_id[instance_id] + # Add children ids to 'instance_ids' to traverse them too + add_children = False if instance_id in instance_ids: instance_ids.discard(instance_id) + discarted_ids.add(instance_id) + # Parent active state changed -> traverse children too + add_children = ( + parent_active is not widget.is_parent_active() + ) widget.update_instance( instance_items_by_id[instance_id], context_info_by_id[instance_id], parent_active, ) - if not instance_ids: - break if not child.hasChildren(): continue @@ -1062,6 +1069,15 @@ class InstanceListView(AbstractInstanceView): child.child(row) for row in range(child.rowCount()) ] + if add_children: + for new_child in children: + instance_id = new_child.data(INSTANCE_ID_ROLE) + if instance_id not in discarted_ids: + instance_ids.add(instance_id) + + if not instance_ids: + break + _queue.append((children, widget.is_active())) def _on_active_changed(self, changed_instance_id, new_value): From ed6fd25a0409ab255ccbb1819b2b08f070be7339 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:45:56 +0200 Subject: [PATCH 095/319] re-order imports --- client/ayon_core/tools/publisher/widgets/list_view_widgets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 798e382fcf..4dc7bf1322 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -30,14 +30,14 @@ from typing import Optional from qtpy import QtWidgets, QtCore, QtGui from ayon_core.style import get_objected_colors -from ayon_core.tools.utils import NiceCheckbox, BaseClickableFrame -from ayon_core.tools.utils.lib import html_escape, checkstate_int_to_enum from ayon_core.pipeline.create import ( InstanceContextInfo, ParentFlags, ) +from ayon_core.tools.utils import NiceCheckbox, BaseClickableFrame +from ayon_core.tools.utils.lib import html_escape, checkstate_int_to_enum from ayon_core.tools.publisher.abstract import AbstractPublisherFrontend from ayon_core.tools.publisher.models.create import ( InstanceItem, From bfc82a07fd58914933f7d1757dc48f3a6e1601c8 Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Mon, 28 Jul 2025 11:30:57 -0400 Subject: [PATCH 096/319] Detect rounding issues in media available_range when extracting (OTIO). --- client/ayon_core/pipeline/editorial.py | 4 ++ .../publish/extract_otio_audio_tracks.py | 9 +++++ .../plugins/publish/extract_otio_review.py | 39 +++++++++++++++---- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/client/ayon_core/pipeline/editorial.py b/client/ayon_core/pipeline/editorial.py index 8b6cfc52f1..b553fae3fb 100644 --- a/client/ayon_core/pipeline/editorial.py +++ b/client/ayon_core/pipeline/editorial.py @@ -7,6 +7,10 @@ import opentimelineio as otio from opentimelineio import opentime as _ot +# https://github.com/AcademySoftwareFoundation/OpenTimelineIO/issues/1822 +OTIO_EPSILON = 1e-9 + + def otio_range_to_frame_range(otio_range): start = _ot.to_frames( otio_range.start_time, otio_range.start_time.rate) diff --git a/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py b/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py index 472694d334..2aec4a5415 100644 --- a/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py +++ b/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py @@ -7,6 +7,7 @@ from ayon_core.lib import ( get_ffmpeg_tool_args, run_subprocess ) +from ayon_core.pipeline import editorial class ExtractOtioAudioTracks(pyblish.api.ContextPlugin): @@ -172,6 +173,14 @@ class ExtractOtioAudioTracks(pyblish.api.ContextPlugin): clip_start = otio_clip.source_range.start_time fps = clip_start.rate conformed_av_start = media_av_start.rescaled_to(fps) + + # Avoid rounding issue on media available range. + if clip_start.almost_equal( + conformed_av_start, + editorial.OTIO_EPSILON + ): + conformed_av_start = clip_start + # ffmpeg ignores embedded tc start = clip_start - conformed_av_start duration = otio_clip.source_range.duration diff --git a/client/ayon_core/plugins/publish/extract_otio_review.py b/client/ayon_core/plugins/publish/extract_otio_review.py index f217be551c..74cf45e474 100644 --- a/client/ayon_core/plugins/publish/extract_otio_review.py +++ b/client/ayon_core/plugins/publish/extract_otio_review.py @@ -23,7 +23,11 @@ from ayon_core.lib import ( get_ffmpeg_tool_args, run_subprocess, ) -from ayon_core.pipeline import publish +from ayon_core.pipeline import ( + KnownPublishError, + editorial, + publish, +) class ExtractOTIOReview( @@ -97,8 +101,11 @@ class ExtractOTIOReview( # skip instance if no reviewable data available if ( - not isinstance(otio_review_clips[0], otio.schema.Clip) - and len(otio_review_clips) == 1 + len(otio_review_clips) == 1 + and ( + not isinstance(otio_review_clips[0], otio.schema.Clip) + or otio_review_clips[0].media_reference.is_missing_reference + ) ): self.log.warning( "Instance `{}` has nothing to process".format(instance)) @@ -248,7 +255,7 @@ class ExtractOTIOReview( # Single video way. # Extraction via FFmpeg. - else: + elif hasattr(media_ref, "target_url"): path = media_ref.target_url # Set extract range from 0 (FFmpeg ignores # embedded timecode). @@ -370,6 +377,13 @@ class ExtractOTIOReview( avl_start = avl_range.start_time + # Avoid rounding issue on media available range. + if start.almost_equal( + avl_start, + editorial.OTIO_EPSILON + ): + avl_start = start + # An additional gap is required before the available # range to conform source start point and head handles. if start < avl_start: @@ -388,6 +402,14 @@ class ExtractOTIOReview( # (media duration is shorter then clip requirement). end_point = start + duration avl_end_point = avl_range.end_time_exclusive() + + # Avoid rounding issue on media available range. + if end_point.almost_equal( + avl_end_point, + editorial.OTIO_EPSILON + ): + avl_end_point = end_point + if end_point > avl_end_point: gap_duration = end_point - avl_end_point duration -= gap_duration @@ -444,7 +466,7 @@ class ExtractOTIOReview( command = get_ffmpeg_tool_args("ffmpeg") input_extension = None - if sequence: + if sequence is not None: input_dir, collection, sequence_fps = sequence in_frame_start = min(collection.indexes) @@ -478,7 +500,7 @@ class ExtractOTIOReview( "-i", input_path ]) - elif video: + elif video is not None: video_path, otio_range = video frame_start = otio_range.start_time.value input_fps = otio_range.start_time.rate @@ -496,7 +518,7 @@ class ExtractOTIOReview( "-i", video_path ]) - elif gap: + elif gap is not None: sec_duration = frames_to_seconds(gap, self.actual_fps) # form command for rendering gap files @@ -510,6 +532,9 @@ class ExtractOTIOReview( "-tune", "stillimage" ]) + else: + raise KnownPublishError("Sequence, video or gap is required.") + if video or sequence: command.extend([ "-vf", f"scale={self.to_width}:{self.to_height}:flags=lanczos", From 1ef49e4d08f157860f1b673b5f16683cdf1f7e5b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:37:37 +0200 Subject: [PATCH 097/319] fix 'is_checkbox_enabled' --- client/ayon_core/tools/publisher/widgets/list_view_widgets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 4dc7bf1322..f0fb5dcf82 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -196,7 +196,7 @@ class InstanceListItemWidget(QtWidgets.QWidget): def is_checkbox_enabled(self) -> bool: """Checkbox can be changed by user.""" return ( - self._parent_is_active + self._used_parent_active() and not self._is_mandatory ) @@ -248,7 +248,7 @@ class InstanceListItemWidget(QtWidgets.QWidget): def is_parent_active(self) -> bool: return self._parent_is_active - def _used_parent_active(self): + def _used_parent_active(self) -> bool: parent_enabled = True if self._parent_flags & ParentFlags.share_active: parent_enabled = self._parent_is_active From 7df97e5503c66d766961e841092a820d032c667f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:39:55 +0200 Subject: [PATCH 098/319] base of card widget implementation --- .../publisher/widgets/card_view_widgets.py | 180 ++++++++++++++---- 1 file changed, 148 insertions(+), 32 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 8a4eddf058..1a2855888a 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -19,6 +19,7 @@ Only one item can be selected at a time. └──────────────────────┘ ``` """ +from __future__ import annotations import re import collections @@ -26,11 +27,13 @@ from typing import Dict from qtpy import QtWidgets, QtCore -from ayon_core.tools.utils import NiceCheckbox +from ayon_core.pipeline.create import ( + InstanceContextInfo, + ParentFlags, +) -from ayon_core.tools.utils import BaseClickableFrame +from ayon_core.tools.utils import BaseClickableFrame, NiceCheckbox from ayon_core.tools.utils.lib import html_escape - from ayon_core.tools.publisher.abstract import AbstractPublisherFrontend from ayon_core.tools.publisher.constants import ( CONTEXT_ID, @@ -38,7 +41,9 @@ from ayon_core.tools.publisher.constants import ( CONTEXT_GROUP, CONVERTOR_ITEM_GROUP, ) - +from ayon_core.tools.publisher.models.create import ( + InstanceItem, +) from .widgets import ( AbstractInstanceView, ContextWarningLabel, @@ -219,7 +224,11 @@ class InstanceGroupWidget(BaseGroupWidget): self._group_icons = group_icons def update_instance_values( - self, context_info_by_id, instance_items_by_id, instance_ids + self, + context_info_by_id, + instance_items_by_id, + instance_ids, + parent_is_active_by_id, ): """Trigger update on instance widgets.""" @@ -228,17 +237,24 @@ class InstanceGroupWidget(BaseGroupWidget): continue widget.update_instance( instance_items_by_id[instance_id], - context_info_by_id[instance_id] + context_info_by_id[instance_id], + parent_is_active_by_id[instance_id], ) - def update_instances(self, instances, context_info_by_id): + def update_instances( + self, + instances: list[InstanceItem], + context_info_by_id: dict[str, InstanceContextInfo], + parent_active_by_id: dict[str, bool] + ): """Update instances for the group. Args: instances (list[InstanceItem]): List of instances in CreateContext. - context_info_by_id (Dict[str, InstanceContextInfo]): Instance + context_info_by_id (dict[str, InstanceContextInfo]): Instance context info by instance id. + parent_active_by_id (dict[str, bool]): Instance has active parent. """ # Store instances by id and by product name @@ -260,13 +276,20 @@ class InstanceGroupWidget(BaseGroupWidget): for product_names in sorted_product_names: for instance in instances_by_product_name[product_names]: context_info = context_info_by_id[instance.id] + parent_is_active = parent_active_by_id[instance.id] if instance.id in self._widgets_by_id: widget = self._widgets_by_id[instance.id] - widget.update_instance(instance, context_info) + widget.update_instance( + instance, context_info, parent_is_active + ) else: group_icon = self._group_icons[instance.creator_identifier] widget = InstanceCardWidget( - instance, context_info, group_icon, self + instance, + context_info, + parent_is_active, + group_icon, + self ) widget.selected.connect(self._on_widget_selection) widget.active_changed.connect(self._on_active_changed) @@ -406,14 +429,23 @@ class InstanceCardWidget(CardWidget): active_changed = QtCore.Signal(str, bool) - def __init__(self, instance, context_info, group_icon, parent): + def __init__( + self, + instance, + context_info, + parent_is_active: bool, + group_icon, + parent: BaseGroupWidget, + ): super().__init__(parent) + self.instance = instance + self._id = instance.id self._group_identifier = instance.group_label self._group_icon = group_icon - - self.instance = instance + self._parent_is_active = parent_is_active + self._toggle_is_enabled = True self._last_product_name = None self._last_variant = None @@ -467,28 +499,29 @@ class InstanceCardWidget(CardWidget): self._active_checkbox = active_checkbox self._expand_btn = expand_btn - self._update_instance_values(context_info) + self._update_instance_values(context_info, parent_is_active) def set_active_toggle_enabled(self, enabled): - self._active_checkbox.setEnabled(enabled) + if self._toggle_is_enabled is enabled: + return + self._toggle_is_enabled = enabled + self._update_checkbox_state() @property def is_active(self): return self._active_checkbox.isChecked() - def _set_active(self, new_value): - """Set instance as active.""" - checkbox_value = self._active_checkbox.isChecked() - if checkbox_value != new_value: - self._active_checkbox.setChecked(new_value) + def is_checkbox_enabled(self) -> bool: + """Checkbox can be changed by user.""" + return ( + self._used_parent_active() + and not self.instance.is_mandatory + ) - def _set_is_mandatory(self, is_mandatory: bool) -> None: - self._active_checkbox.setVisible(not is_mandatory) - - def update_instance(self, instance, context_info): + def update_instance(self, instance, context_info, parent_is_active): """Update instance object and update UI.""" self.instance = instance - self._update_instance_values(context_info) + self._update_instance_values(context_info, parent_is_active) def _validate_context(self, context_info): valid = context_info.is_valid @@ -499,6 +532,9 @@ class InstanceCardWidget(CardWidget): variant = self.instance.variant product_name = self.instance.product_name label = self.instance.label + + parent_is_enabled = self._used_parent_active() + self._label_widget.setEnabled(parent_is_enabled) if ( variant == self._last_variant and product_name == self._last_product_name @@ -524,13 +560,36 @@ class InstanceCardWidget(CardWidget): QtCore.Qt.NoTextInteraction ) - def _update_instance_values(self, context_info): + def _update_instance_values(self, context_info, parent_is_active): """Update instance data""" + self._parent_is_active = parent_is_active self._update_product_name() - self._set_active(self.instance.is_active) - self._set_is_mandatory(self.instance.is_mandatory) + self._update_checkbox_state() self._validate_context(context_info) + def _update_checkbox_state(self): + parent_is_enabled = self._used_parent_active() + self._active_checkbox.setEnabled( + self._toggle_is_enabled + and not self.instance.is_mandatory + and parent_is_enabled + ) + # Hide checkbox for mandatory instances + self._active_checkbox.setVisible(not self.instance.is_mandatory) + + # Visually disable instance if parent is disabled + checked = parent_is_enabled and self.instance.is_active + if checked is not self._active_checkbox.isChecked(): + self._active_checkbox.blockSignals(True) + self._active_checkbox.setChecked(checked) + self._active_checkbox.blockSignals(False) + + def _used_parent_active(self) -> bool: + parent_enabled = True + if self.instance.parent_flags & ParentFlags.share_active: + parent_enabled = self._parent_is_active + return parent_enabled + def _set_expanded(self, expanded=None): if expanded is None: expanded = not self.detail_widget.isVisible() @@ -601,6 +660,8 @@ class InstanceCardView(AbstractInstanceView): self._widgets_by_group: Dict[str, InstanceGroupWidget] = {} self._ordered_groups = [] + self._instance_ids_by_parent_id = collections.defaultdict(set) + self._explicitly_selected_instance_ids = [] self._explicitly_selected_groups = [] @@ -705,12 +766,43 @@ class InstanceCardView(AbstractInstanceView): # Prepare instances by group and identifiers by group instances_by_group = collections.defaultdict(list) identifiers_by_group = collections.defaultdict(set) - for instance in self._controller.get_instance_items(): + instances_by_id = {} + instance_ids_by_parent_id = collections.defaultdict(set) + instance_items = self._controller.get_instance_items() + for instance in instance_items: group_name = instance.group_label instances_by_group[group_name].append(instance) identifiers_by_group[group_name].add( instance.creator_identifier ) + instances_by_id[instance.id] = instance + instance_ids_by_parent_id[instance.parent_instance_id].add( + instance.id + ) + + parent_active_by_id = { + instance_id: False + for instance_id in instances_by_id + } + _queue = collections.deque() + _queue.append((None, True)) + while _queue: + parent_id, parent_is_active = _queue.popleft() + for instance_id in instance_ids_by_parent_id[parent_id]: + instance_item = instances_by_id[instance_id] + is_active = instance_item.is_active + if ( + not parent_is_active + and instance_item.parent_flags & ParentFlags.share_active + ): + is_active = False + + parent_active_by_id[instance_id] = parent_is_active + _queue.append( + (instance_id, is_active) + ) + + self._instance_ids_by_parent_id = instance_ids_by_parent_id # Remove groups that were not found in apassed instances for group_name in tuple(self._widgets_by_group.keys()): @@ -755,7 +847,9 @@ class InstanceCardView(AbstractInstanceView): widget_idx += 1 group_widget.update_instances( - instances_by_group[group_name], context_info_by_id + instances_by_group[group_name], + context_info_by_id, + parent_active_by_id ) group_widget.set_active_toggle_enabled( self._active_toggle_enabled @@ -763,7 +857,7 @@ class InstanceCardView(AbstractInstanceView): self._update_ordered_group_names() - def has_items(self): + def has_items(self) -> bool: if self._convertor_items_group is not None: return True if self._widgets_by_group: @@ -828,9 +922,31 @@ class InstanceCardView(AbstractInstanceView): instance_items_by_id = self._controller.get_instance_items_by_id( instance_ids ) + instance_ids = set(instance_items_by_id) + + parent_is_active_by_id = { + instance_id: False + for instance_id in instance_ids + } + + discarted_ids = set() + _queue = collections.deque() + _queue.append((None, True)) + while _queue: + parent_id, parent_is_active = _queue.pop() + for instance_id in self._instance_ids_by_parent_id[parent_id]: + if instance_id in instance_ids: + instance_ids.discard(instance_id) + discarted_ids.add(instance_id) + # TODO there is no way how to get current state + parent_is_active_by_id[instance_id] = parent_is_active + for widget in self._widgets_by_group.values(): widget.update_instance_values( - context_info_by_id, instance_items_by_id, instance_ids + context_info_by_id, + instance_items_by_id, + instance_ids, + parent_is_active_by_id, ) def _on_active_changed(self, group_name, instance_id, value): From 74ad2e2c7ed451807934f9e640e1f2be2aab350c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 17:39:54 +0200 Subject: [PATCH 099/319] add settings category to CollectAnatomyInstanceData --- .../ayon_core/plugins/publish/collect_anatomy_instance_data.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py b/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py index 2fcf562dd0..2cb2297bf7 100644 --- a/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py +++ b/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py @@ -46,6 +46,8 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder + 0.49 label = "Collect Anatomy Instance data" + settings_category = "core" + follow_workfile_version = False def process(self, context): From 06dbaf2d635d42ad9ba82701593b37a453a5f6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 29 Jul 2025 18:01:34 +0200 Subject: [PATCH 100/319] :recycle: add link types --- .../workfile/workfile_template_builder.py | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index bfa192d834..6b82e3b04d 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -204,7 +204,9 @@ class AbstractTemplateBuilder(ABC): @property def linked_folder_entities(self): if self._linked_folder_entities is _NOT_SET: - self._linked_folder_entities = self._get_linked_folder_entities() + self._linked_folder_entities = self._get_linked_folder_entities( + link_type="template" + ) return self._linked_folder_entities @property @@ -307,14 +309,14 @@ class AbstractTemplateBuilder(ABC): self._loaders_by_name = get_loaders_by_name() return self._loaders_by_name - def _get_linked_folder_entities(self): + def _get_linked_folder_entities(self, link_type: str = "template"): project_name = self.project_name folder_entity = self.current_folder_entity if not folder_entity: return [] links = get_folder_links( project_name, - folder_entity["id"], link_types=["template"], link_direction="in" + folder_entity["id"], link_types=[link_type], link_direction="in" ) linked_folder_ids = { link["entityId"] @@ -1433,6 +1435,14 @@ class PlaceholderLoadMixin(object): {"label": "Linked folders", "value": "linked_folders"}, {"label": "All folders", "value": "all_folders"}, ] + + link_types = ayon_api.get_link_types(self.builder.project_name) + + link_types_enum_item = [ + {"label": link_type["name"], "value": link_type["linkType"]} + for link_type in link_types + + ] build_type_label = "Folder Builder Type" build_type_help = ( "Folder Builder Type\n" @@ -1461,6 +1471,17 @@ class PlaceholderLoadMixin(object): items=builder_type_enum_items, tooltip=build_type_help ), + attribute_definitions.EnumDef( + "link_type", + label="Link Type", + default="template", + items=link_types_enum_item, + tooltip=( + "Link Type\n" + "\nDefines what type of link will be used to" + " link the asset to the current folder." + ) + ), attribute_definitions.EnumDef( "product_type", label="Product type", From d8392a2133d4196c3985357feb6fd4344084f954 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 18:07:17 +0200 Subject: [PATCH 101/319] fix possible issue with missing instance data --- .../publisher/widgets/list_view_widgets.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index f0fb5dcf82..9e3113001b 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -1022,6 +1022,7 @@ class InstanceListView(AbstractInstanceView): instance_ids ) instance_ids = set(instance_items_by_id) + available_ids = set(instance_ids) group_items = list(self._group_items.values()) if self._missing_parent_item is not None: @@ -1050,17 +1051,22 @@ class InstanceListView(AbstractInstanceView): # Add children ids to 'instance_ids' to traverse them too add_children = False if instance_id in instance_ids: - instance_ids.discard(instance_id) - discarted_ids.add(instance_id) # Parent active state changed -> traverse children too add_children = ( parent_active is not widget.is_parent_active() ) - widget.update_instance( - instance_items_by_id[instance_id], - context_info_by_id[instance_id], - parent_active, - ) + if instance_id in available_ids: + available_ids.discard(instance_id) + widget.update_instance( + instance_items_by_id[instance_id], + context_info_by_id[instance_id], + parent_active, + ) + else: + widget.set_active(parent_active) + + instance_ids.discard(instance_id) + discarted_ids.add(instance_id) if not child.hasChildren(): continue From 6bc3e5130e0ded5fbc0986770ce9f8e72a5afdf2 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 18:19:41 +0200 Subject: [PATCH 102/319] reworked card view for easier maintanance of widget updates --- .../publisher/widgets/card_view_widgets.py | 644 +++++++++--------- 1 file changed, 326 insertions(+), 318 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 1a2855888a..238f270f1f 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -23,7 +23,7 @@ from __future__ import annotations import re import collections -from typing import Dict +from typing import Optional from qtpy import QtWidgets, QtCore @@ -87,7 +87,6 @@ class BaseGroupWidget(QtWidgets.QWidget): self._group = group_name self._widgets_by_id = {} - self._ordered_item_ids = [] self._label_widget = label_widget self._content_layout = layout @@ -102,48 +101,25 @@ class BaseGroupWidget(QtWidgets.QWidget): return self._group - def get_widget_by_item_id(self, item_id): - """Get instance widget by its id.""" + def set_widgets( + self, + widgets_by_id: dict[str, QtWidgets.QWidget], + ordered_ids: list[str], + ) -> None: + self._remove_all_except(set(self._widgets_by_id)) + idx = 1 + for item_id in ordered_ids: + widget = widgets_by_id[item_id] + self._content_layout.insertWidget(idx, widget) + self._widgets_by_id[item_id] = widget + idx += 1 - return self._widgets_by_id.get(item_id) - - def get_selected_item_ids(self): - """Selected instance ids. - - Returns: - Set[str]: Instance ids that are selected. - """ - - return { - instance_id - for instance_id, widget in self._widgets_by_id.items() - if widget.is_selected - } - - def get_selected_widgets(self): - """Access to widgets marked as selected. - - Returns: - List[InstanceCardWidget]: Instance widgets that are selected. - """ - - return [ - widget - for instance_id, widget in self._widgets_by_id.items() - if widget.is_selected - ] - - def get_ordered_widgets(self): - """Get instance ids in order as are shown in ui. - - Returns: - List[str]: Instance ids. - """ - - return [ - self._widgets_by_id[instance_id] - for instance_id in self._ordered_item_ids - ] + def take_widgets(self, widget_ids: set[str]): + for widget_id in widget_ids: + widget = self._widgets_by_id.pop(widget_id) + index = self._content_layout.indexOf(widget) + if index >= 0: + self._content_layout.takeAt(index) def _remove_all_except(self, item_ids): item_ids = set(item_ids) @@ -160,149 +136,6 @@ class BaseGroupWidget(QtWidgets.QWidget): self._content_layout.removeWidget(widget) widget.deleteLater() - def _update_ordered_item_ids(self): - ordered_item_ids = [] - for idx in range(self._content_layout.count()): - if idx > 0: - item = self._content_layout.itemAt(idx) - widget = item.widget() - if widget is not None: - ordered_item_ids.append(widget.id) - - self._ordered_item_ids = ordered_item_ids - - def _on_widget_selection(self, instance_id, group_id, selection_type): - self.selected.emit(instance_id, group_id, selection_type) - - def set_active_toggle_enabled(self, enabled): - for widget in self._widgets_by_id.values(): - if isinstance(widget, InstanceCardWidget): - widget.set_active_toggle_enabled(enabled) - - -class ConvertorItemsGroupWidget(BaseGroupWidget): - def update_items(self, items_by_id): - items_by_label = collections.defaultdict(list) - for item in items_by_id.values(): - items_by_label[item.label].append(item) - - # Remove instance widgets that are not in passed instances - self._remove_all_except(items_by_id.keys()) - - # Sort instances by product name - sorted_labels = list(sorted(items_by_label.keys())) - - # Add new instances to widget - widget_idx = 1 - for label in sorted_labels: - for item in items_by_label[label]: - if item.id in self._widgets_by_id: - widget = self._widgets_by_id[item.id] - widget.update_item(item) - else: - widget = ConvertorItemCardWidget(item, self) - widget.selected.connect(self._on_widget_selection) - widget.double_clicked.connect(self.double_clicked) - self._widgets_by_id[item.id] = widget - self._content_layout.insertWidget(widget_idx, widget) - widget_idx += 1 - - self._update_ordered_item_ids() - - -class InstanceGroupWidget(BaseGroupWidget): - """Widget wrapping instances under group.""" - - active_changed = QtCore.Signal(str, str, bool) - - def __init__(self, group_icons, *args, **kwargs): - super().__init__(*args, **kwargs) - - self._group_icons = group_icons - - def update_icons(self, group_icons): - self._group_icons = group_icons - - def update_instance_values( - self, - context_info_by_id, - instance_items_by_id, - instance_ids, - parent_is_active_by_id, - ): - """Trigger update on instance widgets.""" - - for instance_id, widget in self._widgets_by_id.items(): - if instance_ids is not None and instance_id not in instance_ids: - continue - widget.update_instance( - instance_items_by_id[instance_id], - context_info_by_id[instance_id], - parent_is_active_by_id[instance_id], - ) - - def update_instances( - self, - instances: list[InstanceItem], - context_info_by_id: dict[str, InstanceContextInfo], - parent_active_by_id: dict[str, bool] - ): - """Update instances for the group. - - Args: - instances (list[InstanceItem]): List of instances in - CreateContext. - context_info_by_id (dict[str, InstanceContextInfo]): Instance - context info by instance id. - parent_active_by_id (dict[str, bool]): Instance has active parent. - - """ - # Store instances by id and by product name - instances_by_id = {} - instances_by_product_name = collections.defaultdict(list) - for instance in instances: - instances_by_id[instance.id] = instance - product_name = instance.product_name - instances_by_product_name[product_name].append(instance) - - # Remove instance widgets that are not in passed instances - self._remove_all_except(instances_by_id.keys()) - - # Sort instances by product name - sorted_product_names = list(sorted(instances_by_product_name.keys())) - - # Add new instances to widget - widget_idx = 1 - for product_names in sorted_product_names: - for instance in instances_by_product_name[product_names]: - context_info = context_info_by_id[instance.id] - parent_is_active = parent_active_by_id[instance.id] - if instance.id in self._widgets_by_id: - widget = self._widgets_by_id[instance.id] - widget.update_instance( - instance, context_info, parent_is_active - ) - else: - group_icon = self._group_icons[instance.creator_identifier] - widget = InstanceCardWidget( - instance, - context_info, - parent_is_active, - group_icon, - self - ) - widget.selected.connect(self._on_widget_selection) - widget.active_changed.connect(self._on_active_changed) - widget.double_clicked.connect(self.double_clicked) - self._widgets_by_id[instance.id] = widget - self._content_layout.insertWidget(widget_idx, widget) - widget_idx += 1 - - self._update_ordered_item_ids() - - def _on_active_changed(self, instance_id, value): - self.active_changed.emit(self.group_name, instance_id, value) - class CardWidget(BaseClickableFrame): """Clickable card used as bigger button.""" @@ -423,6 +256,10 @@ class ConvertorItemCardWidget(CardWidget): self._icon_widget = icon_widget self._label_widget = label_widget + def update_item(self, item): + self._id = item.id + self.identifier = item.identifier + class InstanceCardWidget(CardWidget): """Card widget representing instance.""" @@ -433,7 +270,7 @@ class InstanceCardWidget(CardWidget): self, instance, context_info, - parent_is_active: bool, + is_parent_active: bool, group_icon, parent: BaseGroupWidget, ): @@ -444,7 +281,7 @@ class InstanceCardWidget(CardWidget): self._id = instance.id self._group_identifier = instance.group_label self._group_icon = group_icon - self._parent_is_active = parent_is_active + self._is_parent_active = is_parent_active self._toggle_is_enabled = True self._last_product_name = None @@ -499,18 +336,26 @@ class InstanceCardWidget(CardWidget): self._active_checkbox = active_checkbox self._expand_btn = expand_btn - self._update_instance_values(context_info, parent_is_active) + self._update_instance_values(context_info, is_parent_active) - def set_active_toggle_enabled(self, enabled): + def set_active_toggle_enabled(self, enabled: bool) -> None: if self._toggle_is_enabled is enabled: return self._toggle_is_enabled = enabled self._update_checkbox_state() - @property - def is_active(self): + def is_active(self) -> bool: return self._active_checkbox.isChecked() + def is_parent_active(self) -> bool: + return self._is_parent_active + + def set_parent_active(self, is_active: bool) -> None: + if self._is_parent_active is is_active: + return + self._is_parent_active = is_active + self._update_checkbox_state() + def is_checkbox_enabled(self) -> bool: """Checkbox can be changed by user.""" return ( @@ -518,10 +363,10 @@ class InstanceCardWidget(CardWidget): and not self.instance.is_mandatory ) - def update_instance(self, instance, context_info, parent_is_active): + def update_instance(self, instance, context_info, is_parent_active): """Update instance object and update UI.""" self.instance = instance - self._update_instance_values(context_info, parent_is_active) + self._update_instance_values(context_info, is_parent_active) def _validate_context(self, context_info): valid = context_info.is_valid @@ -560,9 +405,9 @@ class InstanceCardWidget(CardWidget): QtCore.Qt.NoTextInteraction ) - def _update_instance_values(self, context_info, parent_is_active): + def _update_instance_values(self, context_info, is_parent_active): """Update instance data""" - self._parent_is_active = parent_is_active + self._is_parent_active = is_parent_active self._update_product_name() self._update_checkbox_state() self._validate_context(context_info) @@ -587,7 +432,7 @@ class InstanceCardWidget(CardWidget): def _used_parent_active(self) -> bool: parent_enabled = True if self.instance.parent_flags & ParentFlags.share_active: - parent_enabled = self._parent_is_active + parent_enabled = self._is_parent_active return parent_enabled def _set_expanded(self, expanded=None): @@ -654,11 +499,20 @@ class InstanceCardView(AbstractInstanceView): self._content_layout = content_layout self._content_widget = content_widget - self._context_widget = None - self._convertor_items_group = None - self._active_toggle_enabled = True - self._widgets_by_group: Dict[str, InstanceGroupWidget] = {} + self._active_toggle_enabled: bool = True + self._convertors_group: Optional[BaseGroupWidget] = None + self._convertor_widgets_by_id: dict[str, ConvertorItemCardWidget] = {} + self._convertor_ids: list[str] = [] + + self._group_name_by_instance_id: dict[str, str] = {} + self._instance_ids_by_group_name: dict[str, list[str]] = ( + collections.defaultdict(list) + ) self._ordered_groups = [] + self._group_icons = {} + self._context_widget: Optional[ContextCardWidget] = None + self._widgets_by_id: dict[str, InstanceCardWidget] = {} + self._widgets_by_group: dict[str, BaseGroupWidget] = {} self._instance_ids_by_parent_id = collections.defaultdict(set) @@ -694,7 +548,7 @@ class InstanceCardView(AbstractInstanceView): continue instance_id = widget.id - is_active = widget.is_active + is_active = widget.is_active() if value == -1: active_state_by_id[instance_id] = not is_active continue @@ -731,12 +585,17 @@ class InstanceCardView(AbstractInstanceView): ): output.append(self._context_widget) - if self._convertor_items_group is not None: - output.extend(self._convertor_items_group.get_selected_widgets()) + output.extend( + widget + for widget in self._convertor_widgets_by_id.values() + if widget.is_selected + ) - for group_widget in self._widgets_by_group.values(): - for widget in group_widget.get_selected_widgets(): - output.append(widget) + output.extend( + widget + for widget in self._widgets_by_id.values() + if widget.is_selected + ) return output def _get_selected_instance_ids(self): @@ -747,11 +606,17 @@ class InstanceCardView(AbstractInstanceView): ): output.append(CONTEXT_ID) - if self._convertor_items_group is not None: - output.extend(self._convertor_items_group.get_selected_item_ids()) + output.extend( + conv_id + for conv_id, widget in self._widgets_by_id.items() + if widget.is_selected + ) - for group_widget in self._widgets_by_group.values(): - output.extend(group_widget.get_selected_item_ids()) + output.extend( + widget.id + for instance_id, widget in self._widgets_by_id.items() + if widget.is_selected + ) return output def refresh(self): @@ -759,13 +624,14 @@ class InstanceCardView(AbstractInstanceView): self._make_sure_context_widget_exists() - self._update_convertor_items_group() + self._update_convertors_group() context_info_by_id = self._controller.get_instances_context_info() # Prepare instances by group and identifiers by group instances_by_group = collections.defaultdict(list) identifiers_by_group = collections.defaultdict(set) + identifiers: set[str] = set() instances_by_id = {} instance_ids_by_parent_id = collections.defaultdict(set) instance_items = self._controller.get_instance_items() @@ -775,6 +641,7 @@ class InstanceCardView(AbstractInstanceView): identifiers_by_group[group_name].add( instance.creator_identifier ) + identifiers.add(instance.creator_identifier) instances_by_id[instance.id] = instance instance_ids_by_parent_id[instance.parent_instance_id].add( instance.id @@ -787,28 +654,67 @@ class InstanceCardView(AbstractInstanceView): _queue = collections.deque() _queue.append((None, True)) while _queue: - parent_id, parent_is_active = _queue.popleft() + parent_id, is_parent_active = _queue.popleft() for instance_id in instance_ids_by_parent_id[parent_id]: instance_item = instances_by_id[instance_id] is_active = instance_item.is_active if ( - not parent_is_active + not is_parent_active and instance_item.parent_flags & ParentFlags.share_active ): is_active = False - parent_active_by_id[instance_id] = parent_is_active + parent_active_by_id[instance_id] = is_parent_active _queue.append( (instance_id, is_active) ) - self._instance_ids_by_parent_id = instance_ids_by_parent_id + # Remove groups that were not found in passed instances + groups_to_remove = ( + set(self._widgets_by_group) - set(instances_by_group) + ) - # Remove groups that were not found in apassed instances - for group_name in tuple(self._widgets_by_group.keys()): - if group_name in instances_by_group: - continue + # Sort groups + sorted_group_names = list(sorted(instances_by_group.keys())) + # Keep track of widget indexes + # - we start with 1 because Context item as at the top + widget_idx = 1 + if self._convertors_group is not None: + widget_idx += 1 + + group_by_instance_id = {} + instance_ids_by_group_name = collections.defaultdict(list) + group_icons = { + identifier: self._controller.get_creator_icon(identifier) + for identifier in identifiers + } + for group_name in sorted_group_names: + if group_name not in self._widgets_by_group: + group_widget = BaseGroupWidget( + group_name, self._content_widget + ) + group_widget.double_clicked.connect(self.double_clicked) + self._content_layout.insertWidget(widget_idx, group_widget) + self._widgets_by_group[group_name] = group_widget + + widget_idx += 1 + + instances = instances_by_group[group_name] + for instance in instances: + group_by_instance_id[instance.id] = group_name + instance_ids_by_group_name[group_name].append(instance.id) + + self._update_instances( + group_name, + instances, + context_info_by_id, + parent_active_by_id, + group_icons, + ) + + # Remove empty groups + for group_name in groups_to_remove: widget = self._widgets_by_group.pop(group_name) widget.setVisible(False) self._content_layout.removeWidget(widget) @@ -817,63 +723,85 @@ class InstanceCardView(AbstractInstanceView): if group_name in self._explicitly_selected_groups: self._explicitly_selected_groups.remove(group_name) - # Sort groups - sorted_group_names = list(sorted(instances_by_group.keys())) - - # Keep track of widget indexes - # - we start with 1 because Context item as at the top - widget_idx = 1 - if self._convertor_items_group is not None: - widget_idx += 1 - - for group_name in sorted_group_names: - group_icons = { - identifier: self._controller.get_creator_icon(identifier) - for identifier in identifiers_by_group[group_name] - } - if group_name in self._widgets_by_group: - group_widget = self._widgets_by_group[group_name] - group_widget.update_icons(group_icons) - - else: - group_widget = InstanceGroupWidget( - group_icons, group_name, self._content_widget - ) - group_widget.active_changed.connect(self._on_active_changed) - group_widget.selected.connect(self._on_widget_selection) - group_widget.double_clicked.connect(self.double_clicked) - self._content_layout.insertWidget(widget_idx, group_widget) - self._widgets_by_group[group_name] = group_widget - - widget_idx += 1 - group_widget.update_instances( - instances_by_group[group_name], - context_info_by_id, - parent_active_by_id - ) - group_widget.set_active_toggle_enabled( - self._active_toggle_enabled - ) - - self._update_ordered_group_names() + self._instance_ids_by_parent_id = instance_ids_by_parent_id + self._group_name_by_instance_id = group_by_instance_id + self._instance_ids_by_group_name = instance_ids_by_group_name + self._ordered_groups = sorted_group_names def has_items(self) -> bool: - if self._convertor_items_group is not None: + if self._convertors_group is not None: return True - if self._widgets_by_group: + if self._widgets_by_id: return True return False - def _update_ordered_group_names(self): - ordered_group_names = [CONTEXT_GROUP] - for idx in range(self._content_layout.count()): - if idx > 0: - item = self._content_layout.itemAt(idx) - group_widget = item.widget() - if group_widget is not None: - ordered_group_names.append(group_widget.group_name) + def _update_instances( + self, + group_name: str, + instances: list[InstanceItem], + context_info_by_id: dict[str, InstanceContextInfo], + parent_active_by_id: dict[str, bool], + group_icons: dict[str, str], + ): + """Update instances for the group. - self._ordered_groups = ordered_group_names + Args: + instances (list[InstanceItem]): List of instances in + CreateContext. + context_info_by_id (dict[str, InstanceContextInfo]): Instance + context info by instance id. + parent_active_by_id (dict[str, bool]): Instance has active parent. + + """ + # Store instances by id and by product name + group_widget: BaseGroupWidget = self._widgets_by_group[group_name] + instances_by_id = {} + instances_by_product_name = collections.defaultdict(list) + for instance in instances: + instances_by_id[instance.id] = instance + product_name = instance.product_name + instances_by_product_name[product_name].append(instance) + + to_remove_ids = set( + self._instance_ids_by_group_name[group_name] + ) - set(instances_by_id) + group_widget.take_widgets(to_remove_ids) + + # Sort instances by product name + sorted_product_names = list(sorted(instances_by_product_name.keys())) + + # Add new instances to widget + ordered_ids = [] + widgets_by_id = {} + for product_names in sorted_product_names: + for instance in instances_by_product_name[product_names]: + context_info = context_info_by_id[instance.id] + is_parent_active = parent_active_by_id[instance.id] + if instance.id in self._widgets_by_id: + widget = self._widgets_by_id[instance.id] + widget.update_instance( + instance, context_info, is_parent_active + ) + else: + group_icon = group_icons[instance.creator_identifier] + widget = InstanceCardWidget( + instance, + context_info, + is_parent_active, + group_icon, + group_widget + ) + widget.selected.connect(self._on_widget_selection) + widget.active_changed.connect(self._on_active_changed) + widget.double_clicked.connect(self.double_clicked) + self._widgets_by_id[instance.id] = widget + + ordered_ids.append(instance.id) + widgets_by_id[instance.id] = widget + + group_widget.set_widgets(widgets_by_id, ordered_ids) + + return ordered_ids def _make_sure_context_widget_exists(self): # Create context item if is not already existing @@ -891,28 +819,65 @@ class InstanceCardView(AbstractInstanceView): self.selection_changed.emit() self._content_layout.insertWidget(0, widget) - def _update_convertor_items_group(self): + def _update_convertors_group(self): convertor_items = self._controller.get_convertor_items() - if not convertor_items and self._convertor_items_group is None: + if not convertor_items and self._convertors_group is None: return + ids_to_remove = set(self._convertor_widgets_by_id) - set( + convertor_items + ) + if ids_to_remove: + self._convertors_group.take_widgets(ids_to_remove) + + for conv_id in ids_to_remove: + widget = self._convertor_widgets_by_id.pop(conv_id) + widget.setVisible(False) + widget.deleteLater() + if not convertor_items: - self._convertor_items_group.setVisible(False) - self._content_layout.removeWidget(self._convertor_items_group) - self._convertor_items_group.deleteLater() - self._convertor_items_group = None + self._convertors_group.setVisible(False) + self._content_layout.removeWidget(self._convertors_group) + self._convertors_group.deleteLater() + self._convertors_group = None + self._convertor_ids = [] + self._convertor_widgets_by_id = {} return - if self._convertor_items_group is None: - group_widget = ConvertorItemsGroupWidget( + if self._convertors_group is None: + group_widget = BaseGroupWidget( CONVERTOR_ITEM_GROUP, self._content_widget ) - group_widget.selected.connect(self._on_widget_selection) - group_widget.double_clicked.connect(self.double_clicked) self._content_layout.insertWidget(1, group_widget) - self._convertor_items_group = group_widget + self._convertors_group = group_widget - self._convertor_items_group.update_items(convertor_items) + # TODO create convertor widgets + items_by_label = collections.defaultdict(list) + for item in convertor_items.values(): + items_by_label[item.label].append(item) + + # Sort instances by product name + sorted_labels = list(sorted(items_by_label.keys())) + + # Add new instances to widget + convertor_ids: list[str] = [] + widgets_by_id: dict[str, ConvertorItemCardWidget] = {} + for label in sorted_labels: + for item in items_by_label[label]: + convertor_ids.append(item.id) + if item.id in self._convertor_widgets_by_id: + widget = self._convertor_widgets_by_id[item.id] + widget.update_item(item) + else: + widget = ConvertorItemCardWidget(item, self) + widget.selected.connect(self._on_widget_selection) + widget.double_clicked.connect(self.double_clicked) + self._convertor_widgets_by_id[item.id] = widget + widgets_by_id[item.id] = widget + + self._convertors_group.set_widgets(widgets_by_id, convertor_ids) + self._convertor_ids = convertor_ids + self._convertor_widgets_by_id = widgets_by_id def refresh_instance_states(self, instance_ids=None): """Trigger update of instances on group widgets.""" @@ -922,36 +887,57 @@ class InstanceCardView(AbstractInstanceView): instance_items_by_id = self._controller.get_instance_items_by_id( instance_ids ) - instance_ids = set(instance_items_by_id) + instance_ids: set[str] = set(instance_items_by_id) + available_ids: set[str] = set(instance_items_by_id) + discarted_ids: set[str] = set() - parent_is_active_by_id = { - instance_id: False - for instance_id in instance_ids - } - - discarted_ids = set() _queue = collections.deque() - _queue.append((None, True)) + _queue.append((set(self._instance_ids_by_parent_id[None]), True)) while _queue: - parent_id, parent_is_active = _queue.pop() - for instance_id in self._instance_ids_by_parent_id[parent_id]: + if not instance_ids: + break + + chilren_ids, is_parent_active = _queue.pop() + for instance_id in chilren_ids: + widget = self._widgets_by_id[instance_id] + add_children = False if instance_id in instance_ids: + add_children = ( + is_parent_active is not widget.is_parent_active() + ) + + if instance_id in available_ids: + available_ids.discard(instance_id) + widget.update_instance( + instance_items_by_id[instance_id], + context_info_by_id[instance_id], + is_parent_active, + ) + else: + # TODO implement 'set_parent_active' + widget.set_parent_active(is_parent_active) + instance_ids.discard(instance_id) discarted_ids.add(instance_id) - # TODO there is no way how to get current state - parent_is_active_by_id[instance_id] = parent_is_active - for widget in self._widgets_by_group.values(): - widget.update_instance_values( - context_info_by_id, - instance_items_by_id, - instance_ids, - parent_is_active_by_id, - ) + if not instance_ids: + break - def _on_active_changed(self, group_name, instance_id, value): - group_widget = self._widgets_by_group[group_name] - instance_widget = group_widget.get_widget_by_item_id(instance_id) + if not add_children: + continue + + children_ids = self._instance_ids_by_parent_id[instance_id] + children = { + child_id + for child_id in children_ids + if child_id not in discarted_ids + } + + if children: + _queue.append((children, widget.is_active())) + + def _on_active_changed(self, instance_id, value): + instance_widget = self._widgets_by_id[instance_id] active_state_by_id = {} if not instance_widget.is_selected: active_state_by_id[instance_id] = value @@ -973,10 +959,9 @@ class InstanceCardView(AbstractInstanceView): else: if group_name == CONVERTOR_ITEM_GROUP: - group_widget = self._convertor_items_group + new_widget = self._convertor_widgets_by_id[instance_id] else: - group_widget = self._widgets_by_group[group_name] - new_widget = group_widget.get_widget_by_item_id(instance_id) + new_widget = self._widgets_by_id[instance_id] if selection_type == SelectionTypes.clear: self._select_item_clear(instance_id, group_name, new_widget) @@ -1021,11 +1006,21 @@ class InstanceCardView(AbstractInstanceView): if instance_id == CONTEXT_ID: remove_group = True else: + has_selected_items = False if group_name == CONVERTOR_ITEM_GROUP: - group_widget = self._convertor_items_group + for widget in self._convertor_widgets_by_id.values(): + if widget.is_selected: + has_selected_items = True + break else: - group_widget = self._widgets_by_group[group_name] - if not group_widget.get_selected_widgets(): + group_ids = self._instance_ids_by_group_name[group_name] + for instance_id in group_ids: + widget = self._widgets_by_id[instance_id] + if widget.is_selected: + has_selected_items = True + break + + if not has_selected_items: remove_group = True if remove_group: @@ -1137,10 +1132,16 @@ class InstanceCardView(AbstractInstanceView): sorted_widgets = [self._context_widget] else: if name == CONVERTOR_ITEM_GROUP: - group_widget = self._convertor_items_group + sorted_widgets = [ + self._convertor_widgets_by_id[conv_id] + for conv_id in self._convertor_ids + ] else: - group_widget = self._widgets_by_group[name] - sorted_widgets = group_widget.get_ordered_widgets() + instance_ids = self._instance_ids_by_group_name[name] + sorted_widgets = [ + self._widgets_by_id[instance_id] + for instance_id in instance_ids + ] # Change selection based on explicit selection if start group # was not passed yet @@ -1298,12 +1299,19 @@ class InstanceCardView(AbstractInstanceView): is_convertor_group = group_name == CONVERTOR_ITEM_GROUP if is_convertor_group: - group_widget = self._convertor_items_group + sorted_widgets = [ + self._convertor_widgets_by_id[conv_id] + for conv_id in self._convertor_ids + ] else: - group_widget = self._widgets_by_group[group_name] + instance_ids = self._instance_ids_by_group_name[group_name] + sorted_widgets = [ + self._widgets_by_id[instance_id] + for instance_id in instance_ids + ] group_selected = False - for widget in group_widget.get_ordered_widgets(): + for widget in sorted_widgets: select = False if is_convertor_group: is_in = widget.identifier in s_convertor_identifiers @@ -1325,5 +1333,5 @@ class InstanceCardView(AbstractInstanceView): if self._active_toggle_enabled is enabled: return self._active_toggle_enabled = enabled - for group_widget in self._widgets_by_group.values(): - group_widget.set_active_toggle_enabled(enabled) + for widget in self._widgets_by_id.values(): + widget.set_active_toggle_enabled(enabled) From 067f218752aa605d1433a75dd54266fb07e8171a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 18:58:09 +0200 Subject: [PATCH 103/319] few enhancements --- .../tools/publisher/widgets/card_view_widgets.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 238f270f1f..e3e8a98ad5 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -705,7 +705,7 @@ class InstanceCardView(AbstractInstanceView): group_by_instance_id[instance.id] = group_name instance_ids_by_group_name[group_name].append(instance.id) - self._update_instances( + self._update_instance_widgets( group_name, instances, context_info_by_id, @@ -735,7 +735,7 @@ class InstanceCardView(AbstractInstanceView): return True return False - def _update_instances( + def _update_instance_widgets( self, group_name: str, instances: list[InstanceItem], @@ -905,7 +905,6 @@ class InstanceCardView(AbstractInstanceView): add_children = ( is_parent_active is not widget.is_parent_active() ) - if instance_id in available_ids: available_ids.discard(instance_id) widget.update_instance( @@ -914,15 +913,11 @@ class InstanceCardView(AbstractInstanceView): is_parent_active, ) else: - # TODO implement 'set_parent_active' widget.set_parent_active(is_parent_active) instance_ids.discard(instance_id) discarted_ids.add(instance_id) - if not instance_ids: - break - if not add_children: continue @@ -934,8 +929,12 @@ class InstanceCardView(AbstractInstanceView): } if children: + instance_ids |= children _queue.append((children, widget.is_active())) + if not instance_ids: + break + def _on_active_changed(self, instance_id, value): instance_widget = self._widgets_by_id[instance_id] active_state_by_id = {} From 744d36042c5d5ef570c98a474309d894b5f28f7b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 18:59:45 +0200 Subject: [PATCH 104/319] remove parent active validation --- client/ayon_core/tools/publisher/widgets/list_view_widgets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 9e3113001b..3440a91b6f 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -1144,7 +1144,7 @@ class InstanceListView(AbstractInstanceView): instance_id = child.data(INSTANCE_ID_ROLE) widget = self._widgets_by_id[instance_id] widget.set_parent_is_active(parent_active) - if parent_active and instance_id in instance_ids: + if instance_id in instance_ids: value = new_value if value is None: value = not widget.is_active() From d74435525bfcb17aebcba0dd5ce1834bdf327b91 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 19:19:05 +0200 Subject: [PATCH 105/319] fix signal handling on update --- client/ayon_core/tools/publisher/widgets/list_view_widgets.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 3440a91b6f..7d11746254 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -295,8 +295,7 @@ class InstanceListItemWidget(QtWidgets.QWidget): # Visually disable instance if parent is disabled checked = parent_enabled and self._instance_is_active - if checked is not self._active_checkbox.isChecked(): - self._active_checkbox.setChecked(checked) + self._set_checked(checked) def _on_active_change(self): self.active_changed.emit( From e6ae3fb84736b549b7a0e34097574385f513170e Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 19:22:04 +0200 Subject: [PATCH 106/319] few minor fixes --- .../publisher/widgets/card_view_widgets.py | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index e3e8a98ad5..4f1327baaf 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -277,6 +277,7 @@ class InstanceCardWidget(CardWidget): super().__init__(parent) self.instance = instance + self._is_active = instance.is_active self._id = instance.id self._group_identifier = instance.group_label @@ -366,6 +367,7 @@ class InstanceCardWidget(CardWidget): def update_instance(self, instance, context_info, is_parent_active): """Update instance object and update UI.""" self.instance = instance + self._is_active = instance.is_active self._update_instance_values(context_info, is_parent_active) def _validate_context(self, context_info): @@ -378,8 +380,6 @@ class InstanceCardWidget(CardWidget): product_name = self.instance.product_name label = self.instance.label - parent_is_enabled = self._used_parent_active() - self._label_widget.setEnabled(parent_is_enabled) if ( variant == self._last_variant and product_name == self._last_product_name @@ -414,6 +414,7 @@ class InstanceCardWidget(CardWidget): def _update_checkbox_state(self): parent_is_enabled = self._used_parent_active() + self._label_widget.setEnabled(parent_is_enabled) self._active_checkbox.setEnabled( self._toggle_is_enabled and not self.instance.is_mandatory @@ -423,7 +424,7 @@ class InstanceCardWidget(CardWidget): self._active_checkbox.setVisible(not self.instance.is_mandatory) # Visually disable instance if parent is disabled - checked = parent_is_enabled and self.instance.is_active + checked = parent_is_enabled and self._is_active if checked is not self._active_checkbox.isChecked(): self._active_checkbox.blockSignals(True) self._active_checkbox.setChecked(checked) @@ -442,10 +443,10 @@ class InstanceCardWidget(CardWidget): def _on_active_change(self): new_value = self._active_checkbox.isChecked() - old_value = self.instance.is_active - if new_value == old_value: + old_value = self._is_active + if new_value is old_value: return - + self._is_active = new_value self.active_changed.emit(self._id, new_value) def _on_expend_clicked(self): @@ -742,7 +743,7 @@ class InstanceCardView(AbstractInstanceView): context_info_by_id: dict[str, InstanceContextInfo], parent_active_by_id: dict[str, bool], group_icons: dict[str, str], - ): + ) -> None: """Update instances for the group. Args: @@ -801,8 +802,6 @@ class InstanceCardView(AbstractInstanceView): group_widget.set_widgets(widgets_by_id, ordered_ids) - return ordered_ids - def _make_sure_context_widget_exists(self): # Create context item if is not already existing # - this must be as first thing to do as context item should be at the @@ -945,6 +944,32 @@ class InstanceCardView(AbstractInstanceView): if isinstance(widget, InstanceCardWidget): active_state_by_id[widget.id] = value + if not active_state_by_id: + return + + _queue = collections.deque() + _queue.append((set(self._instance_ids_by_parent_id[None]), True)) + instance_ids = set(active_state_by_id) + discarted_ids = set() + while _queue: + children, parent_active = _queue.popleft() + for instance_id in children: + widget = self._widgets_by_id[instance_id] + old_active = widget.is_active() + widget.set_parent_active(parent_active) + is_active = widget.is_active() + if old_active is not is_active: + active_state_by_id[instance_id] = is_active + + if instance_id in instance_ids: + instance_ids.discard(instance_id) + discarted_ids.add(instance_id) + + _queue.append(( + set(self._instance_ids_by_parent_id[instance_id]), + is_active + )) + self._controller.set_instances_active_state(active_state_by_id) def _on_widget_selection(self, instance_id, group_name, selection_type): From 1758576955a8af9b03a13e78baa0f15f2c29946a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 30 Jul 2025 14:31:04 +0200 Subject: [PATCH 107/319] fix state change in cards view --- .../publisher/widgets/card_view_widgets.py | 149 ++++++++++-------- 1 file changed, 85 insertions(+), 64 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 4f1327baaf..1d2ef9b0d2 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -348,6 +348,13 @@ class InstanceCardWidget(CardWidget): def is_active(self) -> bool: return self._active_checkbox.isChecked() + def set_active(self, active: Optional[bool]) -> None: + if not self.is_checkbox_enabled(): + return + if active is None: + active = not self.is_active() + self._set_checked(active) + def is_parent_active(self) -> bool: return self._is_parent_active @@ -425,6 +432,9 @@ class InstanceCardWidget(CardWidget): # Visually disable instance if parent is disabled checked = parent_is_enabled and self._is_active + self._set_checked(checked) + + def _set_checked(self, checked: bool) -> None: if checked is not self._active_checkbox.isChecked(): self._active_checkbox.blockSignals(True) self._active_checkbox.setChecked(checked) @@ -538,42 +548,85 @@ class InstanceCardView(AbstractInstanceView): result.setWidth(width) return result - def _toggle_instances(self, value): - if not self._active_toggle_enabled: - return + def _toggle_instances( + self, + new_value: Optional[bool], + active_id: Optional[str] = None, + ) -> None: + instance_ids = { + widget.id + for widget in self._get_selected_instance_widgets() + if widget.is_selected + } + active_by_id = {} + if active_id and active_id not in instance_ids: + instance_ids = {active_id} - widgets = self._get_selected_widgets() - active_state_by_id = {} - for widget in widgets: - if not isinstance(widget, InstanceCardWidget): - continue + affected_ids = set(instance_ids) + _queue = collections.deque() + _queue.append((set(self._instance_ids_by_parent_id[None]), True)) + discarted_ids = set() + while _queue: + if not instance_ids: + break - instance_id = widget.id - is_active = widget.is_active() - if value == -1: - active_state_by_id[instance_id] = not is_active - continue + chilren_ids, is_parent_active = _queue.pop() + for instance_id in chilren_ids: + widget = self._widgets_by_id[instance_id] + add_children = False + if instance_id in affected_ids: + affected_ids.discard(instance_id) + instance_ids.discard(instance_id) + discarted_ids.add(instance_id) + add_children = True + value = new_value + if value is None: + value = not widget.is_active() + old_value = widget.is_active() + widget.set_active(value) + if old_value is not widget.is_active(): + active_by_id[instance_id] = value - _value = bool(value) - if is_active is not _value: - active_state_by_id[instance_id] = _value + if ( + instance_id in instance_ids + and is_parent_active is not widget.is_parent_active() + ): + add_children = True + widget.set_parent_active(is_parent_active) - if not active_state_by_id: - return + instance_ids.discard(instance_id) + discarted_ids.add(instance_id) - self._controller.set_instances_active_state(active_state_by_id) + if not add_children: + continue + + children_ids = self._instance_ids_by_parent_id[instance_id] + children = { + child_id + for child_id in children_ids + if child_id not in discarted_ids + } + + if children: + instance_ids |= children + _queue.append((children, widget.is_active())) + + if not instance_ids: + break + + self._controller.set_instances_active_state(active_by_id) def keyPressEvent(self, event): if event.key() == QtCore.Qt.Key_Space: - self._toggle_instances(-1) + self._toggle_instances(None) return True elif event.key() == QtCore.Qt.Key_Backspace: - self._toggle_instances(0) + self._toggle_instances(False) return True elif event.key() == QtCore.Qt.Key_Return: - self._toggle_instances(1) + self._toggle_instances(True) return True return super().keyPressEvent(event) @@ -592,14 +645,17 @@ class InstanceCardView(AbstractInstanceView): if widget.is_selected ) - output.extend( + output.extend(self._get_selected_instance_widgets()) + return output + + def _get_selected_instance_widgets(self) -> list[InstanceCardWidget]: + return [ widget for widget in self._widgets_by_id.values() if widget.is_selected - ) - return output + ] - def _get_selected_instance_ids(self): + def _get_selected_item_ids(self): output = [] if ( self._context_widget is not None @@ -934,43 +990,8 @@ class InstanceCardView(AbstractInstanceView): if not instance_ids: break - def _on_active_changed(self, instance_id, value): - instance_widget = self._widgets_by_id[instance_id] - active_state_by_id = {} - if not instance_widget.is_selected: - active_state_by_id[instance_id] = value - else: - for widget in self._get_selected_widgets(): - if isinstance(widget, InstanceCardWidget): - active_state_by_id[widget.id] = value - - if not active_state_by_id: - return - - _queue = collections.deque() - _queue.append((set(self._instance_ids_by_parent_id[None]), True)) - instance_ids = set(active_state_by_id) - discarted_ids = set() - while _queue: - children, parent_active = _queue.popleft() - for instance_id in children: - widget = self._widgets_by_id[instance_id] - old_active = widget.is_active() - widget.set_parent_active(parent_active) - is_active = widget.is_active() - if old_active is not is_active: - active_state_by_id[instance_id] = is_active - - if instance_id in instance_ids: - instance_ids.discard(instance_id) - discarted_ids.add(instance_id) - - _queue.append(( - set(self._instance_ids_by_parent_id[instance_id]), - is_active - )) - - self._controller.set_instances_active_state(active_state_by_id) + def _on_active_changed(self, instance_id: str, value: bool) -> None: + self._toggle_instances(value, instance_id) def _on_widget_selection(self, instance_id, group_name, selection_type): """Select specific item by instance id. @@ -1021,7 +1042,7 @@ class InstanceCardView(AbstractInstanceView): """ self._explicitly_selected_instance_ids = ( - self._get_selected_instance_ids() + self._get_selected_item_ids() ) if new_widget.is_selected: self._explicitly_selected_instance_ids.remove(instance_id) From 5324c6122dacbd94f9a230fa3358384ca56484d9 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 30 Jul 2025 14:31:20 +0200 Subject: [PATCH 108/319] fix state changes in list view --- .../publisher/widgets/list_view_widgets.py | 95 +++++++------------ 1 file changed, 34 insertions(+), 61 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 7d11746254..a2aadd9cfa 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -506,14 +506,13 @@ class InstanceListView(AbstractInstanceView): if not self._active_toggle_enabled: return - selected_instance_ids = self._instance_view.get_selected_instance_ids() if toggle == -1: active = None elif toggle == 1: active = True else: active = False - self._toggle_active_state(selected_instance_ids, active) + self._toggle_active_state(active) def _update_group_checkstate(self, group_name): """Update checkstate of one group.""" @@ -1086,75 +1085,49 @@ class InstanceListView(AbstractInstanceView): _queue.append((children, widget.is_active())) def _on_active_changed(self, changed_instance_id, new_value): - selected_instance_ids, _, _ = self.get_selected_items() - if changed_instance_id not in selected_instance_ids: - selected_instance_ids = {changed_instance_id} - - self._toggle_active_state( - set(selected_instance_ids), - new_value, - changed_instance_id - ) + self._toggle_active_state(new_value, changed_instance_id) def _toggle_active_state( self, - instance_ids: set[str], new_value: Optional[bool], active_id: Optional[str] = None, ) -> None: - active_widget = None - if active_id: - active_widget = self._widgets_by_id[active_id] - active_by_id = {} + instance_ids, _, _ = self.get_selected_items() if active_id and active_id not in instance_ids: - if not active_widget.is_checkbox_enabled(): - return - if new_value is None: - new_value = not active_widget.is_active() - active_by_id[active_id] = new_value - active_widget.set_active(new_value) - else: - # First make sure that the item under mouse is changed if possible - if active_widget and active_widget.is_checkbox_enabled(): - value = new_value - if value is None: - value = not active_widget.is_active() + instance_ids = {active_id} - active_by_id[active_id] = value - active_widget.set_active(new_value) - instance_ids.discard(active_id) + active_by_id = {} + # Change the states from top to bottom + group_items = list(self._group_items.values()) + if self._missing_parent_item is not None: + group_items.append(self._missing_parent_item) - # Change the states from top to bottom - group_items = list(self._group_items.values()) - if self._missing_parent_item is not None: - group_items.append(self._missing_parent_item) + _queue = collections.deque() + for group_item in group_items: + children = [ + group_item.child(row) + for row in range(group_item.rowCount()) + ] + _queue.append((children, True)) + + while _queue: + children, parent_active = _queue.popleft() + for child in children: + instance_id = child.data(INSTANCE_ID_ROLE) + widget = self._widgets_by_id[instance_id] + widget.set_parent_is_active(parent_active) + if instance_id in instance_ids: + value = new_value + if value is None: + value = not widget.is_active() + widget.set_active(value) + active_by_id[instance_id] = value - _queue = collections.deque() - for group_item in group_items: children = [ - group_item.child(row) - for row in range(group_item.rowCount()) + child.child(row) + for row in range(child.rowCount()) ] - _queue.append((children, True)) - - while _queue: - children, parent_active = _queue.popleft() - for child in children: - instance_id = child.data(INSTANCE_ID_ROLE) - widget = self._widgets_by_id[instance_id] - widget.set_parent_is_active(parent_active) - if instance_id in instance_ids: - value = new_value - if value is None: - value = not widget.is_active() - widget.set_active(value) - active_by_id[instance_id] = value - - children = [ - child.child(row) - for row in range(child.rowCount()) - ] - _queue.append((children, widget.is_active())) + _queue.append((children, widget.is_active())) self._controller.set_instances_active_state(active_by_id) @@ -1195,7 +1168,7 @@ class InstanceListView(AbstractInstanceView): instance_id = child.data(INSTANCE_ID_ROLE) instance_ids.add(instance_id) - self._toggle_active_state(instance_ids, active) + self._toggle_active_state(active) proxy_index = self._proxy_model.mapFromSource(group_item.index()) if not self._instance_view.isExpanded(proxy_index): @@ -1339,7 +1312,7 @@ class InstanceListView(AbstractInstanceView): | QtCore.QItemSelectionModel.Rows ) - def set_active_toggle_enabled(self, enabled: bool) -> bool: + def set_active_toggle_enabled(self, enabled: bool) -> None: if self._active_toggle_enabled is enabled: return From 19bafc10d31d35de691c47d8a83b65fbbd5544c9 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:00:43 +0200 Subject: [PATCH 109/319] fix cleanup of removed instances --- .../publisher/widgets/card_view_widgets.py | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 1d2ef9b0d2..b8185fbb3f 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -639,12 +639,7 @@ class InstanceCardView(AbstractInstanceView): ): output.append(self._context_widget) - output.extend( - widget - for widget in self._convertor_widgets_by_id.values() - if widget.is_selected - ) - + output.extend(self._get_selected_convertor_widgets()) output.extend(self._get_selected_instance_widgets()) return output @@ -655,6 +650,13 @@ class InstanceCardView(AbstractInstanceView): if widget.is_selected ] + def _get_selected_convertor_widgets(self) -> list[ConvertorItemCardWidget]: + return [ + widget + for widget in self._convertor_widgets_by_id.values() + if widget.is_selected + ] + def _get_selected_item_ids(self): output = [] if ( @@ -730,6 +732,9 @@ class InstanceCardView(AbstractInstanceView): groups_to_remove = ( set(self._widgets_by_group) - set(instances_by_group) ) + ids_to_remove = ( + set(self._widgets_by_id) - set(instances_by_id) + ) # Sort groups sorted_group_names = list(sorted(instances_by_group.keys())) @@ -780,6 +785,11 @@ class InstanceCardView(AbstractInstanceView): if group_name in self._explicitly_selected_groups: self._explicitly_selected_groups.remove(group_name) + for instance_id in ids_to_remove: + widget = self._widgets_by_id.pop(instance_id) + widget.setVisible(False) + widget.deleteLater() + self._instance_ids_by_parent_id = instance_ids_by_parent_id self._group_name_by_instance_id = group_by_instance_id self._instance_ids_by_group_name = instance_ids_by_group_name @@ -1298,21 +1308,18 @@ class InstanceCardView(AbstractInstanceView): def get_selected_items(self): """Get selected instance ids and context.""" - convertor_identifiers = [] - instances = [] - selected_widgets = self._get_selected_widgets() - - context_selected = False - for widget in selected_widgets: - if widget is self._context_widget: - context_selected = True - - elif isinstance(widget, InstanceCardWidget): - instances.append(widget.id) - - elif isinstance(widget, ConvertorItemCardWidget): - convertor_identifiers.append(widget.identifier) - + context_selected = ( + self._context_widget is not None + and self._context_widget.is_selected + ) + instances = [ + widget.id + for widget in self._get_selected_instance_widgets() + ] + convertor_identifiers = [ + widget.identifier + for widget in self._get_selected_convertor_widgets() + ] return instances, context_selected, convertor_identifiers def set_selected_items( From c4d6723c51e64f14947b095757e4e15750cf0e48 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 30 Jul 2025 16:04:00 +0200 Subject: [PATCH 110/319] formatting fixes --- client/ayon_core/pipeline/create/context.py | 2 +- .../ayon_core/plugins/publish/collect_from_create_context.py | 4 ++-- client/ayon_core/tools/publisher/widgets/card_view_widgets.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index 5e069cd62e..b006924750 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -2629,4 +2629,4 @@ class CreateContext: INSTANCE_PARENT_CHANGED_TOPIC, {"instances": instances}, sender, - ) \ No newline at end of file + ) diff --git a/client/ayon_core/plugins/publish/collect_from_create_context.py b/client/ayon_core/plugins/publish/collect_from_create_context.py index 7b8aeee457..5e0ecbdff4 100644 --- a/client/ayon_core/plugins/publish/collect_from_create_context.py +++ b/client/ayon_core/plugins/publish/collect_from_create_context.py @@ -60,8 +60,8 @@ class CollectFromCreateContext(pyblish.api.ContextPlugin): is_active = created_instance["active"] # Use a parent's active state if parent flags defines that if ( - is_active - and created_instance.parent_flags & ParentFlags.share_active + created_instance.parent_flags & ParentFlags.share_active + and is_active ): is_active = parent_is_active diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index b8185fbb3f..6d95906364 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -792,7 +792,7 @@ class InstanceCardView(AbstractInstanceView): self._instance_ids_by_parent_id = instance_ids_by_parent_id self._group_name_by_instance_id = group_by_instance_id - self._instance_ids_by_group_name = instance_ids_by_group_name + self._instance_ids_by_group_name = instance_ids_by_group_name self._ordered_groups = sorted_group_names def has_items(self) -> bool: From eaf47d8731a9dab98ff38d637984ea2d0837dc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Wed, 30 Jul 2025 18:32:09 +0200 Subject: [PATCH 111/319] :recycle: don't allow duplicate loaders --- client/ayon_core/pipeline/load/plugins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/load/plugins.py b/client/ayon_core/pipeline/load/plugins.py index dc5bb0f66f..48e860e834 100644 --- a/client/ayon_core/pipeline/load/plugins.py +++ b/client/ayon_core/pipeline/load/plugins.py @@ -373,7 +373,7 @@ def discover_loader_plugins(project_name=None): if not project_name: project_name = get_current_project_name() project_settings = get_project_settings(project_name) - plugins = discover(LoaderPlugin) + plugins = discover(LoaderPlugin, allow_duplicates=False) hooks = discover(LoaderHookPlugin) sorted_hooks = sorted(hooks, key=lambda hook: hook.order) for plugin in plugins: From ea3b4524d405f63a698d34bac7d15fafff42831b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:31:46 +0200 Subject: [PATCH 112/319] capture 'ItemNotFoundException' error if possible --- client/ayon_core/lib/local_settings.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 91b881cf57..a582a6c1b9 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -124,6 +124,10 @@ def get_addons_resources_dir(addon_name: str, *args) -> str: return os.path.join(addons_resources_dir, addon_name, *args) +class _FakeException(Exception): + """Placeholder exception used if real exception is not available.""" + + class AYONSecureRegistry: """Store information using keyring. @@ -195,7 +199,17 @@ class AYONSecureRegistry: """ import keyring - value = keyring.get_password(self._name, name) + # Capture 'ItemNotFoundException' exception (on linux) + try: + from secretstorage.exceptions import ItemNotFoundException + except ImportError: + ItemNotFoundException = _FakeException + + try: + value = keyring.get_password(self._name, name) + except ItemNotFoundException: + value = None + if value is not None: return value From 97a3ab142c291ced73aef586bad8e6c3b62d5ab4 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:46:37 +0200 Subject: [PATCH 113/319] raise dedicated exception if item is not available --- client/ayon_core/lib/local_settings.py | 41 +++++++++++++++----------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 91b881cf57..7c6459fad6 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -15,6 +15,11 @@ import ayon_api _PLACEHOLDER = object() +# TODO should use 'KeyError' or 'Exception' as base +class RegistryItemNotFound(ValueError): + """Raised when the item is not found in keyring.""" + + class _Cache: username = None @@ -187,7 +192,7 @@ class AYONSecureRegistry: value (str): Value of the item. Raises: - ValueError: If item doesn't exist and default is not defined. + RegistryItemNotFound: If item doesn't exist and default is not defined. .. _Keyring module: https://github.com/jaraco/keyring @@ -202,9 +207,8 @@ class AYONSecureRegistry: if default is not _PLACEHOLDER: return default - # NOTE Should raise `KeyError` - raise ValueError( - "Item {}:{} does not exist in keyring.".format(self._name, name) + raise RegistryItemNotFound( + f"Item {self._name}:{name} not found in keyring." ) def delete_item(self, name): @@ -277,7 +281,7 @@ class ASettingRegistry(ABC): value (str): Value of the item. Raises: - ValueError: If item doesn't exist. + RegistryItemNotFound: If the item doesn't exist. """ return self._get_item(name) @@ -388,7 +392,7 @@ class IniSettingRegistry(ASettingRegistry): str: Value of item. Raises: - ValueError: If value doesn't exist. + RegistryItemNotFound: If value doesn't exist. """ return super(IniSettingRegistry, self).get_item(name) @@ -399,8 +403,8 @@ class IniSettingRegistry(ASettingRegistry): """Get item from section of ini file. This will read ini file and try to get item value from specified - section. If that section or item doesn't exist, :exc:`ValueError` - is risen. + section. If that section or item doesn't exist, + :exc:`RegistryItemNotFound` is risen. Args: section (str): Name of ini section. @@ -410,7 +414,7 @@ class IniSettingRegistry(ASettingRegistry): str: Item value. Raises: - ValueError: If value doesn't exist. + RegistryItemNotFound: If value doesn't exist. """ config = configparser.ConfigParser() @@ -418,8 +422,9 @@ class IniSettingRegistry(ASettingRegistry): try: value = config[section][name] except KeyError: - raise ValueError( - "Registry doesn't contain value {}:{}".format(section, name)) + raise RegistryItemNotFound( + f"Registry doesn't contain value {section}:{name}" + ) return value def _get_item(self, name): @@ -435,7 +440,7 @@ class IniSettingRegistry(ASettingRegistry): name (str): Name of the item. Raises: - ValueError: If item doesn't exist. + RegistryItemNotFound: If the item doesn't exist. """ self.get_item_from_section.cache_clear() @@ -444,8 +449,9 @@ class IniSettingRegistry(ASettingRegistry): try: _ = config[section][name] except KeyError: - raise ValueError( - "Registry doesn't contain value {}:{}".format(section, name)) + raise RegistryItemNotFound( + f"Registry doesn't contain value {section}:{name}" + ) config.remove_option(section, name) # if section is empty, delete it @@ -494,8 +500,9 @@ class JSONSettingRegistry(ASettingRegistry): try: value = data["registry"][name] except KeyError: - raise ValueError( - "Registry doesn't contain value {}".format(name)) + raise RegistryItemNotFound( + f"Registry doesn't contain value {name}" + ) return value def get_item(self, name): @@ -509,7 +516,7 @@ class JSONSettingRegistry(ASettingRegistry): value of the item Raises: - ValueError: If item is not found in registry file. + RegistryItemNotFound: If the item is not found in registry file. """ return self._get_item(name) From 88b01a2797c39e9b19d5808f475c3ecb49ce885f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:54:26 +0200 Subject: [PATCH 114/319] added type-hints --- client/ayon_core/lib/local_settings.py | 101 ++++++++++--------------- 1 file changed, 38 insertions(+), 63 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 7c6459fad6..19ffffd63f 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -8,6 +8,7 @@ import warnings from datetime import datetime from abc import ABC, abstractmethod from functools import lru_cache +from typing import Optional, Any import platformdirs import ayon_api @@ -24,14 +25,14 @@ class _Cache: username = None -def _get_ayon_appdirs(*args): +def _get_ayon_appdirs(*args: str) -> str: return os.path.join( platformdirs.user_data_dir("AYON", "Ynput"), *args ) -def get_ayon_appdirs(*args): +def get_ayon_appdirs(*args: str) -> str: """Local app data directory of AYON client. Deprecated: @@ -141,7 +142,7 @@ class AYONSecureRegistry: Args: name(str): Name of registry used as identifier for data. """ - def __init__(self, name): + def __init__(self, name: str) -> None: try: import keyring @@ -159,8 +160,7 @@ class AYONSecureRegistry: # Force "AYON" prefix self._name = "/".join(("AYON", name)) - def set_item(self, name, value): - # type: (str, str) -> None + def set_item(self, name: str, value: str) -> None: """Set sensitive item into system's keyring. This uses `Keyring module`_ to save sensitive stuff into system's @@ -179,7 +179,9 @@ class AYONSecureRegistry: keyring.set_password(self._name, name, value) @lru_cache(maxsize=32) - def get_item(self, name, default=_PLACEHOLDER): + def get_item( + self, name: str, default: Any = _PLACEHOLDER + ) -> Optional[str]: """Get value of sensitive item from system's keyring. See also `Keyring module`_ @@ -211,8 +213,7 @@ class AYONSecureRegistry: f"Item {self._name}:{name} not found in keyring." ) - def delete_item(self, name): - # type: (str) -> None + def delete_item(self, name: str) -> None: """Delete value stored in system's keyring. See also `Keyring module`_ @@ -241,16 +242,13 @@ class ASettingRegistry(ABC): _name (str): Registry names. """ - - def __init__(self, name): - # type: (str) -> ASettingRegistry + def __init__(self, name: str) -> None: super(ASettingRegistry, self).__init__() self._name = name self._items = {} - def set_item(self, name, value): - # type: (str, str) -> None + def set_item(self, name: str, value: str) -> None: """Set item to settings registry. Args: @@ -261,17 +259,14 @@ class ASettingRegistry(ABC): self._set_item(name, value) @abstractmethod - def _set_item(self, name, value): - # type: (str, str) -> None - # Implement it - pass + def _set_item(self, name: str, value: str) -> None: + """Set item value to registry.""" - def __setitem__(self, name, value): + def __setitem__(self, name: str, value: str) -> None: self._items[name] = value self._set_item(name, value) - def get_item(self, name): - # type: (str) -> str + def get_item(self, name: str) -> str: """Get item from settings registry. Args: @@ -287,16 +282,13 @@ class ASettingRegistry(ABC): return self._get_item(name) @abstractmethod - def _get_item(self, name): - # type: (str) -> str - # Implement it - pass + def _get_item(self, name: str) -> str: + """Get item value from registry.""" - def __getitem__(self, name): + def __getitem__(self, name: str) -> Any: return self._get_item(name) - def delete_item(self, name): - # type: (str) -> None + def delete_item(self, name: str) -> None: """Delete item from settings registry. Args: @@ -306,12 +298,10 @@ class ASettingRegistry(ABC): self._delete_item(name) @abstractmethod - def _delete_item(self, name): - # type: (str) -> None - """Delete item from settings.""" - pass + def _delete_item(self, name: str) -> None: + """Delete item from registry.""" - def __delitem__(self, name): + def __delitem__(self, name: str) -> None: del self._items[name] self._delete_item(name) @@ -322,9 +312,7 @@ class IniSettingRegistry(ASettingRegistry): This class is using :mod:`configparser` (ini) files to store items. """ - - def __init__(self, name, path): - # type: (str, str) -> IniSettingRegistry + def __init__(self, name: str, path: str) -> None: super(IniSettingRegistry, self).__init__(name) # get registry file self._registry_file = os.path.join(path, "{}.ini".format(name)) @@ -334,8 +322,7 @@ class IniSettingRegistry(ASettingRegistry): now = datetime.now().strftime("%d/%m/%Y %H:%M:%S") print("# {}".format(now), cfg) - def set_item_section(self, section, name, value): - # type: (str, str, str) -> None + def set_item_section(self, section: str, name: str, value: str) -> None: """Set item to specific section of ini registry. If section doesn't exists, it is created. @@ -358,12 +345,10 @@ class IniSettingRegistry(ASettingRegistry): with open(self._registry_file, mode="w") as cfg: config.write(cfg) - def _set_item(self, name, value): - # type: (str, str) -> None + def _set_item(self, name: str, value: str) -> None: self.set_item_section("MAIN", name, value) - def set_item(self, name, value): - # type: (str, str) -> None + def set_item(self, name: str, value: str) -> None: """Set item to settings ini file. This saves item to ``DEFAULT`` section of ini as each item there @@ -378,8 +363,7 @@ class IniSettingRegistry(ASettingRegistry): # we cast value to str as ini options values must be strings. super(IniSettingRegistry, self).set_item(name, str(value)) - def get_item(self, name): - # type: (str) -> str + def get_item(self, name: str) -> str: """Gets item from settings ini file. This gets settings from ``DEFAULT`` section of ini file as each item @@ -398,8 +382,7 @@ class IniSettingRegistry(ASettingRegistry): return super(IniSettingRegistry, self).get_item(name) @lru_cache(maxsize=32) - def get_item_from_section(self, section, name): - # type: (str, str) -> str + def get_item_from_section(self, section: str, name: str) -> str: """Get item from section of ini file. This will read ini file and try to get item value from specified @@ -427,12 +410,10 @@ class IniSettingRegistry(ASettingRegistry): ) return value - def _get_item(self, name): - # type: (str) -> str + def _get_item(self, name: str) -> str: return self.get_item_from_section("MAIN", name) - def delete_item_from_section(self, section, name): - # type: (str, str) -> None + def delete_item_from_section(self, section: str, name: str) -> None: """Delete item from section in ini file. Args: @@ -469,8 +450,7 @@ class IniSettingRegistry(ASettingRegistry): class JSONSettingRegistry(ASettingRegistry): """Class using json file as storage.""" - def __init__(self, name, path): - # type: (str, str) -> JSONSettingRegistry + def __init__(self, name: str, path: str) -> None: super(JSONSettingRegistry, self).__init__(name) #: str: name of registry file self._registry_file = os.path.join(path, "{}.json".format(name)) @@ -487,8 +467,7 @@ class JSONSettingRegistry(ASettingRegistry): json.dump(header, cfg, indent=4) @lru_cache(maxsize=32) - def _get_item(self, name): - # type: (str) -> object + def _get_item(self, name: str) -> Any: """Get item value from registry json. Note: @@ -505,8 +484,7 @@ class JSONSettingRegistry(ASettingRegistry): ) return value - def get_item(self, name): - # type: (str) -> object + def get_item(self, name: str) -> Any: """Get item value from registry json. Args: @@ -521,8 +499,7 @@ class JSONSettingRegistry(ASettingRegistry): """ return self._get_item(name) - def _set_item(self, name, value): - # type: (str, object) -> None + def _set_item(self, name: str, value: Any) -> None: """Set item value to registry json. Note: @@ -536,8 +513,7 @@ class JSONSettingRegistry(ASettingRegistry): cfg.seek(0) json.dump(data, cfg, indent=4) - def set_item(self, name, value): - # type: (str, object) -> None + def set_item(self, name: str, value: Any) -> None: """Set item and its value into json registry file. Args: @@ -547,8 +523,7 @@ class JSONSettingRegistry(ASettingRegistry): """ self._set_item(name, value) - def _delete_item(self, name): - # type: (str) -> None + def _delete_item(self, name: str) -> None: self._get_item.cache_clear() with open(self._registry_file, "r+") as cfg: data = json.load(cfg) @@ -563,9 +538,9 @@ class AYONSettingsRegistry(JSONSettingRegistry): Args: name (Optional[str]): Name of the registry. - """ - def __init__(self, name=None): + """ + def __init__(self, name: Optional[str] = None) -> None: if not name: name = "AYON_settings" path = get_launcher_storage_dir() From d431956963c55bb60405142649efd636011b89ca Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:55:34 +0200 Subject: [PATCH 115/319] simplified super calls --- client/ayon_core/lib/local_settings.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 19ffffd63f..26db587835 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -243,7 +243,7 @@ class ASettingRegistry(ABC): """ def __init__(self, name: str) -> None: - super(ASettingRegistry, self).__init__() + super().__init__() self._name = name self._items = {} @@ -313,7 +313,7 @@ class IniSettingRegistry(ASettingRegistry): """ def __init__(self, name: str, path: str) -> None: - super(IniSettingRegistry, self).__init__(name) + super().__init__(name) # get registry file self._registry_file = os.path.join(path, "{}.ini".format(name)) if not os.path.exists(self._registry_file): @@ -361,7 +361,7 @@ class IniSettingRegistry(ASettingRegistry): """ # this does the some, overridden just for different docstring. # we cast value to str as ini options values must be strings. - super(IniSettingRegistry, self).set_item(name, str(value)) + super().set_item(name, str(value)) def get_item(self, name: str) -> str: """Gets item from settings ini file. @@ -379,7 +379,7 @@ class IniSettingRegistry(ASettingRegistry): RegistryItemNotFound: If value doesn't exist. """ - return super(IniSettingRegistry, self).get_item(name) + return super().get_item(name) @lru_cache(maxsize=32) def get_item_from_section(self, section: str, name: str) -> str: @@ -451,7 +451,7 @@ class JSONSettingRegistry(ASettingRegistry): """Class using json file as storage.""" def __init__(self, name: str, path: str) -> None: - super(JSONSettingRegistry, self).__init__(name) + super().__init__(name) #: str: name of registry file self._registry_file = os.path.join(path, "{}.json".format(name)) now = datetime.now().strftime("%d/%m/%Y %H:%M:%S") @@ -544,7 +544,7 @@ class AYONSettingsRegistry(JSONSettingRegistry): if not name: name = "AYON_settings" path = get_launcher_storage_dir() - super(AYONSettingsRegistry, self).__init__(name, path) + super().__init__(name, path) def get_local_site_id(): From 08c242edefe4b11046a589fca10a7e8e7f969177 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:55:59 +0200 Subject: [PATCH 116/319] use f-strings --- client/ayon_core/lib/local_settings.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 26db587835..36abeb4283 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -158,7 +158,7 @@ class AYONSecureRegistry: keyring.set_keyring(Windows.WinVaultKeyring()) # Force "AYON" prefix - self._name = "/".join(("AYON", name)) + self._name = f"AYON/{name}" def set_item(self, name: str, value: str) -> None: """Set sensitive item into system's keyring. @@ -315,12 +315,12 @@ class IniSettingRegistry(ASettingRegistry): def __init__(self, name: str, path: str) -> None: super().__init__(name) # get registry file - self._registry_file = os.path.join(path, "{}.ini".format(name)) + self._registry_file = os.path.join(path, f"{name}.ini") if not os.path.exists(self._registry_file): with open(self._registry_file, mode="w") as cfg: print("# Settings registry", cfg) now = datetime.now().strftime("%d/%m/%Y %H:%M:%S") - print("# {}".format(now), cfg) + print(f"# {now}", cfg) def set_item_section(self, section: str, name: str, value: str) -> None: """Set item to specific section of ini registry. @@ -452,8 +452,7 @@ class JSONSettingRegistry(ASettingRegistry): def __init__(self, name: str, path: str) -> None: super().__init__(name) - #: str: name of registry file - self._registry_file = os.path.join(path, "{}.json".format(name)) + self._registry_file = os.path.join(path, f"{name}.json") now = datetime.now().strftime("%d/%m/%Y %H:%M:%S") header = { "__metadata__": {"generated": now}, From d1fce584fa577d209feff5c91867eda12399acec Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:56:25 +0200 Subject: [PATCH 117/319] remove unncessary variable --- client/ayon_core/lib/local_settings.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 36abeb4283..a52539a4dd 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -238,15 +238,11 @@ class ASettingRegistry(ABC): mechanism for storing common items must be implemented in abstract methods. - Attributes: - _name (str): Registry names. - """ def __init__(self, name: str) -> None: super().__init__() self._name = name - self._items = {} def set_item(self, name: str, value: str) -> None: """Set item to settings registry. @@ -263,7 +259,6 @@ class ASettingRegistry(ABC): """Set item value to registry.""" def __setitem__(self, name: str, value: str) -> None: - self._items[name] = value self._set_item(name, value) def get_item(self, name: str) -> str: @@ -302,7 +297,6 @@ class ASettingRegistry(ABC): """Delete item from registry.""" def __delitem__(self, name: str) -> None: - del self._items[name] self._delete_item(name) From d88a8678729fc2e51c9e49e7f798499e5e74cdcd Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:56:39 +0200 Subject: [PATCH 118/319] reset cache on set item --- client/ayon_core/lib/local_settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index a52539a4dd..162e17fd94 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -177,6 +177,7 @@ class AYONSecureRegistry: import keyring keyring.set_password(self._name, name, value) + self.get_item.cache_clear() @lru_cache(maxsize=32) def get_item( From 41228915eca2c0b29fdc7d7c5eb208ecda0fd568 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:58:08 +0200 Subject: [PATCH 119/319] more explicit dir creation --- client/ayon_core/lib/local_settings.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 162e17fd94..98eec3af4f 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -454,8 +454,10 @@ class JSONSettingRegistry(ASettingRegistry): "registry": {} } - if not os.path.exists(os.path.dirname(self._registry_file)): - os.makedirs(os.path.dirname(self._registry_file), exist_ok=True) + # Use 'os.path.dirname' in case someone uses slashes in 'name' + dirpath = os.path.dirname(self._registry_file) + if not os.path.exists(dirpath): + os.makedirs(dirpath, exist_ok=True) if not os.path.exists(self._registry_file): with open(self._registry_file, mode="w") as cfg: json.dump(header, cfg, indent=4) From 2013eea5c4cc52942f79c371032f7c9b6126870a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:58:21 +0200 Subject: [PATCH 120/319] formatting change --- client/ayon_core/lib/local_settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 98eec3af4f..b06b890992 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -141,6 +141,7 @@ class AYONSecureRegistry: Args: name(str): Name of registry used as identifier for data. + """ def __init__(self, name: str) -> None: try: From 1a46f2c027b60e03ac35a25d231bf034042bcb1c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:00:51 +0200 Subject: [PATCH 121/319] remove unnecessary super call --- client/ayon_core/lib/local_settings.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index b06b890992..79e0e24307 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -242,8 +242,6 @@ class ASettingRegistry(ABC): """ def __init__(self, name: str) -> None: - super().__init__() - self._name = name def set_item(self, name: str, value: str) -> None: From b403db76e6626b450dad91d489e20bc997284746 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:01:52 +0200 Subject: [PATCH 122/319] better order of methods --- client/ayon_core/lib/local_settings.py | 46 ++++++++++++++------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 79e0e24307..4b85a76b2d 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -244,23 +244,31 @@ class ASettingRegistry(ABC): def __init__(self, name: str) -> None: self._name = name - def set_item(self, name: str, value: str) -> None: - """Set item to settings registry. - - Args: - name (str): Name of the item. - value (str): Value of the item. - - """ - self._set_item(name, value) + @abstractmethod + def _get_item(self, name: str) -> Any: + """Get item value from registry.""" @abstractmethod def _set_item(self, name: str, value: str) -> None: """Set item value to registry.""" + @abstractmethod + def _delete_item(self, name: str) -> None: + """Delete item from registry.""" + + def __getitem__(self, name: str) -> Any: + return self._get_item(name) + def __setitem__(self, name: str, value: str) -> None: self._set_item(name, value) + def __delitem__(self, name: str) -> None: + self._delete_item(name) + + @property + def name(self) -> str: + return self._name + def get_item(self, name: str) -> str: """Get item from settings registry. @@ -276,12 +284,15 @@ class ASettingRegistry(ABC): """ return self._get_item(name) - @abstractmethod - def _get_item(self, name: str) -> str: - """Get item value from registry.""" + def set_item(self, name: str, value: str) -> None: + """Set item to settings registry. - def __getitem__(self, name: str) -> Any: - return self._get_item(name) + Args: + name (str): Name of the item. + value (str): Value of the item. + + """ + self._set_item(name, value) def delete_item(self, name: str) -> None: """Delete item from settings registry. @@ -292,13 +303,6 @@ class ASettingRegistry(ABC): """ self._delete_item(name) - @abstractmethod - def _delete_item(self, name: str) -> None: - """Delete item from registry.""" - - def __delitem__(self, name: str) -> None: - self._delete_item(name) - class IniSettingRegistry(ASettingRegistry): """Class using :mod:`configparser`. From d4092c8e314eb5e02cf004e07ac8a5f69f39a36c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:02:12 +0200 Subject: [PATCH 123/319] deprecated not passed name in 'AYONSettingsRegistry' --- client/ayon_core/lib/local_settings.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 4b85a76b2d..8511c8d15e 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -536,12 +536,21 @@ class AYONSettingsRegistry(JSONSettingRegistry): """Class handling AYON general settings registry. Args: - name (Optional[str]): Name of the registry. + name (Optional[str]): Name of the registry. Using 'None' or not + passing name is deprecated. """ def __init__(self, name: Optional[str] = None) -> None: if not name: name = "AYON_settings" + warnings.warn( + ( + "Used 'AYONSettingsRegistry' without 'name' argument." + " The argument will be required in future versions." + ), + DeprecationWarning, + stacklevel=2, + ) path = get_launcher_storage_dir() super().__init__(name, path) From 473cf8b0c13f19d4763d2d9bea4f0b376ca85f77 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:19:39 +0200 Subject: [PATCH 124/319] grammar fixes --- client/ayon_core/lib/local_settings.py | 37 +++++++++++++------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 8511c8d15e..19381b18e0 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -18,7 +18,7 @@ _PLACEHOLDER = object() # TODO should use 'KeyError' or 'Exception' as base class RegistryItemNotFound(ValueError): - """Raised when the item is not found in keyring.""" + """Raised when the item is not found in the keyring.""" class _Cache: @@ -37,10 +37,10 @@ def get_ayon_appdirs(*args: str) -> str: Deprecated: Use 'get_launcher_local_dir' or 'get_launcher_storage_dir' based on - use-case. Deprecation added 24/08/09 (0.4.4-dev.1). + a use-case. Deprecation added 24/08/09 (0.4.4-dev.1). Args: - *args (Iterable[str]): Subdirectories/files in local app data dir. + *args (Iterable[str]): Subdirectories/files in the local app data dir. Returns: str: Path to directory/file in local app data dir. @@ -58,7 +58,7 @@ def get_ayon_appdirs(*args: str) -> str: def get_launcher_storage_dir(*subdirs: str) -> str: - """Get storage directory for launcher. + """Get a storage directory for launcher. Storage directory is used for storing shims, addons, dependencies, etc. @@ -83,14 +83,14 @@ def get_launcher_storage_dir(*subdirs: str) -> str: def get_launcher_local_dir(*subdirs: str) -> str: - """Get local directory for launcher. + """Get a local directory for launcher. - Local directory is used for storing machine or user specific data. + Local directory is used for storing machine or user-specific data. - The location is user specific. + The location is user-specific. Note: - This function should be called at least once on bootstrap. + This function should be called at least once on the bootstrap. Args: *subdirs (str): Subdirectories relative to local dir. @@ -107,7 +107,7 @@ def get_launcher_local_dir(*subdirs: str) -> str: def get_addons_resources_dir(addon_name: str, *args) -> str: - """Get directory for storing resources for addons. + """Get a directory for storing resources for addons. Some addons might need to store ad-hoc resources that are not part of addon client package (e.g. because of size). Studio might define @@ -117,7 +117,7 @@ def get_addons_resources_dir(addon_name: str, *args) -> str: Args: addon_name (str): Addon name. - *args (str): Subfolders in resources directory. + *args (str): Subfolders in the resources directory. Returns: str: Path to resources directory. @@ -140,7 +140,7 @@ class AYONSecureRegistry: identify which data were created by AYON. Args: - name(str): Name of registry used as identifier for data. + name(str): Name of registry used as the identifier for data. """ def __init__(self, name: str) -> None: @@ -162,9 +162,9 @@ class AYONSecureRegistry: self._name = f"AYON/{name}" def set_item(self, name: str, value: str) -> None: - """Set sensitive item into system's keyring. + """Set sensitive item into the system's keyring. - This uses `Keyring module`_ to save sensitive stuff into system's + This uses `Keyring module`_ to save sensitive stuff into the system's keyring. Args: @@ -184,19 +184,20 @@ class AYONSecureRegistry: def get_item( self, name: str, default: Any = _PLACEHOLDER ) -> Optional[str]: - """Get value of sensitive item from system's keyring. + """Get value of sensitive item from the system's keyring. See also `Keyring module`_ Args: name (str): Name of the item. - default (Any): Default value if item is not available. + default (Any): Default value if the item is not available. Returns: value (str): Value of the item. Raises: - RegistryItemNotFound: If item doesn't exist and default is not defined. + RegistryItemNotFound: If the item doesn't exist and default + is not defined. .. _Keyring module: https://github.com/jaraco/keyring @@ -216,7 +217,7 @@ class AYONSecureRegistry: ) def delete_item(self, name: str) -> None: - """Delete value stored in system's keyring. + """Delete value stored in the system's keyring. See also `Keyring module`_ @@ -446,7 +447,7 @@ class IniSettingRegistry(ASettingRegistry): class JSONSettingRegistry(ASettingRegistry): - """Class using json file as storage.""" + """Class using a json file as storage.""" def __init__(self, name: str, path: str) -> None: super().__init__(name) From 3c867c517c4773b75aae84d049a1edf5e8323512 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:20:08 +0200 Subject: [PATCH 125/319] change value of json registry to 'str' --- client/ayon_core/lib/local_settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 19381b18e0..09855c6075 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -467,8 +467,8 @@ class JSONSettingRegistry(ASettingRegistry): json.dump(header, cfg, indent=4) @lru_cache(maxsize=32) - def _get_item(self, name: str) -> Any: - """Get item value from registry json. + def _get_item(self, name: str) -> str: + """Get item value from the registry. Note: See :meth:`ayon_core.lib.JSONSettingRegistry.get_item` @@ -499,8 +499,8 @@ class JSONSettingRegistry(ASettingRegistry): """ return self._get_item(name) - def _set_item(self, name: str, value: Any) -> None: - """Set item value to registry json. + def _set_item(self, name: str, value: str) -> None: + """Set item value to the registry. Note: See :meth:`ayon_core.lib.JSONSettingRegistry.set_item` From 6433ada42c78a586899c9329b91838a5ade936e7 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:20:50 +0200 Subject: [PATCH 126/319] remove unnecessary overriden methods --- client/ayon_core/lib/local_settings.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 09855c6075..7982a2797e 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -484,21 +484,6 @@ class JSONSettingRegistry(ASettingRegistry): ) return value - def get_item(self, name: str) -> Any: - """Get item value from registry json. - - Args: - name (str): Name of the item. - - Returns: - value of the item - - Raises: - RegistryItemNotFound: If the item is not found in registry file. - - """ - return self._get_item(name) - def _set_item(self, name: str, value: str) -> None: """Set item value to the registry. @@ -513,18 +498,7 @@ class JSONSettingRegistry(ASettingRegistry): cfg.seek(0) json.dump(data, cfg, indent=4) - def set_item(self, name: str, value: Any) -> None: - """Set item and its value into json registry file. - - Args: - name (str): name of the item. - value (Any): value of the item. - - """ - self._set_item(name, value) - def _delete_item(self, name: str) -> None: - self._get_item.cache_clear() with open(self._registry_file, "r+") as cfg: data = json.load(cfg) del data["registry"][name] From 83b109be28602958e1fa0b666fc3e10188ad7cae Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:21:11 +0200 Subject: [PATCH 127/319] fix cache again --- client/ayon_core/lib/local_settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 7982a2797e..4cfe059e2a 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -497,6 +497,7 @@ class JSONSettingRegistry(ASettingRegistry): cfg.truncate(0) cfg.seek(0) json.dump(data, cfg, indent=4) + self._get_item.cache_clear() def _delete_item(self, name: str) -> None: with open(self._registry_file, "r+") as cfg: @@ -505,6 +506,7 @@ class JSONSettingRegistry(ASettingRegistry): cfg.truncate(0) cfg.seek(0) json.dump(data, cfg, indent=4) + self._get_item.cache_clear() class AYONSettingsRegistry(JSONSettingRegistry): From 1017becebd118f5cdd3bd021ed7fbe5891bf954e Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:21:26 +0200 Subject: [PATCH 128/319] changed abstract class docstring --- client/ayon_core/lib/local_settings.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 4cfe059e2a..85ece54d6f 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -235,11 +235,7 @@ class AYONSecureRegistry: class ASettingRegistry(ABC): - """Abstract class defining structure of **SettingRegistry** class. - - It is implementing methods to store secure items into keyring, otherwise - mechanism for storing common items must be implemented in abstract - methods. + """Abstract class to defining structure of registry class. """ def __init__(self, name: str) -> None: From 47af183d04f82ccc5d27af20143ee03ddf8eeb49 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:12:00 +0200 Subject: [PATCH 129/319] check for availability that don't live in workdir --- client/ayon_core/host/interfaces/workfiles.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index b6c33337e9..693aac5fe5 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -1155,12 +1155,15 @@ class IWorkfileHost: comment = parsed_data.comment filepath = list_workfiles_context.anatomy.fill_root(rootless_path) + available = False + if filepath != rootless_path: + available = os.path.exists(filepath) items.append(WorkfileInfo.new( filepath, rootless_path, version=version, comment=comment, - available=False, + available=available, workfile_entity=workfile_entity, )) From 4f296e0ed78138cef63791605c40e1a6b82e7ebf Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:41:33 +0200 Subject: [PATCH 130/319] simplified --- client/ayon_core/host/interfaces/workfiles.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index 693aac5fe5..14e60bda20 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -1155,9 +1155,7 @@ class IWorkfileHost: comment = parsed_data.comment filepath = list_workfiles_context.anatomy.fill_root(rootless_path) - available = False - if filepath != rootless_path: - available = os.path.exists(filepath) + available = os.path.exists(filepath) items.append(WorkfileInfo.new( filepath, rootless_path, From a85cf5d2e907c13dc19d1818231fc28ba0829000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Thu, 31 Jul 2025 15:41:47 +0200 Subject: [PATCH 131/319] :recycle: handle more link types --- .../workfile/workfile_template_builder.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index 6b82e3b04d..7920abb23f 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -201,14 +201,6 @@ class AbstractTemplateBuilder(ABC): ) return self._current_folder_entity - @property - def linked_folder_entities(self): - if self._linked_folder_entities is _NOT_SET: - self._linked_folder_entities = self._get_linked_folder_entities( - link_type="template" - ) - return self._linked_folder_entities - @property def current_task_entity(self): if self._current_task_entity is _NOT_SET: @@ -309,7 +301,7 @@ class AbstractTemplateBuilder(ABC): self._loaders_by_name = get_loaders_by_name() return self._loaders_by_name - def _get_linked_folder_entities(self, link_type: str = "template"): + def get_linked_folder_entities(self, link_type: str = "template"): project_name = self.project_name folder_entity = self.current_folder_entity if not folder_entity: @@ -1642,6 +1634,8 @@ class PlaceholderLoadMixin(object): folder_ids = [current_folder_entity["id"]] elif builder_type == "linked_folders": + # link type from placeholder data or default to "template" + link_type = placeholder.data.get("link_type", "template") # Get all linked folders for the current folder if hasattr(self, "builder") and isinstance( self.builder, AbstractTemplateBuilder): @@ -1649,7 +1643,8 @@ class PlaceholderLoadMixin(object): folder_ids = [ linked_folder_entity["id"] for linked_folder_entity in ( - self.builder.linked_folder_entities) + self.builder.get_linked_folder_entities( + link_type=link_type)) ] if not folder_ids: From b247762806f3e9f4dfa38afdb812d3da461d34d8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 16:44:02 +0200 Subject: [PATCH 132/319] make 'get_plugin_paths' optional --- client/ayon_core/addon/interfaces.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/addon/interfaces.py b/client/ayon_core/addon/interfaces.py index 232c056fb4..b0f2d25c08 100644 --- a/client/ayon_core/addon/interfaces.py +++ b/client/ayon_core/addon/interfaces.py @@ -48,14 +48,23 @@ class IPluginPaths(AYONInterface): } """ - @abstractmethod def get_plugin_paths(self) -> dict[str, list[str]]: """Return plugin paths for addon. + This method was abstract (required) in the past, so raise the required + 'core' addon version when 'get_plugin_paths' is removed from + addon. + + Deprecated: + Please implement specific methods 'get_create_plugin_paths', + 'get_load_plugin_paths', 'get_inventory_action_paths' and + 'get_publish_plugin_paths' to return plugin paths. + Returns: dict[str, list[str]]: Plugin paths for addon. """ + return {} def _get_plugin_paths_by_type( self, plugin_type: str) -> list[str]: From 67f039bf5dc102b3da3c97e1010efe0639745a84 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 16:44:36 +0200 Subject: [PATCH 133/319] warn about using deprecated method --- client/ayon_core/addon/interfaces.py | 29 ++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/addon/interfaces.py b/client/ayon_core/addon/interfaces.py index b0f2d25c08..010a5aaca1 100644 --- a/client/ayon_core/addon/interfaces.py +++ b/client/ayon_core/addon/interfaces.py @@ -1,6 +1,7 @@ """Addon interfaces for AYON.""" from __future__ import annotations +import warnings from abc import ABCMeta, abstractmethod from typing import TYPE_CHECKING, Callable, Optional, Type @@ -39,14 +40,7 @@ class AYONInterface(metaclass=_AYONInterfaceMeta): class IPluginPaths(AYONInterface): - """Addon has plugin paths to return. - - Expected result is dictionary with keys "publish", "create", "load", - "actions" or "inventory" and values as list or string. - { - "publish": ["path/to/publish_plugins"] - } - """ + """Addon wants to register plugin paths.""" def get_plugin_paths(self) -> dict[str, list[str]]: """Return plugin paths for addon. @@ -87,6 +81,25 @@ class IPluginPaths(AYONInterface): if not isinstance(paths, (list, tuple, set)): paths = [paths] + + new_function_name = "get_launcher_action_paths" + if plugin_type == "create": + new_function_name = "get_create_plugin_paths" + elif plugin_type == "load": + new_function_name = "get_load_plugin_paths" + elif plugin_type == "publish": + new_function_name = "get_publish_plugin_paths" + elif plugin_type == "inventory": + new_function_name = "get_inventory_action_paths" + + warnings.warn( + f"Addon '{self.name}' returns '{plugin_type}' paths using" + " 'get_plugin_paths' method. Please implement" + f" '{new_function_name}' instead.", + DeprecationWarning, + stacklevel=2 + + ) return paths def get_launcher_action_paths(self) -> list[str]: From 487b5dda98a3ff19084d0c6143de7da0708209b5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 16:44:45 +0200 Subject: [PATCH 134/319] small formatting change --- client/ayon_core/addon/interfaces.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/addon/interfaces.py b/client/ayon_core/addon/interfaces.py index 010a5aaca1..9f2a14a264 100644 --- a/client/ayon_core/addon/interfaces.py +++ b/client/ayon_core/addon/interfaces.py @@ -61,7 +61,8 @@ class IPluginPaths(AYONInterface): return {} def _get_plugin_paths_by_type( - self, plugin_type: str) -> list[str]: + self, plugin_type: str + ) -> list[str]: """Get plugin paths by type. Args: From ba4412577bafaf5e759e39d942133d03a7a0392b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 16:45:12 +0200 Subject: [PATCH 135/319] mark 'collect_plugin_paths' as deprecated --- client/ayon_core/addon/base.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index 72270fa585..80e1ceaa1e 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -8,6 +8,7 @@ import inspect import logging import threading import collections +import warnings from uuid import uuid4 from abc import ABC, abstractmethod from typing import Optional @@ -815,10 +816,26 @@ class AddonsManager: Unknown keys are logged out. + Deprecated: + Use targeted methods 'collect_launcher_action_paths', + 'collect_create_plugin_paths', 'collect_load_plugin_paths', + 'collect_publish_plugin_paths' and + 'collect_inventory_action_paths' to collect plugin paths. + Returns: dict: Output is dictionary with keys "publish", "create", "load", "actions" and "inventory" each containing list of paths. + """ + warnings.warn( + "Used deprecated method 'collect_plugin_paths'. Please use" + " targeted methods 'collect_launcher_action_paths'," + " 'collect_create_plugin_paths', 'collect_load_plugin_paths'" + " 'collect_publish_plugin_paths' and" + " 'collect_inventory_action_paths'", + DeprecationWarning, + stacklevel=2 + ) # Output structure output = { "publish": [], From 5e8dece22e2fbae722f83f45d74d30cad04708cf Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 16:46:03 +0200 Subject: [PATCH 136/319] warn about having string as output from plugin getter method --- client/ayon_core/addon/base.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index 80e1ceaa1e..57968b0e09 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -891,24 +891,28 @@ class AddonsManager: if not isinstance(addon, IPluginPaths): continue + paths = None method = getattr(addon, method_name) try: paths = method(*args, **kwargs) except Exception: self.log.warning( - ( - "Failed to get plugin paths from addon" - " '{}' using '{}'." - ).format(addon.__class__.__name__, method_name), + "Failed to get plugin paths from addon" + f" '{addon.name}' using '{method_name}'.", exc_info=True ) + + if not paths: continue - if paths: - # Convert to list if value is not list - if not isinstance(paths, (list, tuple, set)): - paths = [paths] - output.extend(paths) + if isinstance(paths, str): + paths = [paths] + self.log.warning( + f"Addon '{addon.name}' returned invalid output type" + f" from '{method_name}'." + f" Got 'str' expected 'list[str]'." + ) + output.extend(paths) return output def collect_launcher_action_paths(self): From 2ee875b90b98cc501f9887867ab090b053b03038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Thu, 31 Jul 2025 17:17:44 +0200 Subject: [PATCH 137/319] :recycle: remove defaults --- .../ayon_core/pipeline/workfile/workfile_template_builder.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index 7920abb23f..7b20747768 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -301,7 +301,7 @@ class AbstractTemplateBuilder(ABC): self._loaders_by_name = get_loaders_by_name() return self._loaders_by_name - def get_linked_folder_entities(self, link_type: str = "template"): + def get_linked_folder_entities(self, link_type: str): project_name = self.project_name folder_entity = self.current_folder_entity if not folder_entity: @@ -1466,7 +1466,6 @@ class PlaceholderLoadMixin(object): attribute_definitions.EnumDef( "link_type", label="Link Type", - default="template", items=link_types_enum_item, tooltip=( "Link Type\n" From 5fa11b24e4bb0b165b67cd779d0e8c25ed8a2984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Thu, 31 Jul 2025 17:21:21 +0200 Subject: [PATCH 138/319] :recycle: limit link types to folder <-> folder --- .../workfile/workfile_template_builder.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index 7b20747768..6a36fd12e4 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -1430,11 +1430,21 @@ class PlaceholderLoadMixin(object): link_types = ayon_api.get_link_types(self.builder.project_name) - link_types_enum_item = [ + # Filter link types for folder to folder links + link_types_enum_items = [ {"label": link_type["name"], "value": link_type["linkType"]} for link_type in link_types - + if ( + link_type["inputType"] == "folder" + and link_type["outputType"] == "folder" + ) ] + + if not link_types_enum_items: + link_types_enum_items.append( + {"label": "", "value": None} + ) + build_type_label = "Folder Builder Type" build_type_help = ( "Folder Builder Type\n" @@ -1466,7 +1476,7 @@ class PlaceholderLoadMixin(object): attribute_definitions.EnumDef( "link_type", label="Link Type", - items=link_types_enum_item, + items=link_types_enum_items, tooltip=( "Link Type\n" "\nDefines what type of link will be used to" From 8e2f33d483791c606cdbc4230e04be2ad88f6889 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 1 Aug 2025 11:23:44 +0200 Subject: [PATCH 139/319] use filepath instead of rootless path for workfile entity mapping --- client/ayon_core/host/interfaces/workfiles.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index 14e60bda20..b519751ba2 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -1072,10 +1072,13 @@ class IWorkfileHost: prepared_data=prepared_data, ) - workfile_entities_by_path = { - workfile_entity["path"]: workfile_entity - for workfile_entity in list_workfiles_context.workfile_entities - } + workfile_entities_by_path = {} + for workfile_entity in list_workfiles_context.workfile_entities: + rootless_path = workfile_entity["path"] + path = os.path.normpath( + list_workfiles_context.anatomy.fill_root(rootless_path) + ) + workfile_entities_by_path[path] = workfile_entity workdir_data = get_template_data( list_workfiles_context.project_entity, @@ -1114,10 +1117,10 @@ class IWorkfileHost: rootless_path = f"{rootless_workdir}/{filename}" workfile_entity = workfile_entities_by_path.pop( - rootless_path, None + filepath, None ) version = comment = None - if workfile_entity: + if workfile_entity is not None: _data = workfile_entity["data"] version = _data.get("version") comment = _data.get("comment") @@ -1137,7 +1140,7 @@ class IWorkfileHost: ) items.append(item) - for workfile_entity in workfile_entities_by_path.values(): + for filepath, workfile_entity in workfile_entities_by_path.items(): # Workfile entity is not in the filesystem # but it is in the database rootless_path = workfile_entity["path"] @@ -1154,7 +1157,6 @@ class IWorkfileHost: version = parsed_data.version comment = parsed_data.comment - filepath = list_workfiles_context.anatomy.fill_root(rootless_path) available = os.path.exists(filepath) items.append(WorkfileInfo.new( filepath, From e7ea930d557d5e8264beb09a94b39044178fee33 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Fri, 1 Aug 2025 10:23:24 +0000 Subject: [PATCH 140/319] [Automated] Add generated package files from main --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 7f55a17a01..c16b31f2fc 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.5.0+dev" +__version__ = "1.5.1" diff --git a/package.py b/package.py index 807e4e4b35..9c131794d7 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.5.0+dev" +version = "1.5.1" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index e7977a5579..686cc1e3f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.5.0+dev" +version = "1.5.1" description = "" authors = ["Ynput Team "] readme = "README.md" From 302619176bbc651642dbe847d98eda76f543bd29 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Fri, 1 Aug 2025 10:24:02 +0000 Subject: [PATCH 141/319] [Automated] Update version in package.py for develop --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index c16b31f2fc..784105572b 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.5.1" +__version__ = "1.5.1+dev" diff --git a/package.py b/package.py index 9c131794d7..a0d7b26703 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.5.1" +version = "1.5.1+dev" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 686cc1e3f8..b544afa346 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.5.1" +version = "1.5.1+dev" description = "" authors = ["Ynput Team "] readme = "README.md" From 745a394cdddd688a054870c2ae08559683850d82 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 1 Aug 2025 10:24:54 +0000 Subject: [PATCH 142/319] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 9202190f8b..364d1709e0 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to AYON Tray options: + - 1.5.1 - 1.5.0 - 1.4.1 - 1.4.0 From 9f456f7cb8b3afa3c32ba605ca7ed22276b47c6d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 1 Aug 2025 14:37:21 +0200 Subject: [PATCH 143/319] added safe importing of otio --- .../publish/collect_otio_frame_ranges.py | 17 +++++++++++------ .../publish/extract_otio_audio_tracks.py | 2 +- .../plugins/publish/extract_otio_review.py | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_otio_frame_ranges.py b/client/ayon_core/plugins/publish/collect_otio_frame_ranges.py index 0a4efc2172..d68970d428 100644 --- a/client/ayon_core/plugins/publish/collect_otio_frame_ranges.py +++ b/client/ayon_core/plugins/publish/collect_otio_frame_ranges.py @@ -8,13 +8,7 @@ This module contains a unified plugin that handles: from pprint import pformat -import opentimelineio as otio import pyblish.api -from ayon_core.pipeline.editorial import ( - get_media_range_with_retimes, - otio_range_to_frame_range, - otio_range_with_handles, -) def validate_otio_clip(instance, logger): @@ -74,6 +68,8 @@ class CollectOtioRanges(pyblish.api.InstancePlugin): if not validate_otio_clip(instance, self.log): return + import opentimelineio as otio + otio_clip = instance.data["otioClip"] # Collect timeline ranges if workfile start frame is available @@ -100,6 +96,11 @@ class CollectOtioRanges(pyblish.api.InstancePlugin): def _collect_timeline_ranges(self, instance, otio_clip): """Collect basic timeline frame ranges.""" + from ayon_core.pipeline.editorial import ( + otio_range_to_frame_range, + otio_range_with_handles, + ) + workfile_start = instance.data["workfileFrameStart"] # Get timeline ranges @@ -129,6 +130,8 @@ class CollectOtioRanges(pyblish.api.InstancePlugin): def _collect_source_ranges(self, instance, otio_clip): """Collect source media frame ranges.""" + import opentimelineio as otio + # Get source ranges otio_src_range = otio_clip.source_range otio_available_range = otio_clip.available_range() @@ -178,6 +181,8 @@ class CollectOtioRanges(pyblish.api.InstancePlugin): def _collect_retimed_ranges(self, instance, otio_clip): """Handle retimed clip frame ranges.""" + from ayon_core.pipeline.editorial import get_media_range_with_retimes + retimed_attributes = get_media_range_with_retimes(otio_clip, 0, 0) self.log.debug(f"Retimed attributes: {retimed_attributes}") diff --git a/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py b/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py index 2aec4a5415..86d18ed147 100644 --- a/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py +++ b/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py @@ -7,7 +7,6 @@ from ayon_core.lib import ( get_ffmpeg_tool_args, run_subprocess ) -from ayon_core.pipeline import editorial class ExtractOtioAudioTracks(pyblish.api.ContextPlugin): @@ -159,6 +158,7 @@ class ExtractOtioAudioTracks(pyblish.api.ContextPlugin): """ # Not all hosts can import this module. import opentimelineio as otio + from ayon_core.pipeline.editorial import OTIO_EPSILON output = [] # go trough all audio tracks diff --git a/client/ayon_core/plugins/publish/extract_otio_review.py b/client/ayon_core/plugins/publish/extract_otio_review.py index 74cf45e474..28452bc0e9 100644 --- a/client/ayon_core/plugins/publish/extract_otio_review.py +++ b/client/ayon_core/plugins/publish/extract_otio_review.py @@ -25,7 +25,6 @@ from ayon_core.lib import ( ) from ayon_core.pipeline import ( KnownPublishError, - editorial, publish, ) @@ -359,6 +358,7 @@ class ExtractOTIOReview( import opentimelineio as otio from ayon_core.pipeline.editorial import ( trim_media_range, + OTIO_EPSILON, ) def _round_to_frame(rational_time): @@ -380,7 +380,7 @@ class ExtractOTIOReview( # Avoid rounding issue on media available range. if start.almost_equal( avl_start, - editorial.OTIO_EPSILON + OTIO_EPSILON ): avl_start = start From 798b281e6731947cd4700591632f4e4c4134b73b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 1 Aug 2025 14:42:16 +0200 Subject: [PATCH 144/319] fix OTIO_EPSILON usage --- client/ayon_core/plugins/publish/extract_otio_audio_tracks.py | 2 +- client/ayon_core/plugins/publish/extract_otio_review.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py b/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py index 86d18ed147..3a450a4f33 100644 --- a/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py +++ b/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py @@ -177,7 +177,7 @@ class ExtractOtioAudioTracks(pyblish.api.ContextPlugin): # Avoid rounding issue on media available range. if clip_start.almost_equal( conformed_av_start, - editorial.OTIO_EPSILON + OTIO_EPSILON ): conformed_av_start = clip_start diff --git a/client/ayon_core/plugins/publish/extract_otio_review.py b/client/ayon_core/plugins/publish/extract_otio_review.py index 28452bc0e9..90215bd2c9 100644 --- a/client/ayon_core/plugins/publish/extract_otio_review.py +++ b/client/ayon_core/plugins/publish/extract_otio_review.py @@ -406,7 +406,7 @@ class ExtractOTIOReview( # Avoid rounding issue on media available range. if end_point.almost_equal( avl_end_point, - editorial.OTIO_EPSILON + OTIO_EPSILON ): avl_end_point = end_point From 8bcc4a3939d4e52cce731a0e712b87b283fee37d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 1 Aug 2025 18:23:15 +0200 Subject: [PATCH 145/319] Make sure workdir exists when workfile is being saved --- client/ayon_core/host/interfaces/workfiles.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index b519751ba2..82d71d152a 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -944,6 +944,8 @@ class IWorkfileHost: self._emit_workfile_save_event(event_data, after_save=False) workdir = os.path.dirname(filepath) + if not os.path.exists(workdir): + os.makedirs(workdir, exist_ok=True) # Set 'AYON_WORKDIR' environment variable os.environ["AYON_WORKDIR"] = workdir From 955d8166a5fc4d216368db6ee0a7bf80710f7b32 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Fri, 1 Aug 2025 16:36:08 +0000 Subject: [PATCH 146/319] [Automated] Add generated package files from main --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 784105572b..b6958f1be5 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.5.1+dev" +__version__ = "1.5.2" diff --git a/package.py b/package.py index a0d7b26703..79fe4f83b1 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.5.1+dev" +version = "1.5.2" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index b544afa346..73fa4336f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.5.1+dev" +version = "1.5.2" description = "" authors = ["Ynput Team "] readme = "README.md" From 8cd7037c6f0910ff4ae789dd2b1213b5b5307e85 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Fri, 1 Aug 2025 16:36:43 +0000 Subject: [PATCH 147/319] [Automated] Update version in package.py for develop --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index b6958f1be5..9f1bac6805 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.5.2" +__version__ = "1.5.2+dev" diff --git a/package.py b/package.py index 79fe4f83b1..7bd806159f 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.5.2" +version = "1.5.2+dev" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 73fa4336f1..e67fcc2138 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.5.2" +version = "1.5.2+dev" description = "" authors = ["Ynput Team "] readme = "README.md" From 55f5551b31b1ad2aef3ca801207ad458a19d153e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 1 Aug 2025 16:37:35 +0000 Subject: [PATCH 148/319] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 364d1709e0..933448a6a9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to AYON Tray options: + - 1.5.2 - 1.5.1 - 1.5.0 - 1.4.1 From 4f0e18b42ed081370bc7d5279a2a91159a7b139f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 4 Aug 2025 10:17:50 +0200 Subject: [PATCH 149/319] Remove unnecessary line --- client/ayon_core/addon/interfaces.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/addon/interfaces.py b/client/ayon_core/addon/interfaces.py index 9f2a14a264..bf08ccd48c 100644 --- a/client/ayon_core/addon/interfaces.py +++ b/client/ayon_core/addon/interfaces.py @@ -99,7 +99,6 @@ class IPluginPaths(AYONInterface): f" '{new_function_name}' instead.", DeprecationWarning, stacklevel=2 - ) return paths From c219403b13c1f9436b17758e095b2f7fdd6788d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= <33513211+antirotor@users.noreply.github.com> Date: Mon, 4 Aug 2025 18:18:10 +0200 Subject: [PATCH 150/319] Update client/ayon_core/pipeline/workfile/workfile_template_builder.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../ayon_core/pipeline/workfile/workfile_template_builder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index 6a36fd12e4..9994bcfd4e 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -301,7 +301,9 @@ class AbstractTemplateBuilder(ABC): self._loaders_by_name = get_loaders_by_name() return self._loaders_by_name - def get_linked_folder_entities(self, link_type: str): + def get_linked_folder_entities(self, link_type: Optional[str]): + if not link_type: + return [] project_name = self.project_name folder_entity = self.current_folder_entity if not folder_entity: From 9929c80425cdf1caa5986ce8bacbfda442d009ae Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 7 Aug 2025 14:58:33 +0200 Subject: [PATCH 151/319] better detail widget varaible --- .../tools/publisher/widgets/card_view_widgets.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 6d95906364..1cce09e97a 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -309,10 +309,6 @@ class InstanceCardWidget(CardWidget): expand_btn.setMaximumWidth(14) expand_btn.setEnabled(False) - detail_widget = QtWidgets.QWidget(self) - detail_widget.setVisible(False) - self.detail_widget = detail_widget - top_layout = QtWidgets.QHBoxLayout() top_layout.addLayout(icon_layout, 0) top_layout.addWidget(label_widget, 1) @@ -320,6 +316,9 @@ class InstanceCardWidget(CardWidget): top_layout.addWidget(active_checkbox, 0) top_layout.addWidget(expand_btn, 0) + detail_widget = QtWidgets.QWidget(self) + detail_widget.setVisible(False) + layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 2, 10, 2) layout.addLayout(top_layout) @@ -337,6 +336,8 @@ class InstanceCardWidget(CardWidget): self._active_checkbox = active_checkbox self._expand_btn = expand_btn + self._detail_widget = detail_widget + self._update_instance_values(context_info, is_parent_active) def set_active_toggle_enabled(self, enabled: bool) -> None: @@ -448,8 +449,8 @@ class InstanceCardWidget(CardWidget): def _set_expanded(self, expanded=None): if expanded is None: - expanded = not self.detail_widget.isVisible() - self.detail_widget.setVisible(expanded) + expanded = not self._detail_widget.isVisible() + self._detail_widget.setVisible(expanded) def _on_active_change(self): new_value = self._active_checkbox.isChecked() From 5ab31a0bd9ee03e66c5908068bdbabce29de7098 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 7 Aug 2025 14:58:42 +0200 Subject: [PATCH 152/319] remove unused variable --- client/ayon_core/tools/publisher/widgets/card_view_widgets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 1cce09e97a..5b9b104c16 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -521,7 +521,6 @@ class InstanceCardView(AbstractInstanceView): collections.defaultdict(list) ) self._ordered_groups = [] - self._group_icons = {} self._context_widget: Optional[ContextCardWidget] = None self._widgets_by_id: dict[str, InstanceCardWidget] = {} self._widgets_by_group: dict[str, BaseGroupWidget] = {} From dba9ea95a2cc9aace75b3f84e88ffe6aa42ba323 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 7 Aug 2025 14:59:11 +0200 Subject: [PATCH 153/319] add missing abstract method --- .../ayon_core/tools/publisher/widgets/widgets.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/ayon_core/tools/publisher/widgets/widgets.py b/client/ayon_core/tools/publisher/widgets/widgets.py index a9d34c4c66..9de1f753b2 100644 --- a/client/ayon_core/tools/publisher/widgets/widgets.py +++ b/client/ayon_core/tools/publisher/widgets/widgets.py @@ -370,6 +370,21 @@ class AbstractInstanceView(QtWidgets.QWidget): "{} Method 'set_active_toggle_enabled' is not implemented." ).format(self.__class__.__name__)) + def refresh_instance_states(self, instance_ids=None): + """Refresh instance states. + + Args: + instance_ids: Optional[Iterable[str]]: Instance ids to refresh. + If not passed then all instances are refreshed. + + """ + + raise NotImplementedError( + f"{self.__class__.__name__} Method 'refresh_instance_states'" + " is not implemented." + ) + + class ClickableLineEdit(QtWidgets.QLineEdit): """QLineEdit capturing left mouse click. From a4bd8523f2203b9e588f22d75bef78e0f152dc01 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 7 Aug 2025 15:00:43 +0200 Subject: [PATCH 154/319] better view handling --- .../publisher/widgets/overview_widget.py | 75 ++++++++++++------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/overview_widget.py b/client/ayon_core/tools/publisher/widgets/overview_widget.py index d78b143ce6..10bd2bb354 100644 --- a/client/ayon_core/tools/publisher/widgets/overview_widget.py +++ b/client/ayon_core/tools/publisher/widgets/overview_widget.py @@ -1,3 +1,7 @@ +from __future__ import annotations + +from typing import Generator + from qtpy import QtWidgets, QtCore from ayon_core.tools.publisher.abstract import AbstractPublisherFrontend @@ -250,7 +254,7 @@ class OverviewWidget(QtWidgets.QFrame): ) def has_items(self): - view = self._product_views_layout.currentWidget() + view = self._get_current_view() return view.has_items() def _on_create_clicked(self): @@ -369,16 +373,14 @@ class OverviewWidget(QtWidgets.QFrame): self._refresh_instance_states(event["instance_ids"]) def _refresh_instance_states(self, instance_ids): - current_idx = self._product_views_layout.currentIndex() - for idx in range(self._product_views_layout.count()): - if idx == current_idx: - continue - widget = self._product_views_layout.widget(idx) - if widget.refreshed: - widget.set_refreshed(False) + current_view = self._get_current_view() + for view in self._iter_views(): + if view is current_view: + current_view = view + elif view.refreshed: + view.set_refreshed(False) - current_widget = self._product_views_layout.widget(current_idx) - current_widget.refresh_instance_states(instance_ids) + current_view.refresh_instance_states(instance_ids) def _on_convert_requested(self): self.convert_requested.emit() @@ -392,7 +394,7 @@ class OverviewWidget(QtWidgets.QFrame): convertor plugins. """ - view = self._product_views_layout.currentWidget() + view = self._get_current_view() return view.get_selected_items() def get_selected_legacy_convertors(self): @@ -410,8 +412,8 @@ class OverviewWidget(QtWidgets.QFrame): idx = self._product_views_layout.currentIndex() new_idx = (idx + 1) % self._product_views_layout.count() - old_view = self._product_views_layout.currentWidget() - new_view = self._product_views_layout.widget(new_idx) + old_view = self._get_current_view() + new_view = self._get_view_by_idx(new_idx) if not new_view.refreshed: new_view.refresh() @@ -430,17 +432,41 @@ class OverviewWidget(QtWidgets.QFrame): self._on_product_change() + def _iter_views(self) -> Generator[AbstractInstanceView, None, None]: + for idx in range(self._product_views_layout.count()): + widget = self._product_views_layout.widget(idx) + if not isinstance(widget, AbstractInstanceView): + raise TypeError( + "Current widget is not instance of 'AbstractInstanceView'" + ) + yield widget + + def _get_current_view(self) -> AbstractInstanceView: + widget = self._product_views_layout.currentWidget() + if isinstance(widget, AbstractInstanceView): + return widget + raise TypeError( + "Current widget is not instance of 'AbstractInstanceView'" + ) + + def _get_view_by_idx(self, idx: int) -> AbstractInstanceView: + widget = self._product_views_layout.widget(idx) + if isinstance(widget, AbstractInstanceView): + return widget + raise TypeError( + "Current widget is not instance of 'AbstractInstanceView'" + ) + def _refresh_instances(self): if self._refreshing_instances: return self._refreshing_instances = True - for idx in range(self._product_views_layout.count()): - widget = self._product_views_layout.widget(idx) - widget.set_refreshed(False) + for view in self._iter_views(): + view.set_refreshed(False) - view = self._product_views_layout.currentWidget() + view = self._get_current_view() view.refresh() view.set_refreshed(True) @@ -451,25 +477,22 @@ class OverviewWidget(QtWidgets.QFrame): # Give a change to process Resize Request QtWidgets.QApplication.processEvents() - # Trigger update geometry of - widget = self._product_views_layout.currentWidget() - widget.updateGeometry() + # Trigger update geometry + view.updateGeometry() def _on_publish_start(self): """Publish started.""" self._create_btn.setEnabled(False) self._product_attributes_wrap.setEnabled(False) - for idx in range(self._product_views_layout.count()): - widget = self._product_views_layout.widget(idx) - widget.set_active_toggle_enabled(False) + for view in self._iter_views(): + view.set_active_toggle_enabled(False) def _on_controller_reset_start(self): """Controller reset started.""" - for idx in range(self._product_views_layout.count()): - widget = self._product_views_layout.widget(idx) - widget.set_active_toggle_enabled(True) + for view in self._iter_views(): + view.set_active_toggle_enabled(True) def _on_publish_reset(self): """Context in controller has been reseted.""" From bc6bd4be29614630f875cc6ecfc809c6fa7d3859 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 7 Aug 2025 15:00:57 +0200 Subject: [PATCH 155/319] added missing import --- client/ayon_core/tools/publisher/widgets/overview_widget.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/tools/publisher/widgets/overview_widget.py b/client/ayon_core/tools/publisher/widgets/overview_widget.py index 10bd2bb354..44581feac8 100644 --- a/client/ayon_core/tools/publisher/widgets/overview_widget.py +++ b/client/ayon_core/tools/publisher/widgets/overview_widget.py @@ -10,6 +10,7 @@ from .border_label_widget import BorderedLabelWidget from .card_view_widgets import InstanceCardView from .list_view_widgets import InstanceListView from .widgets import ( + AbstractInstanceView, CreateInstanceBtn, RemoveInstanceBtn, ChangeViewBtn, From c800e35f3fc4ad44df28a39f34040f46334cce89 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 7 Aug 2025 15:01:34 +0200 Subject: [PATCH 156/319] change change view button --- .../publisher/widgets/overview_widget.py | 5 ++++ .../tools/publisher/widgets/widgets.py | 24 +++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/overview_widget.py b/client/ayon_core/tools/publisher/widgets/overview_widget.py index 44581feac8..4ff38c26cd 100644 --- a/client/ayon_core/tools/publisher/widgets/overview_widget.py +++ b/client/ayon_core/tools/publisher/widgets/overview_widget.py @@ -178,6 +178,7 @@ class OverviewWidget(QtWidgets.QFrame): self._create_btn = create_btn self._delete_btn = delete_btn + self._change_view_btn = change_view_btn self._product_attributes_widget = product_attributes_widget self._create_widget = create_widget @@ -415,6 +416,7 @@ class OverviewWidget(QtWidgets.QFrame): old_view = self._get_current_view() new_view = self._get_view_by_idx(new_idx) + is_list_view = isinstance(new_view, InstanceListView) if not new_view.refreshed: new_view.refresh() @@ -429,6 +431,9 @@ class OverviewWidget(QtWidgets.QFrame): instance_ids, context_selected, convertor_identifiers ) + self._change_view_btn.set_view_type( + "card" if is_list_view else "list" + ) self._product_views_layout.setCurrentIndex(new_idx) self._on_product_change() diff --git a/client/ayon_core/tools/publisher/widgets/widgets.py b/client/ayon_core/tools/publisher/widgets/widgets.py index 9de1f753b2..b1c4a3afcc 100644 --- a/client/ayon_core/tools/publisher/widgets/widgets.py +++ b/client/ayon_core/tools/publisher/widgets/widgets.py @@ -10,6 +10,7 @@ from ayon_core.tools.flickcharm import FlickCharm from ayon_core.tools.utils import ( IconButton, PixmapLabel, + get_qt_icon, ) from ayon_core.tools.publisher.constants import ResetKeySequence @@ -287,12 +288,27 @@ class RemoveInstanceBtn(PublishIconBtn): self.setToolTip("Remove selected instances") -class ChangeViewBtn(PublishIconBtn): +class ChangeViewBtn(IconButton): """Create toggle view button.""" def __init__(self, parent=None): - icon_path = get_icon_path("change_view") - super().__init__(icon_path, parent) - self.setToolTip("Swap between views") + super().__init__(parent) + self.set_view_type("list") + + def set_view_type(self, view_type): + if view_type == "list": + # icon_name = "data_table" + icon_name = "view_agenda" + tooltip = "Change to list view" + else: + icon_name = "dehaze" + tooltip = "Change to card view" + + icon = get_qt_icon({ + "type": "material-symbols", + "name": icon_name, + }) + self.setIcon(icon) + self.setToolTip(tooltip) class AbstractInstanceView(QtWidgets.QWidget): From a7a3834fdcc168188d8c944144f8514e24f8bd56 Mon Sep 17 00:00:00 2001 From: Sasbom Date: Fri, 8 Aug 2025 08:31:22 +0200 Subject: [PATCH 157/319] force in UI element from laucher to workfiles --- .../tools/workfiles/widgets/window.py | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/client/ayon_core/tools/workfiles/widgets/window.py b/client/ayon_core/tools/workfiles/widgets/window.py index 1649a059cb..81f1d76c71 100644 --- a/client/ayon_core/tools/workfiles/widgets/window.py +++ b/client/ayon_core/tools/workfiles/widgets/window.py @@ -1,21 +1,20 @@ -from qtpy import QtCore, QtWidgets, QtGui +from qtpy import QtCore, QtGui, QtWidgets -from ayon_core import style, resources +from ayon_core import resources, style from ayon_core.tools.utils import ( - PlaceholderLineEdit, - MessageOverlayObject, -) - -from ayon_core.tools.workfiles.control import BaseWorkfileController -from ayon_core.tools.utils import ( - GoToCurrentButton, - RefreshButton, FoldersWidget, + GoToCurrentButton, + MessageOverlayObject, + NiceCheckbox, + PlaceholderLineEdit, + RefreshButton, TasksWidget, ) +from ayon_core.tools.utils.lib import checkstate_int_to_enum +from ayon_core.tools.workfiles.control import BaseWorkfileController -from .side_panel import SidePanelWidget from .files_widget import FilesWidget +from .side_panel import SidePanelWidget from .utils import BaseOverlayFrame @@ -186,11 +185,24 @@ class WorkfilesToolWindow(QtWidgets.QWidget): controller, col_widget, handle_expected_selection=True ) + my_tasks_tooltip = ( + "Filter folders and task to only those you are assigned to." + ) + + my_tasks_label = QtWidgets.QLabel("My tasks") + my_tasks_label.setToolTip(my_tasks_tooltip) + + my_tasks_checkbox = NiceCheckbox(folder_widget) + my_tasks_checkbox.setChecked(False) + my_tasks_checkbox.setToolTip(my_tasks_tooltip) + header_layout = QtWidgets.QHBoxLayout(header_widget) header_layout.setContentsMargins(0, 0, 0, 0) header_layout.addWidget(folder_filter_input, 1) header_layout.addWidget(go_to_current_btn, 0) header_layout.addWidget(refresh_btn, 0) + header_layout.addWidget(my_tasks_label, 0) + header_layout.addWidget(my_tasks_checkbox, 0) col_layout = QtWidgets.QVBoxLayout(col_widget) col_layout.setContentsMargins(0, 0, 0, 0) @@ -200,6 +212,9 @@ class WorkfilesToolWindow(QtWidgets.QWidget): folder_filter_input.textChanged.connect(self._on_folder_filter_change) go_to_current_btn.clicked.connect(self._on_go_to_current_clicked) refresh_btn.clicked.connect(self._on_refresh_clicked) + my_tasks_checkbox.stateChanged.connect( + self._on_my_tasks_checkbox_state_changed + ) self._folder_filter_input = folder_filter_input self._folders_widget = folder_widget @@ -385,3 +400,16 @@ class WorkfilesToolWindow(QtWidgets.QWidget): ) else: self.close() + + def _on_my_tasks_checkbox_state_changed(self, state): + folder_ids = None + task_ids = None + state = checkstate_int_to_enum(state) + if state == QtCore.Qt.Checked: + entity_ids = self._controller.get_my_tasks_entity_ids( + self._project_name + ) + folder_ids = entity_ids["folder_ids"] + task_ids = entity_ids["task_ids"] + self._folders_widget.set_folder_ids_filter(folder_ids) + self._tasks_widget.set_task_ids_filter(task_ids) From 20614562cd5a8818191d8daa1822cf354ffa6a86 Mon Sep 17 00:00:00 2001 From: Sasbom Date: Fri, 8 Aug 2025 09:13:31 +0200 Subject: [PATCH 158/319] implement interface for "my task" functionality in workfiles control / window --- client/ayon_core/tools/workfiles/control.py | 26 +++++++++++++++---- .../tools/workfiles/widgets/window.py | 4 +++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/tools/workfiles/control.py b/client/ayon_core/tools/workfiles/control.py index 4391e6b5fd..f0e0f0e416 100644 --- a/client/ayon_core/tools/workfiles/control.py +++ b/client/ayon_core/tools/workfiles/control.py @@ -3,25 +3,26 @@ import os import ayon_api from ayon_core.host import IWorkfileHost -from ayon_core.lib import Logger +from ayon_core.lib import Logger, get_ayon_username from ayon_core.lib.events import QueuedEventSystem -from ayon_core.settings import get_project_settings from ayon_core.pipeline import Anatomy, registered_host from ayon_core.pipeline.context_tools import get_global_context - +from ayon_core.settings import get_project_settings from ayon_core.tools.common_models import ( - HierarchyModel, HierarchyExpectedSelection, + HierarchyModel, ProjectsModel, UsersModel, ) from .abstract import ( - AbstractWorkfilesFrontend, AbstractWorkfilesBackend, + AbstractWorkfilesFrontend, ) from .models import SelectionModel, WorkfilesModel +NOT_SET = object() + class WorkfilesToolExpectedSelection(HierarchyExpectedSelection): def __init__(self, controller): @@ -143,6 +144,7 @@ class BaseWorkfileController( self._project_settings = None self._event_system = None self._log = None + self._username = NOT_SET self._current_project_name = None self._current_folder_path = None @@ -588,6 +590,20 @@ class BaseWorkfileController( description, ) + def get_my_tasks_entity_ids(self, project_name: str): + username = self._get_my_username() + assignees = [] + if username: + assignees.append(username) + return self._hierarchy_model.get_entity_ids_for_assignees( + project_name, assignees + ) + + def _get_my_username(self): + if self._username is NOT_SET: + self._username = get_ayon_username() + return self._username + def _emit_event(self, topic, data=None): self.emit_event(topic, data, "controller") diff --git a/client/ayon_core/tools/workfiles/widgets/window.py b/client/ayon_core/tools/workfiles/widgets/window.py index 81f1d76c71..1e78b89851 100644 --- a/client/ayon_core/tools/workfiles/widgets/window.py +++ b/client/ayon_core/tools/workfiles/widgets/window.py @@ -1,3 +1,4 @@ + from qtpy import QtCore, QtGui, QtWidgets from ayon_core import resources, style @@ -156,6 +157,9 @@ class WorkfilesToolWindow(QtWidgets.QWidget): self._home_body_widget = home_body_widget self._split_widget = split_widget + host = self._controller._host + self._project_name = host.get_current_project_name() + self._tasks_widget = tasks_widget self._side_panel = side_panel From f4578e93a9f5a8a4f86cad0a4e9510d375b0d707 Mon Sep 17 00:00:00 2001 From: Sasbom Date: Fri, 8 Aug 2025 09:16:32 +0200 Subject: [PATCH 159/319] embiggen first panel to accommodate added ui element --- client/ayon_core/tools/workfiles/widgets/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/workfiles/widgets/window.py b/client/ayon_core/tools/workfiles/widgets/window.py index 1e78b89851..7c00499b2d 100644 --- a/client/ayon_core/tools/workfiles/widgets/window.py +++ b/client/ayon_core/tools/workfiles/widgets/window.py @@ -107,7 +107,7 @@ class WorkfilesToolWindow(QtWidgets.QWidget): split_widget.addWidget(tasks_widget) split_widget.addWidget(col_3_widget) split_widget.addWidget(side_panel) - split_widget.setSizes([255, 175, 550, 190]) + split_widget.setSizes([350, 175, 550, 190]) body_layout.addWidget(split_widget) From 0d945c90ecf37c794f84ff7048c0e0474de30bf1 Mon Sep 17 00:00:00 2001 From: Sasbom Date: Fri, 8 Aug 2025 10:17:13 +0200 Subject: [PATCH 160/319] neaten up project name retrieval through canonical means --- client/ayon_core/tools/workfiles/widgets/window.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_core/tools/workfiles/widgets/window.py b/client/ayon_core/tools/workfiles/widgets/window.py index 7c00499b2d..3f96f0bb15 100644 --- a/client/ayon_core/tools/workfiles/widgets/window.py +++ b/client/ayon_core/tools/workfiles/widgets/window.py @@ -157,8 +157,7 @@ class WorkfilesToolWindow(QtWidgets.QWidget): self._home_body_widget = home_body_widget self._split_widget = split_widget - host = self._controller._host - self._project_name = host.get_current_project_name() + self._project_name = self._controller.get_current_project_name() self._tasks_widget = tasks_widget self._side_panel = side_panel From 80cd3a3ea811dc70dd2e0c44b22eb42ebb8d4d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Fri, 8 Aug 2025 12:23:43 +0200 Subject: [PATCH 161/319] :bug: fix import --- client/ayon_core/pipeline/workfile/workfile_template_builder.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index 9994bcfd4e..e2add99752 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -16,6 +16,7 @@ import re import collections import copy from abc import ABC, abstractmethod +from typing import Optional import ayon_api from ayon_api import ( From e07b11b7fabd89e1d9bd95697acff8a4a843d6f7 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 8 Aug 2025 13:56:30 +0200 Subject: [PATCH 162/319] change view on too much instances --- .../tools/publisher/widgets/card_view_widgets.py | 4 ++++ .../tools/publisher/widgets/overview_widget.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 5b9b104c16..3c8a99b2c9 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -548,6 +548,10 @@ class InstanceCardView(AbstractInstanceView): result.setWidth(width) return result + def get_current_instance_count(self) -> int: + """How many instances are currently in the view.""" + return len(self._widgets_by_id) + def _toggle_instances( self, new_value: Optional[bool], diff --git a/client/ayon_core/tools/publisher/widgets/overview_widget.py b/client/ayon_core/tools/publisher/widgets/overview_widget.py index 4ff38c26cd..27b1a2e185 100644 --- a/client/ayon_core/tools/publisher/widgets/overview_widget.py +++ b/client/ayon_core/tools/publisher/widgets/overview_widget.py @@ -513,7 +513,19 @@ class OverviewWidget(QtWidgets.QFrame): self._refresh_instances() def _on_instances_added(self): + view = self._get_current_view() + is_card_view = False + count = 0 + if isinstance(view, InstanceCardView): + is_card_view = True + count = view.get_current_instance_count() + self._refresh_instances() + if is_card_view and count < 10: + new_count = view.get_current_instance_count() + if new_count > count and new_count >= 10: + self._change_view_type() + def _on_instances_removed(self): self._refresh_instances() From de68250995e727f2804f31ad1184585576fc3ef0 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:00:11 +0200 Subject: [PATCH 163/319] use parent ids structure instead of UI model to traverse hierarchy --- .../publisher/widgets/list_view_widgets.py | 80 +++++++------------ 1 file changed, 31 insertions(+), 49 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index a2aadd9cfa..62c5b6aa4c 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -485,6 +485,7 @@ class InstanceListView(AbstractInstanceView): self._widgets_by_id: dict[str, InstanceListItemWidget] = {} self._items_by_id = {} self._parent_id_by_id = {} + self._instance_ids_by_parent_id = collections.defaultdict(set) # Group by instance id for handling of active state self._group_by_instance_id = {} self._context_item = None @@ -565,10 +566,14 @@ class InstanceListView(AbstractInstanceView): # Prepare instances by their groups instances_by_group_name = collections.defaultdict(list) instances_by_parent_id = collections.defaultdict(list) + instance_ids_by_parent_id = collections.defaultdict(set) group_names = set() instance_ids = set() for instance in instance_items: instance_ids.add(instance.id) + instance_ids_by_parent_id[instance.parent_instance_id].add( + instance.id + ) if instance.parent_instance_id: instances_by_parent_id[instance.parent_instance_id].append( instance @@ -663,20 +668,19 @@ class InstanceListView(AbstractInstanceView): self._parent_id_by_id[instance_id] = parent_id - children = instances_by_parent_id.pop(instance_id, []) items_with_instance.append( ( item, instance, parent_id, is_orpaned_item, - bool(children) ) ) item.setData(instance.product_name, SORT_VALUE_ROLE) item.setData(instance.product_name, GROUP_ROLE) + children = instances_by_parent_id.pop(instance_id, []) for child in children: _queue.append((child, item, instance_id)) @@ -705,7 +709,7 @@ class InstanceListView(AbstractInstanceView): parent_item.appendRows(items) for ( - item, instance, parent_id, is_orpaned_item, has_children + item, instance, parent_id, is_orpaned_item ) in items_with_instance: context_info = context_info_by_id[instance.id] # TODO expand all parents @@ -752,6 +756,7 @@ class InstanceListView(AbstractInstanceView): widget.deleteLater() self._widgets_by_id = widgets_by_id + self._instance_ids_by_parent_id = instance_ids_by_parent_id # Expand items marked for expanding items_to_expand = [] @@ -1022,29 +1027,16 @@ class InstanceListView(AbstractInstanceView): instance_ids = set(instance_items_by_id) available_ids = set(instance_ids) - group_items = list(self._group_items.values()) - if self._missing_parent_item is not None: - group_items.append(self._missing_parent_item) - _queue = collections.deque() - for group_item in group_items: - if not group_item.hasChildren(): - continue - - children = [ - group_item.child(row) - for row in range(group_item.rowCount()) - ] - _queue.append((children, True)) + _queue.append((set(self._instance_ids_by_parent_id[None]), True)) discarted_ids = set() while _queue: if not instance_ids: break - children, parent_active = _queue.popleft() - for child in children: - instance_id = child.data(INSTANCE_ID_ROLE) + children_ids, parent_active = _queue.popleft() + for instance_id in children_ids: widget = self._widgets_by_id[instance_id] # Add children ids to 'instance_ids' to traverse them too add_children = False @@ -1066,23 +1058,24 @@ class InstanceListView(AbstractInstanceView): instance_ids.discard(instance_id) discarted_ids.add(instance_id) - if not child.hasChildren(): + if not add_children: continue - children = [ - child.child(row) - for row in range(child.rowCount()) - ] - if add_children: - for new_child in children: - instance_id = new_child.data(INSTANCE_ID_ROLE) - if instance_id not in discarted_ids: - instance_ids.add(instance_id) + _children = { + child_id + for child_id in ( + self._instance_ids_by_parent_id[instance_id] + ) + if child_id not in discarted_ids + } + + if _children: + instance_ids |= _children + _queue.append((_children, widget.is_active())) if not instance_ids: break - _queue.append((children, widget.is_active())) def _on_active_changed(self, changed_instance_id, new_value): self._toggle_active_state(new_value, changed_instance_id) @@ -1097,23 +1090,12 @@ class InstanceListView(AbstractInstanceView): instance_ids = {active_id} active_by_id = {} - # Change the states from top to bottom - group_items = list(self._group_items.values()) - if self._missing_parent_item is not None: - group_items.append(self._missing_parent_item) - _queue = collections.deque() - for group_item in group_items: - children = [ - group_item.child(row) - for row in range(group_item.rowCount()) - ] - _queue.append((children, True)) + _queue.append((set(self._instance_ids_by_parent_id[None]), True)) while _queue: - children, parent_active = _queue.popleft() - for child in children: - instance_id = child.data(INSTANCE_ID_ROLE) + children_ids, parent_active = _queue.popleft() + for instance_id in children_ids: widget = self._widgets_by_id[instance_id] widget.set_parent_is_active(parent_active) if instance_id in instance_ids: @@ -1123,11 +1105,11 @@ class InstanceListView(AbstractInstanceView): widget.set_active(value) active_by_id[instance_id] = value - children = [ - child.child(row) - for row in range(child.rowCount()) - ] - _queue.append((children, widget.is_active())) + children = set( + self._instance_ids_by_parent_id[instance_id] + ) + if children: + _queue.append((children, widget.is_active())) self._controller.set_instances_active_state(active_by_id) From 4fda90d135430087fde7631b2acd36d1123fd634 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:00:25 +0200 Subject: [PATCH 164/319] added 3rd view --- .../publisher/widgets/list_view_widgets.py | 17 ++++++++++++-- .../publisher/widgets/overview_widget.py | 23 +++++++++++++++---- .../tools/publisher/widgets/widgets.py | 13 +++++++---- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 62c5b6aa4c..89ed60a076 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -491,6 +491,7 @@ class InstanceListView(AbstractInstanceView): self._context_item = None self._context_widget = None self._missing_parent_item = None + self._parent_grouping = True self._convertor_group_item = None self._convertor_group_widget = None @@ -578,7 +579,8 @@ class InstanceListView(AbstractInstanceView): instances_by_parent_id[instance.parent_instance_id].append( instance ) - continue + if self._parent_grouping: + continue group_label = instance.group_label group_names.add(group_label) @@ -664,6 +666,9 @@ class InstanceListView(AbstractInstanceView): new_items[parent_id].append(item) elif item.parent() is not parent_item: + current_parent = item.parent() + if current_parent is not None: + current_parent.takeRow(item.row()) new_items[parent_id].append(item) self._parent_id_by_id[instance_id] = parent_id @@ -680,6 +685,9 @@ class InstanceListView(AbstractInstanceView): item.setData(instance.product_name, SORT_VALUE_ROLE) item.setData(instance.product_name, GROUP_ROLE) + if not self._parent_grouping: + continue + children = instances_by_parent_id.pop(instance_id, []) for child in children: _queue.append((child, item, instance_id)) @@ -701,7 +709,7 @@ class InstanceListView(AbstractInstanceView): # Add items under group item for parent_id, items in new_items.items(): - if parent_id is None: + if parent_id is None or not self._parent_grouping: parent_item = group_item else: parent_item = self._items_by_id[parent_id] @@ -1076,6 +1084,11 @@ class InstanceListView(AbstractInstanceView): if not instance_ids: break + def parent_grouping_enabled(self) -> bool: + return self._parent_grouping + + def set_parent_grouping(self, parent_grouping: bool) -> None: + self._parent_grouping = parent_grouping def _on_active_changed(self, changed_instance_id, new_value): self._toggle_active_state(new_value, changed_instance_id) diff --git a/client/ayon_core/tools/publisher/widgets/overview_widget.py b/client/ayon_core/tools/publisher/widgets/overview_widget.py index 27b1a2e185..cb7e2b39cf 100644 --- a/client/ayon_core/tools/publisher/widgets/overview_widget.py +++ b/client/ayon_core/tools/publisher/widgets/overview_widget.py @@ -411,14 +411,27 @@ class OverviewWidget(QtWidgets.QFrame): return convertor_identifiers def _change_view_type(self): + old_view = self._get_current_view() + if ( + isinstance(old_view, InstanceListView) + and not old_view.parent_grouping_enabled() + ): + self._change_view_btn.set_view_type("card") + old_view.set_parent_grouping(True) + old_view.refresh() + old_view.set_refreshed(True) + return + idx = self._product_views_layout.currentIndex() new_idx = (idx + 1) % self._product_views_layout.count() - old_view = self._get_current_view() new_view = self._get_view_by_idx(new_idx) - is_list_view = isinstance(new_view, InstanceListView) + if isinstance(new_view, InstanceListView): + new_view.set_parent_grouping(False) + new_view.refresh() + new_view.set_refreshed(True) - if not new_view.refreshed: + elif not new_view.refreshed: new_view.refresh() new_view.set_refreshed(True) else: @@ -432,7 +445,9 @@ class OverviewWidget(QtWidgets.QFrame): ) self._change_view_btn.set_view_type( - "card" if is_list_view else "list" + "list" + if isinstance(new_view, InstanceCardView) + else "list-parent-grouping" ) self._product_views_layout.setCurrentIndex(new_idx) diff --git a/client/ayon_core/tools/publisher/widgets/widgets.py b/client/ayon_core/tools/publisher/widgets/widgets.py index b1c4a3afcc..921a13ba77 100644 --- a/client/ayon_core/tools/publisher/widgets/widgets.py +++ b/client/ayon_core/tools/publisher/widgets/widgets.py @@ -289,7 +289,7 @@ class RemoveInstanceBtn(PublishIconBtn): class ChangeViewBtn(IconButton): - """Create toggle view button.""" + """Toggle views button.""" def __init__(self, parent=None): super().__init__(parent) self.set_view_type("list") @@ -297,12 +297,17 @@ class ChangeViewBtn(IconButton): def set_view_type(self, view_type): if view_type == "list": # icon_name = "data_table" - icon_name = "view_agenda" - tooltip = "Change to list view" - else: icon_name = "dehaze" + tooltip = "Change to list view" + elif view_type == "card": + icon_name = "view_agenda" tooltip = "Change to card view" + else: + icon_name = "segment" + tooltip = "Change to parent grouping view" + # "format_align_right" + # "segment" icon = get_qt_icon({ "type": "material-symbols", "name": icon_name, From 78faa1c36f95ba30fe25cf1e2abf02289f234216 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:06:03 +0200 Subject: [PATCH 165/319] formatting fix --- client/ayon_core/tools/publisher/widgets/widgets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/publisher/widgets/widgets.py b/client/ayon_core/tools/publisher/widgets/widgets.py index 921a13ba77..793b0f501b 100644 --- a/client/ayon_core/tools/publisher/widgets/widgets.py +++ b/client/ayon_core/tools/publisher/widgets/widgets.py @@ -406,7 +406,6 @@ class AbstractInstanceView(QtWidgets.QWidget): ) - class ClickableLineEdit(QtWidgets.QLineEdit): """QLineEdit capturing left mouse click. From f11fe9c089b775d431d458c15d1022b24d9a7c2a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 12 Aug 2025 17:52:10 +0200 Subject: [PATCH 166/319] allow copy of published workfile without task --- client/ayon_core/tools/workfiles/widgets/files_widget.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/workfiles/widgets/files_widget.py b/client/ayon_core/tools/workfiles/widgets/files_widget.py index 0c8ad392e2..9c12fa575c 100644 --- a/client/ayon_core/tools/workfiles/widgets/files_widget.py +++ b/client/ayon_core/tools/workfiles/widgets/files_widget.py @@ -287,10 +287,11 @@ class FilesWidget(QtWidgets.QWidget): def _update_published_btns_state(self): enabled = ( self._valid_representation_id - and self._valid_selected_context and self._is_save_enabled ) - self._published_btn_copy_n_open.setEnabled(enabled) + self._published_btn_copy_n_open.setEnabled( + enabled and self._valid_selected_context + ) self._published_btn_change_context.setEnabled(enabled) def _update_workarea_btns_state(self): From 2757c6efbb7e68c6c0ff1ac43e6d4b0bef2c2971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 12 Aug 2025 18:42:49 +0200 Subject: [PATCH 167/319] :sparkles: very raw WIP version --- .../plugins/load/create_hero_version.py | 415 ++++++++++++++++++ 1 file changed, 415 insertions(+) create mode 100644 client/ayon_core/plugins/load/create_hero_version.py diff --git a/client/ayon_core/plugins/load/create_hero_version.py b/client/ayon_core/plugins/load/create_hero_version.py new file mode 100644 index 0000000000..7e1a0d8a3d --- /dev/null +++ b/client/ayon_core/plugins/load/create_hero_version.py @@ -0,0 +1,415 @@ + +import os +import copy +import shutil +import errno +import itertools +from concurrent.futures import ThreadPoolExecutor + +from speedcopy import copyfile +import clique +import ayon_api +from ayon_api.operations import OperationsSession, new_version_entity +from ayon_api.utils import create_entity_id +from qtpy import QtWidgets, QtCore +from ayon_core import style +from ayon_core.pipeline import load, Anatomy +from ayon_core.lib import create_hard_link, source_hash +from ayon_core.lib.file_transaction import wait_for_future_errors +from ayon_core.pipeline.publish import get_publish_template_name +from ayon_core.pipeline.template_data import get_template_data + + +def prepare_changes(old_entity, new_entity): + changes = {} + for key in set(new_entity.keys()): + if key == "attrib": + continue + if key in new_entity and new_entity[key] != old_entity.get(key): + changes[key] = new_entity[key] + attrib_changes = {} + if "attrib" in new_entity: + for key, value in new_entity["attrib"].items(): + if value != old_entity["attrib"].get(key): + attrib_changes[key] = value + if attrib_changes: + changes["attrib"] = attrib_changes + return changes + + +class CreateHeroVersion(load.ProductLoaderPlugin): + """Create hero version from selected context.""" + + is_multiple_contexts_compatible = False + representations = {"*"} + product_types = {"*"} + label = "Create Hero Version" + order = 36 + icon = "star" + color = "#ffd700" + + ignored_representation_names = [] + db_representation_context_keys = [ + "project", "folder", "asset", "hierarchy", "task", "product", + "subset", "family", "representation", "username", "user", "output" + ] + use_hardlinks = False + + def message(self, text): + msgBox = QtWidgets.QMessageBox() + msgBox.setText(text) + msgBox.setStyleSheet(style.load_stylesheet()) + msgBox.setWindowFlags( + msgBox.windowFlags() | QtCore.Qt.FramelessWindowHint + ) + msgBox.exec_() + + + def load(self, context, name=None, namespace=None, options=None) -> None: + """Load hero version from context (dict as in context.py).""" + success = True + errors = [] + + # Extract project, product, version, folder from context + project = context.get("project") + product = context.get("product") + version = context.get("version") + folder = context.get("folder") + task_entity = ayon_api.get_task_by_id( + task_id=version.get("taskId"), project_name=project["name"]) + + anatomy = Anatomy(project["name"]) + + version_id = version["id"] + project_name = project["name"] + repres = list( + ayon_api.get_representations(project_name, version_ids={version_id})) + anatomy_data = get_template_data( + project_entity=project, + folder_entity=folder, + task_entity=task_entity, + ) + anatomy_data["product"] = { + "name": product["name"], + "type": product["productType"], + } + published_representations = {} + for repre in repres: + repre_anatomy = anatomy_data + repre_anatomy["ext"] = repre.get("ext", "") + published_representations[repre["id"]] = { + "representation": repre, + "published_files": [f["path"] for f in repre.get("files", [])], + "anatomy_data": repre_anatomy + } + + instance_data = { + "productName": product["name"], + "productType": product["productType"], + "anatomyData": anatomy_data, + "publishDir": "", # TODO: Set to actual publish directory + "published_representations": published_representations, + "versionEntity": version, + } + + try: + self.create_hero_version(instance_data, anatomy, context) + except Exception as exc: + success = False + errors.append(str(exc)) + if success: + self.message("Hero version created successfully.") + else: + self.message( + f"Failed to create hero version:\n{chr(10).join(errors)}") + + def create_hero_version(self, instance_data, anatomy, context): + """Create hero version from instance data.""" + published_repres = instance_data.get("published_representations") + if not published_repres: + raise RuntimeError("No published representations found.") + + project_name = anatomy.project_name + template_key = get_publish_template_name( + project_name, + context.get("hostName"), + instance_data.get("productType"), + instance_data.get("anatomyData", {}).get("task", {}).get("name"), + instance_data.get("anatomyData", {}).get("task", {}).get("type"), + project_settings=context.get("project_settings", {}), + hero=True, + logger=None + ) + hero_template = anatomy.get_template_item("hero", template_key, "path", default=None) + if hero_template is None: + raise RuntimeError(f"Project anatomy does not have hero template key: {template_key}") + + print(f"Hero template: {hero_template.template}") + + hero_publish_dir = self.get_publish_dir(instance_data, anatomy, template_key) + + print(f"Hero publish dir: {hero_publish_dir}") + + src_version_entity = instance_data.get("versionEntity") + filtered_repre_ids = [] + for repre_id, repre_info in published_repres.items(): + repre = repre_info["representation"] + if repre["name"].lower() in self.ignored_representation_names: + filtered_repre_ids.append(repre_id) + for repre_id in filtered_repre_ids: + published_repres.pop(repre_id, None) + if not published_repres: + raise RuntimeError("All published representations were filtered by name.") + + if src_version_entity is None: + src_version_entity = self.version_from_representations(project_name, published_repres) + if not src_version_entity: + raise RuntimeError("Can't find origin version in database.") + if src_version_entity["version"] == 0: + raise RuntimeError("Version 0 cannot have hero version.") + + all_copied_files = [] + transfers = instance_data.get("transfers", list()) + for _src, dst in transfers: + dst = os.path.normpath(dst) + if dst not in all_copied_files: + all_copied_files.append(dst) + hardlinks = instance_data.get("hardlinks", list()) + for _src, dst in hardlinks: + dst = os.path.normpath(dst) + if dst not in all_copied_files: + all_copied_files.append(dst) + + all_repre_file_paths = [] + for repre_info in published_repres.values(): + published_files = repre_info.get("published_files") or [] + for file_path in published_files: + file_path = os.path.normpath(file_path) + if file_path not in all_repre_file_paths: + all_repre_file_paths.append(file_path) + + instance_publish_dir = os.path.normpath(instance_data["publishDir"]) + other_file_paths_mapping = [] + for file_path in all_copied_files: + if not file_path.startswith(instance_publish_dir): + continue + if file_path in all_repre_file_paths: + continue + dst_filepath = file_path.replace(instance_publish_dir, hero_publish_dir) + other_file_paths_mapping.append((file_path, dst_filepath)) + + old_version, old_repres = self.current_hero_ents(project_name, src_version_entity) + inactive_old_repres_by_name = {} + old_repres_by_name = {} + for repre in old_repres: + low_name = repre["name"].lower() + if repre["active"]: + old_repres_by_name[low_name] = repre + else: + inactive_old_repres_by_name[low_name] = repre + + op_session = OperationsSession() + entity_id = old_version["id"] if old_version else None + new_hero_version = new_version_entity( + -src_version_entity["version"], + src_version_entity["productId"], + task_id=src_version_entity.get("taskId"), + data=copy.deepcopy(src_version_entity["data"]), + attribs=copy.deepcopy(src_version_entity["attrib"]), + entity_id=entity_id, + ) + if old_version: + update_data = prepare_changes(old_version, new_hero_version) + op_session.update_entity(project_name, "version", old_version["id"], update_data) + else: + op_session.create_entity(project_name, "version", new_hero_version) + + # Store hero entity to instance_data + instance_data["heroVersionEntity"] = new_hero_version + + old_repres_to_replace = {} + old_repres_to_delete = {} + for repre_info in published_repres.values(): + repre = repre_info["representation"] + repre_name_low = repre["name"].lower() + if repre_name_low in old_repres_by_name: + old_repres_to_replace[repre_name_low] = old_repres_by_name.pop(repre_name_low) + if old_repres_by_name: + old_repres_to_delete = old_repres_by_name + + backup_hero_publish_dir = None + if os.path.exists(hero_publish_dir): + backup_hero_publish_dir = hero_publish_dir + ".BACKUP" + max_idx = 10 + idx = 0 + _backup_hero_publish_dir = backup_hero_publish_dir + while os.path.exists(_backup_hero_publish_dir): + try: + shutil.rmtree(_backup_hero_publish_dir) + backup_hero_publish_dir = _backup_hero_publish_dir + break + except Exception: + _backup_hero_publish_dir = backup_hero_publish_dir + str(idx) + if not os.path.exists(_backup_hero_publish_dir): + backup_hero_publish_dir = _backup_hero_publish_dir + break + if idx > max_idx: + raise AssertionError(f"Backup folders are fully occupied to max index {max_idx}") + idx += 1 + try: + os.rename(hero_publish_dir, backup_hero_publish_dir) + except PermissionError: + raise AssertionError( + "Could not create hero version because it is " + "not possible to replace current hero files.") + + try: + src_to_dst_file_paths = [] + repre_integrate_data = [] + path_template_obj = anatomy.get_template_item( + "hero", template_key, "path") + for repre_info in published_repres.values(): + published_files = repre_info["published_files"] + if len(published_files) == 0: + continue + anatomy_data = copy.deepcopy(repre_info["anatomy_data"]) + anatomy_data.pop("version", None) + template_filled = path_template_obj.format_strict(anatomy_data) + repre_context = template_filled.used_values + for key in self.db_representation_context_keys: + value = anatomy_data.get(key) + if value is not None: + repre_context[key] = value + repre_entity = copy.deepcopy(repre_info["representation"]) + repre_entity.pop("id", None) + repre_entity["versionId"] = new_hero_version["id"] + repre_entity["context"] = repre_context + repre_entity["attrib"] = { + "path": str(template_filled), + "template": hero_template.template + } + dst_paths = [] + if len(published_files) == 1: + dst_paths.append(str(template_filled)) + src_to_dst_file_paths.append((published_files[0], template_filled)) + print(f"Single published file: {published_files[0]} -> {template_filled}") + else: + collections, remainders = clique.assemble(published_files) + if remainders or not collections or len(collections) > 1: + raise Exception( + "Integrity error. Files of published representation is " + "combination of frame collections and single files.") + src_col = collections[0] + frame_splitter = "_-_FRAME_SPLIT_-_" + anatomy_data["frame"] = frame_splitter + _template_filled = path_template_obj.format_strict(anatomy_data) + head, tail = _template_filled.split(frame_splitter) + padding = anatomy.templates_obj.frame_padding + dst_col = clique.Collection(head=head, padding=padding, tail=tail) + dst_col.indexes.clear() + dst_col.indexes.update(src_col.indexes) + for src_file, dst_file in zip(src_col, dst_col): + src_to_dst_file_paths.append((src_file, dst_file)) + dst_paths.append(dst_file) + print(f"Collection published file: {src_file} -> {dst_file}") + repre_integrate_data.append((repre_entity, dst_paths)) + + # Copy files + with ThreadPoolExecutor(max_workers=8) as executor: + futures = [ + executor.submit(self.copy_file, src_path, dst_path) + for src_path, dst_path in itertools.chain(src_to_dst_file_paths, other_file_paths_mapping) + ] + wait_for_future_errors(executor, futures) + + # Update/create representations + for repre_entity, dst_paths in repre_integrate_data: + repre_files = self.get_files_info(dst_paths, anatomy) + repre_entity["files"] = repre_files + repre_name_low = repre_entity["name"].lower() + if repre_name_low in old_repres_to_replace: + old_repre = old_repres_to_replace.pop(repre_name_low) + repre_entity["id"] = old_repre["id"] + update_data = prepare_changes(old_repre, repre_entity) + op_session.update_entity(project_name, "representation", old_repre["id"], update_data) + elif repre_name_low in inactive_old_repres_by_name: + inactive_repre = inactive_old_repres_by_name.pop(repre_name_low) + repre_entity["id"] = inactive_repre["id"] + update_data = prepare_changes(inactive_repre, repre_entity) + op_session.update_entity(project_name, "representation", inactive_repre["id"], update_data) + else: + op_session.create_entity(project_name, "representation", repre_entity) + + for repre in old_repres_to_delete.values(): + op_session.update_entity(project_name, "representation", repre["id"], {"active": False}) + + op_session.commit() + + if backup_hero_publish_dir is not None and os.path.exists(backup_hero_publish_dir): + shutil.rmtree(backup_hero_publish_dir) + + except Exception: + if backup_hero_publish_dir is not None and os.path.exists(backup_hero_publish_dir): + if os.path.exists(hero_publish_dir): + shutil.rmtree(hero_publish_dir) + os.rename(backup_hero_publish_dir, hero_publish_dir) + raise + + def get_files_info(self, filepaths, anatomy): + file_infos = [] + for filepath in filepaths: + file_info = self.prepare_file_info(filepath, anatomy) + file_infos.append(file_info) + return file_infos + + def prepare_file_info(self, path, anatomy): + return { + "id": create_entity_id(), + "name": os.path.basename(path), + "path": self.get_rootless_path(anatomy, path), + "size": os.path.getsize(path), + "hash": source_hash(path), + "hash_type": "op3", + } + + def get_publish_dir(self, instance_data, anatomy, template_key): + template_data = copy.deepcopy(instance_data.get("anatomyData", {})) + if "originalBasename" in instance_data: + template_data["originalBasename"] = instance_data["originalBasename"] + template_obj = anatomy.get_template_item("hero", template_key, "directory") + return os.path.normpath(template_obj.format_strict(template_data)) + + def get_rootless_path(self, anatomy, path): + success, rootless_path = anatomy.find_root_template_from_path(path) + if success: + path = rootless_path + return path + + def copy_file(self, src_path, dst_path): + dirname = os.path.dirname(dst_path) + try: + os.makedirs(dirname) + except OSError as exc: + if exc.errno != errno.EEXIST: + raise + if self.use_hardlinks: + try: + create_hard_link(src_path, dst_path) + return + except OSError as exc: + if exc.errno not in [errno.EXDEV, errno.EINVAL]: + raise + copyfile(src_path, dst_path) + + def version_from_representations(self, project_name, repres): + for repre_info in repres.values(): + version = ayon_api.get_version_by_id(project_name, repre_info["representation"]["versionId"]) + if version: + return version + + def current_hero_ents(self, project_name, version): + hero_version = ayon_api.get_hero_version_by_product_id(project_name, version["productId"]) + if not hero_version: + return (None, []) + hero_repres = list(ayon_api.get_representations(project_name, version_ids={hero_version["id"]})) + return (hero_version, hero_repres) From 8faac875a491a113471464e0957941245a883134 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 13 Aug 2025 10:15:20 +0200 Subject: [PATCH 168/319] fix group checkbox functionality --- .../ayon_core/tools/publisher/widgets/list_view_widgets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 89ed60a076..c54f9b94b0 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -1097,8 +1097,10 @@ class InstanceListView(AbstractInstanceView): self, new_value: Optional[bool], active_id: Optional[str] = None, + instance_ids: Optional[set[str]] = None, ) -> None: - instance_ids, _, _ = self.get_selected_items() + if instance_ids is None: + instance_ids, _, _ = self.get_selected_items() if active_id and active_id not in instance_ids: instance_ids = {active_id} @@ -1163,7 +1165,7 @@ class InstanceListView(AbstractInstanceView): instance_id = child.data(INSTANCE_ID_ROLE) instance_ids.add(instance_id) - self._toggle_active_state(active) + self._toggle_active_state(active, instance_ids=instance_ids) proxy_index = self._proxy_model.mapFromSource(group_item.index()) if not self._instance_view.isExpanded(proxy_index): From b66f4fe325f5d1fee9df4ce75fab176cab7fa4a8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 13 Aug 2025 11:47:12 +0200 Subject: [PATCH 169/319] emit event only if active actually changed --- client/ayon_core/tools/publisher/models/create.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/publisher/models/create.py b/client/ayon_core/tools/publisher/models/create.py index 0b0d287448..5098826b8b 100644 --- a/client/ayon_core/tools/publisher/models/create.py +++ b/client/ayon_core/tools/publisher/models/create.py @@ -583,15 +583,21 @@ class CreateModel: def set_instances_active_state( self, active_state_by_id: Dict[str, bool] ): + changed_ids = set() with self._create_context.bulk_value_changes(CREATE_EVENT_SOURCE): for instance_id, active in active_state_by_id.items(): instance = self._create_context.get_instance_by_id(instance_id) - instance["active"] = active + if instance["active"] is not active: + instance["active"] = active + changed_ids.add(instance_id) + + if not changed_ids: + return self._emit_event( "create.model.instances.context.changed", { - "instance_ids": set(active_state_by_id.keys()) + "instance_ids": changed_ids } ) From 822182f21a434465302961d8a20d41078d1668db Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 13 Aug 2025 11:47:32 +0200 Subject: [PATCH 170/319] fix parent active issue --- .../tools/publisher/widgets/card_view_widgets.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 3c8a99b2c9..1491cdf7ec 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -583,13 +583,16 @@ class InstanceCardView(AbstractInstanceView): instance_ids.discard(instance_id) discarted_ids.add(instance_id) add_children = True + if is_parent_active is not widget.is_parent_active(): + add_children = True + widget.set_parent_active(is_parent_active) + + old_value = widget.is_active() value = new_value if value is None: - value = not widget.is_active() - old_value = widget.is_active() + value = not old_value widget.set_active(value) - if old_value is not widget.is_active(): - active_by_id[instance_id] = value + active_by_id[instance_id] = widget.is_active() if ( instance_id in instance_ids From 2d97cc9a29b5d28fdf6efadc0108690192693c63 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 13 Aug 2025 11:48:28 +0200 Subject: [PATCH 171/319] don't re-using the same view --- .../publisher/widgets/overview_widget.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/overview_widget.py b/client/ayon_core/tools/publisher/widgets/overview_widget.py index cb7e2b39cf..01799ac908 100644 --- a/client/ayon_core/tools/publisher/widgets/overview_widget.py +++ b/client/ayon_core/tools/publisher/widgets/overview_widget.py @@ -48,10 +48,16 @@ class OverviewWidget(QtWidgets.QFrame): product_view_cards = InstanceCardView(controller, product_views_widget) product_list_view = InstanceListView(controller, product_views_widget) + product_list_view.set_parent_grouping(False) + product_list_view_grouped = InstanceListView( + controller, product_views_widget + ) + product_list_view_grouped.set_parent_grouping(True) product_views_layout = QtWidgets.QStackedLayout() product_views_layout.addWidget(product_view_cards) product_views_layout.addWidget(product_list_view) + product_views_layout.addWidget(product_list_view_grouped) product_views_layout.setCurrentWidget(product_view_cards) # Buttons at the bottom of product view @@ -123,6 +129,12 @@ class OverviewWidget(QtWidgets.QFrame): product_list_view.double_clicked.connect( self.publish_tab_requested ) + product_list_view_grouped.selection_changed.connect( + self._on_product_change + ) + product_list_view_grouped.double_clicked.connect( + self.publish_tab_requested + ) product_view_cards.selection_changed.connect( self._on_product_change ) @@ -174,6 +186,7 @@ class OverviewWidget(QtWidgets.QFrame): self._product_view_cards = product_view_cards self._product_list_view = product_list_view + self._product_list_view_grouped = product_list_view_grouped self._product_views_layout = product_views_layout self._create_btn = create_btn @@ -412,26 +425,12 @@ class OverviewWidget(QtWidgets.QFrame): def _change_view_type(self): old_view = self._get_current_view() - if ( - isinstance(old_view, InstanceListView) - and not old_view.parent_grouping_enabled() - ): - self._change_view_btn.set_view_type("card") - old_view.set_parent_grouping(True) - old_view.refresh() - old_view.set_refreshed(True) - return idx = self._product_views_layout.currentIndex() new_idx = (idx + 1) % self._product_views_layout.count() new_view = self._get_view_by_idx(new_idx) - if isinstance(new_view, InstanceListView): - new_view.set_parent_grouping(False) - new_view.refresh() - new_view.set_refreshed(True) - - elif not new_view.refreshed: + if not new_view.refreshed: new_view.refresh() new_view.set_refreshed(True) else: @@ -443,12 +442,13 @@ class OverviewWidget(QtWidgets.QFrame): new_view.set_selected_items( instance_ids, context_selected, convertor_identifiers ) + view_type = "list" + if new_view is self._product_list_view_grouped: + view_type = "card" + elif new_view is self._product_list_view: + view_type = "list-parent-grouping" - self._change_view_btn.set_view_type( - "list" - if isinstance(new_view, InstanceCardView) - else "list-parent-grouping" - ) + self._change_view_btn.set_view_type(view_type) self._product_views_layout.setCurrentIndex(new_idx) self._on_product_change() From e6522e4d4e80c7d00fca0994451dbf4414d45b2f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 13 Aug 2025 11:49:17 +0200 Subject: [PATCH 172/319] make sure parent is active is always checked --- .../ayon_core/tools/publisher/widgets/list_view_widgets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index c54f9b94b0..9ea0f85bcb 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -1060,12 +1060,14 @@ class InstanceListView(AbstractInstanceView): context_info_by_id[instance_id], parent_active, ) - else: - widget.set_active(parent_active) instance_ids.discard(instance_id) discarted_ids.add(instance_id) + if parent_active is not widget.is_parent_active(): + widget.set_parent_is_active(parent_active) + add_children = True + if not add_children: continue From 10ebfa6d8e3865b6ca0a4b3ece5c3674a9317a9d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 13 Aug 2025 11:49:28 +0200 Subject: [PATCH 173/319] few enhancements --- .../tools/publisher/widgets/list_view_widgets.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 9ea0f85bcb..86df4223a4 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -1046,10 +1046,9 @@ class InstanceListView(AbstractInstanceView): children_ids, parent_active = _queue.popleft() for instance_id in children_ids: widget = self._widgets_by_id[instance_id] - # Add children ids to 'instance_ids' to traverse them too - add_children = False + # Parent active state changed -> traverse children too + add_children = False if instance_id in instance_ids: - # Parent active state changed -> traverse children too add_children = ( parent_active is not widget.is_parent_active() ) @@ -1069,16 +1068,11 @@ class InstanceListView(AbstractInstanceView): add_children = True if not add_children: + if not instance_ids: + break continue - _children = { - child_id - for child_id in ( - self._instance_ids_by_parent_id[instance_id] - ) - if child_id not in discarted_ids - } - + _children = set(self._instance_ids_by_parent_id[instance_id]) if _children: instance_ids |= _children _queue.append((_children, widget.is_active())) From 277489b4252464230ff2574f8287f334149fa03b Mon Sep 17 00:00:00 2001 From: Ynbot Date: Wed, 13 Aug 2025 12:19:27 +0000 Subject: [PATCH 174/319] [Automated] Add generated package files from main --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 9f1bac6805..11cbfa61b5 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.5.2+dev" +__version__ = "1.5.3" diff --git a/package.py b/package.py index 7bd806159f..012bbd081c 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.5.2+dev" +version = "1.5.3" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index e67fcc2138..91748f801b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.5.2+dev" +version = "1.5.3" description = "" authors = ["Ynput Team "] readme = "README.md" From c8f802b210026bb0b47c85efea4fe1d23c516835 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Wed, 13 Aug 2025 12:20:11 +0000 Subject: [PATCH 175/319] [Automated] Update version in package.py for develop --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 11cbfa61b5..f2aa94020f 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.5.3" +__version__ = "1.5.3+dev" diff --git a/package.py b/package.py index 012bbd081c..07a1246c9f 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.5.3" +version = "1.5.3+dev" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 91748f801b..ee6c35b50b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.5.3" +version = "1.5.3+dev" description = "" authors = ["Ynput Team "] readme = "README.md" From 3ef40e203bafbd229cd21417b604a939fc1cd9fb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 13 Aug 2025 12:21:07 +0000 Subject: [PATCH 176/319] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 933448a6a9..ce5982969c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to AYON Tray options: + - 1.5.3 - 1.5.2 - 1.5.1 - 1.5.0 From 56ebe87bcb298be9507ca027248c882a6bb0ffe8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 13 Aug 2025 14:46:09 +0200 Subject: [PATCH 177/319] fix card view changes --- .../publisher/widgets/card_view_widgets.py | 102 ++++++++++-------- 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 1491cdf7ec..24daae151a 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -353,7 +353,7 @@ class InstanceCardWidget(CardWidget): if not self.is_checkbox_enabled(): return if active is None: - active = not self.is_active() + active = not self._is_active self._set_checked(active) def is_parent_active(self) -> bool: @@ -453,6 +453,8 @@ class InstanceCardWidget(CardWidget): self._detail_widget.setVisible(expanded) def _on_active_change(self): + if not self.is_checkbox_enabled(): + return new_value = self._active_checkbox.isChecked() old_value = self._is_active if new_value is old_value: @@ -525,6 +527,7 @@ class InstanceCardView(AbstractInstanceView): self._widgets_by_id: dict[str, InstanceCardWidget] = {} self._widgets_by_group: dict[str, BaseGroupWidget] = {} + self._parent_id_by_id = {} self._instance_ids_by_parent_id = collections.defaultdict(set) self._explicitly_selected_instance_ids = [] @@ -552,6 +555,26 @@ class InstanceCardView(AbstractInstanceView): """How many instances are currently in the view.""" return len(self._widgets_by_id) + def _get_affected_ids(self, instance_ids: set[str]) -> set[str]: + affected_ids = set() + affected_queue = collections.deque() + affected_queue.extend(instance_ids) + while affected_queue: + instance_id = affected_queue.popleft() + if instance_id in affected_ids: + continue + affected_ids.add(instance_id) + parent_id = instance_id + while True: + parent_id = self._parent_id_by_id[parent_id] + if parent_id is None: + break + affected_ids.add(parent_id) + + child_ids = set(self._instance_ids_by_parent_id[instance_id]) + affected_queue.extend(child_ids - affected_ids) + return affected_ids + def _toggle_instances( self, new_value: Optional[bool], @@ -566,7 +589,10 @@ class InstanceCardView(AbstractInstanceView): if active_id and active_id not in instance_ids: instance_ids = {active_id} - affected_ids = set(instance_ids) + ids_to_toggle = set(instance_ids) + + affected_ids = self._get_affected_ids(instance_ids) + _queue = collections.deque() _queue.append((set(self._instance_ids_by_parent_id[None]), True)) discarted_ids = set() @@ -576,36 +602,24 @@ class InstanceCardView(AbstractInstanceView): chilren_ids, is_parent_active = _queue.pop() for instance_id in chilren_ids: - widget = self._widgets_by_id[instance_id] - add_children = False - if instance_id in affected_ids: - affected_ids.discard(instance_id) - instance_ids.discard(instance_id) - discarted_ids.add(instance_id) - add_children = True - if is_parent_active is not widget.is_parent_active(): - add_children = True - widget.set_parent_active(is_parent_active) + if instance_id not in affected_ids: + continue + widget = self._widgets_by_id[instance_id] + if is_parent_active is not widget.is_parent_active(): + widget.set_parent_active(is_parent_active) + + instance_ids.discard(instance_id) + if instance_id in ids_to_toggle: + discarted_ids.add(instance_id) old_value = widget.is_active() value = new_value if value is None: value = not old_value + widget.set_active(value) - active_by_id[instance_id] = widget.is_active() - - if ( - instance_id in instance_ids - and is_parent_active is not widget.is_parent_active() - ): - add_children = True - widget.set_parent_active(is_parent_active) - - instance_ids.discard(instance_id) - discarted_ids.add(instance_id) - - if not add_children: - continue + if widget.is_parent_active(): + active_by_id[instance_id] = widget.is_active() children_ids = self._instance_ids_by_parent_id[instance_id] children = { @@ -621,7 +635,8 @@ class InstanceCardView(AbstractInstanceView): if not instance_ids: break - self._controller.set_instances_active_state(active_by_id) + if active_by_id: + self._controller.set_instances_active_state(active_by_id) def keyPressEvent(self, event): if event.key() == QtCore.Qt.Key_Space: @@ -699,6 +714,7 @@ class InstanceCardView(AbstractInstanceView): identifiers_by_group = collections.defaultdict(set) identifiers: set[str] = set() instances_by_id = {} + parent_id_by_id = {} instance_ids_by_parent_id = collections.defaultdict(set) instance_items = self._controller.get_instance_items() for instance in instance_items: @@ -712,6 +728,7 @@ class InstanceCardView(AbstractInstanceView): instance_ids_by_parent_id[instance.parent_instance_id].add( instance.id ) + parent_id_by_id[instance.id] = instance.parent_instance_id parent_active_by_id = { instance_id: False @@ -797,6 +814,7 @@ class InstanceCardView(AbstractInstanceView): widget.setVisible(False) widget.deleteLater() + self._parent_id_by_id = parent_id_by_id self._instance_ids_by_parent_id = instance_ids_by_parent_id self._group_name_by_instance_id = group_by_instance_id self._instance_ids_by_group_name = instance_ids_by_group_name @@ -961,22 +979,23 @@ class InstanceCardView(AbstractInstanceView): ) instance_ids: set[str] = set(instance_items_by_id) available_ids: set[str] = set(instance_items_by_id) - discarted_ids: set[str] = set() + + affected_ids = self._get_affected_ids(instance_ids) _queue = collections.deque() _queue.append((set(self._instance_ids_by_parent_id[None]), True)) while _queue: - if not instance_ids: + if not affected_ids: break chilren_ids, is_parent_active = _queue.pop() for instance_id in chilren_ids: + if instance_id not in affected_ids: + continue + affected_ids.discard(instance_id) widget = self._widgets_by_id[instance_id] - add_children = False if instance_id in instance_ids: - add_children = ( - is_parent_active is not widget.is_parent_active() - ) + instance_ids.discard(instance_id) if instance_id in available_ids: available_ids.discard(instance_id) widget.update_instance( @@ -987,25 +1006,14 @@ class InstanceCardView(AbstractInstanceView): else: widget.set_parent_active(is_parent_active) - instance_ids.discard(instance_id) - discarted_ids.add(instance_id) - - if not add_children: - continue - - children_ids = self._instance_ids_by_parent_id[instance_id] - children = { - child_id - for child_id in children_ids - if child_id not in discarted_ids - } + if not affected_ids: + break + children = set(self._instance_ids_by_parent_id[instance_id]) if children: instance_ids |= children _queue.append((children, widget.is_active())) - if not instance_ids: - break def _on_active_changed(self, instance_id: str, value: bool) -> None: self._toggle_instances(value, instance_id) From ef3cf62a41779ecaac5d132c02d491e1fad2dab6 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 13 Aug 2025 15:15:18 +0200 Subject: [PATCH 178/319] fix list view refresh --- .../publisher/widgets/list_view_widgets.py | 124 ++++++++---------- 1 file changed, 56 insertions(+), 68 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index 86df4223a4..cd1a1dbb9a 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -621,6 +621,7 @@ class InstanceListView(AbstractInstanceView): orphans_item, )) + items_with_instance = {} # Process changes in each group item # - create new instance, update existing and remove not existing for group_widget, group_instances, group_item in group_items: @@ -633,26 +634,12 @@ class InstanceListView(AbstractInstanceView): # - 'None' is used if parent is group item new_items = collections.defaultdict(list) # Tuples of model item and instance itself - items_with_instance = [] - # Group activity (should be {-1;0;1} at the end) - # - 0 when all instances are disabled - # - 1 when all instances are enabled - # - -1 when it's mixed - activity = None for instance in group_instances: _queue = collections.deque() _queue.append((instance, group_item, None)) while _queue: instance, parent_item, parent_id = _queue.popleft() instance_id = instance.id - # Handle group activity - if activity is None: - activity = int(instance.is_active) - elif activity == -1: - pass - elif activity != instance.is_active: - activity = -1 - # Remove group name from groups mapping if parent_id is not None: self._group_by_instance_id.pop(instance_id, None) @@ -673,13 +660,10 @@ class InstanceListView(AbstractInstanceView): self._parent_id_by_id[instance_id] = parent_id - items_with_instance.append( - ( - item, - instance, - parent_id, - is_orpaned_item, - ) + items_with_instance[instance.id] = ( + item, + instance, + is_orpaned_item, ) item.setData(instance.product_name, SORT_VALUE_ROLE) @@ -692,15 +676,6 @@ class InstanceListView(AbstractInstanceView): for child in children: _queue.append((child, item, instance_id)) - # Set checkstate of group checkbox - if group_widget is not None: - state = QtCore.Qt.PartiallyChecked - if activity == 0: - state = QtCore.Qt.Unchecked - elif activity == 1: - state = QtCore.Qt.Checked - group_widget.set_checkstate(state) - # Process new instance items and add them to model and create # their widgets if new_items: @@ -716,48 +691,57 @@ class InstanceListView(AbstractInstanceView): parent_item.appendRows(items) - for ( - item, instance, parent_id, is_orpaned_item - ) in items_with_instance: - context_info = context_info_by_id[instance.id] - # TODO expand all parents - if not context_info.is_valid: - expand_to_items.append(item) + ids_order = [] + ids_queue = collections.deque() + ids_queue.extend(instance_ids_by_parent_id[None]) + while ids_queue: + parent_id = ids_queue.popleft() + ids_order.append(parent_id) + ids_queue.extend(instance_ids_by_parent_id[parent_id]) + ids_order.extend(set(items_with_instance) - set(ids_order)) - parent_active = True - if is_orpaned_item: - parent_active = False + for instance_id in ids_order: + item, instance, is_orpaned_item = items_with_instance[instance_id] + context_info = context_info_by_id[instance.id] + # TODO expand all parents + if not context_info.is_valid: + expand_to_items.append(item) - if parent_id: - parent_widget = widgets_by_id.get(parent_id) - parent_active = False - if parent_widget is not None: - parent_active = parent_widget.is_active() - item_index = self._instance_model.indexFromItem(item) - proxy_index = self._proxy_model.mapFromSource(item_index) - widget = self._instance_view.indexWidget(proxy_index) - if isinstance(widget, InstanceListItemWidget): - widget.update_instance( - instance, - context_info, - parent_active, - ) - else: - widget = InstanceListItemWidget( - instance, - context_info, - parent_active, - self._instance_view - ) - widget.active_changed.connect(self._on_active_changed) - widget.double_clicked.connect(self.double_clicked) - self._instance_view.setIndexWidget(proxy_index, widget) - widget.set_active_toggle_enabled( - self._active_toggle_enabled + parent_active = True + if is_orpaned_item: + parent_active = False + + parent_id = instance.parent_instance_id + if parent_id: + parent_widget = widgets_by_id.get(parent_id) + parent_active = False + if parent_widget is not None: + parent_active = parent_widget.is_active() + item_index = self._instance_model.indexFromItem(item) + proxy_index = self._proxy_model.mapFromSource(item_index) + widget = self._instance_view.indexWidget(proxy_index) + if isinstance(widget, InstanceListItemWidget): + widget.update_instance( + instance, + context_info, + parent_active, ) + else: + widget = InstanceListItemWidget( + instance, + context_info, + parent_active, + self._instance_view + ) + widget.active_changed.connect(self._on_active_changed) + widget.double_clicked.connect(self.double_clicked) + self._instance_view.setIndexWidget(proxy_index, widget) + widget.set_active_toggle_enabled( + self._active_toggle_enabled + ) - widgets_by_id[instance.id] = widget - self._widgets_by_id.pop(instance.id, None) + widgets_by_id[instance.id] = widget + self._widgets_by_id.pop(instance.id, None) for widget in self._widgets_by_id.values(): widget.setVisible(False) @@ -766,6 +750,10 @@ class InstanceListView(AbstractInstanceView): self._widgets_by_id = widgets_by_id self._instance_ids_by_parent_id = instance_ids_by_parent_id + # Set checkstate of group checkbox + for group_name in self._group_items: + self._update_group_checkstate(group_name) + # Expand items marked for expanding items_to_expand = [] _marked_ids = set() From 65d03327b8af6e630b41f17bd629115e6fd1a83d Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 13 Aug 2025 15:18:46 +0200 Subject: [PATCH 179/319] Fix typo --- client/ayon_core/tools/push_to_project/ui/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 6b0363adee..344295f177 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -551,7 +551,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._main_thread_timer_can_stop = False self._main_thread_timer.start() self._main_layout.setCurrentWidget(self._overlay_widget) - self._overlay_label.setText("Submittion started") + self._overlay_label.setText("Submission started") def _on_controller_submit_end(self): self._main_thread_timer_can_stop = True From 152e32ac323f376a5fe04b8eaed2a3f1b132506f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 13 Aug 2025 15:20:32 +0200 Subject: [PATCH 180/319] formatting fixes --- client/ayon_core/tools/publisher/widgets/card_view_widgets.py | 1 - client/ayon_core/tools/publisher/widgets/list_view_widgets.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py index 24daae151a..84786a671e 100644 --- a/client/ayon_core/tools/publisher/widgets/card_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/card_view_widgets.py @@ -1014,7 +1014,6 @@ class InstanceCardView(AbstractInstanceView): instance_ids |= children _queue.append((children, widget.is_active())) - def _on_active_changed(self, instance_id: str, value: bool) -> None: self._toggle_instances(value, instance_id) diff --git a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py index cd1a1dbb9a..c524b96d5f 100644 --- a/client/ayon_core/tools/publisher/widgets/list_view_widgets.py +++ b/client/ayon_core/tools/publisher/widgets/list_view_widgets.py @@ -1035,7 +1035,7 @@ class InstanceListView(AbstractInstanceView): for instance_id in children_ids: widget = self._widgets_by_id[instance_id] # Parent active state changed -> traverse children too - add_children = False + add_children = False if instance_id in instance_ids: add_children = ( parent_active is not widget.is_parent_active() From 4951c9442a86bc23bd8ffa40618fc9c9676a8c49 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 16:45:22 +0200 Subject: [PATCH 181/319] small enhancements in nice checkbox --- client/ayon_core/tools/utils/nice_checkbox.py | 200 +++++++++--------- 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/client/ayon_core/tools/utils/nice_checkbox.py b/client/ayon_core/tools/utils/nice_checkbox.py index 3d9d63b6bc..d1cc8d16f5 100644 --- a/client/ayon_core/tools/utils/nice_checkbox.py +++ b/client/ayon_core/tools/utils/nice_checkbox.py @@ -1,7 +1,8 @@ -from math import floor, sqrt, ceil +from math import floor, ceil + from qtpy import QtWidgets, QtCore, QtGui -from ayon_core.style import get_objected_colors +from ayon_core.style import load_stylesheet, get_objected_colors class NiceCheckbox(QtWidgets.QFrame): @@ -9,12 +10,15 @@ class NiceCheckbox(QtWidgets.QFrame): clicked = QtCore.Signal() _checked_bg_color = None + _checked_bg_color_disabled = None _unchecked_bg_color = None + _unchecked_bg_color_disabled = None _checker_color = None + _checker_color_disabled = None _checker_hover_color = None def __init__(self, checked=False, draw_icons=False, parent=None): - super(NiceCheckbox, self).__init__(parent) + super().__init__(parent) self.setObjectName("NiceCheckbox") self.setAttribute(QtCore.Qt.WA_TranslucentBackground) @@ -48,8 +52,6 @@ class NiceCheckbox(QtWidgets.QFrame): self._pressed = False self._under_mouse = False - self.icon_scale_factor = sqrt(2) / 2 - icon_path_stroker = QtGui.QPainterPathStroker() icon_path_stroker.setCapStyle(QtCore.Qt.RoundCap) icon_path_stroker.setJoinStyle(QtCore.Qt.RoundJoin) @@ -61,35 +63,6 @@ class NiceCheckbox(QtWidgets.QFrame): self._base_size = QtCore.QSize(90, 50) self._load_colors() - @classmethod - def _load_colors(cls): - if cls._checked_bg_color is not None: - return - - colors_info = get_objected_colors("nice-checkbox") - - cls._checked_bg_color = colors_info["bg-checked"].get_qcolor() - cls._unchecked_bg_color = colors_info["bg-unchecked"].get_qcolor() - - cls._checker_color = colors_info["bg-checker"].get_qcolor() - cls._checker_hover_color = colors_info["bg-checker-hover"].get_qcolor() - - @property - def checked_bg_color(self): - return self._checked_bg_color - - @property - def unchecked_bg_color(self): - return self._unchecked_bg_color - - @property - def checker_color(self): - return self._checker_color - - @property - def checker_hover_color(self): - return self._checker_hover_color - def setTristate(self, tristate=True): if self._is_tristate != tristate: self._is_tristate = tristate @@ -121,14 +94,14 @@ class NiceCheckbox(QtWidgets.QFrame): def setFixedHeight(self, *args, **kwargs): self._fixed_height_set = True - super(NiceCheckbox, self).setFixedHeight(*args, **kwargs) + super().setFixedHeight(*args, **kwargs) if not self._fixed_width_set: width = self.get_width_hint_by_height(self.height()) self.setFixedWidth(width) def setFixedWidth(self, *args, **kwargs): self._fixed_width_set = True - super(NiceCheckbox, self).setFixedWidth(*args, **kwargs) + super().setFixedWidth(*args, **kwargs) if not self._fixed_height_set: height = self.get_height_hint_by_width(self.width()) self.setFixedHeight(height) @@ -136,7 +109,7 @@ class NiceCheckbox(QtWidgets.QFrame): def setFixedSize(self, *args, **kwargs): self._fixed_height_set = True self._fixed_width_set = True - super(NiceCheckbox, self).setFixedSize(*args, **kwargs) + super().setFixedSize(*args, **kwargs) def steps(self): return self._steps @@ -242,7 +215,7 @@ class NiceCheckbox(QtWidgets.QFrame): if event.buttons() & QtCore.Qt.LeftButton: self._pressed = True self.repaint() - super(NiceCheckbox, self).mousePressEvent(event) + super().mousePressEvent(event) def mouseReleaseEvent(self, event): if self._pressed and not event.buttons() & QtCore.Qt.LeftButton: @@ -252,7 +225,7 @@ class NiceCheckbox(QtWidgets.QFrame): self.clicked.emit() event.accept() return - super(NiceCheckbox, self).mouseReleaseEvent(event) + super().mouseReleaseEvent(event) def mouseMoveEvent(self, event): if self._pressed: @@ -261,19 +234,19 @@ class NiceCheckbox(QtWidgets.QFrame): self._under_mouse = under_mouse self.repaint() - super(NiceCheckbox, self).mouseMoveEvent(event) + super().mouseMoveEvent(event) def enterEvent(self, event): self._under_mouse = True if self.isEnabled(): self.repaint() - super(NiceCheckbox, self).enterEvent(event) + super().enterEvent(event) def leaveEvent(self, event): self._under_mouse = False if self.isEnabled(): self.repaint() - super(NiceCheckbox, self).leaveEvent(event) + super().leaveEvent(event) def _on_animation_timeout(self): if self._checkstate == QtCore.Qt.Checked: @@ -302,24 +275,13 @@ class NiceCheckbox(QtWidgets.QFrame): @staticmethod def steped_color(color1, color2, offset_ratio): - red_dif = ( - color1.red() - color2.red() - ) - green_dif = ( - color1.green() - color2.green() - ) - blue_dif = ( - color1.blue() - color2.blue() - ) - red = int(color2.red() + ( - red_dif * offset_ratio - )) - green = int(color2.green() + ( - green_dif * offset_ratio - )) - blue = int(color2.blue() + ( - blue_dif * offset_ratio - )) + red_dif = color1.red() - color2.red() + green_dif = color1.green() - color2.green() + blue_dif = color1.blue() - color2.blue() + + red = int(color2.red() + (red_dif * offset_ratio)) + green = int(color2.green() + (green_dif * offset_ratio)) + blue = int(color2.blue() + (blue_dif * offset_ratio)) return QtGui.QColor(red, green, blue) @@ -334,20 +296,28 @@ class NiceCheckbox(QtWidgets.QFrame): painter = QtGui.QPainter(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) + painter.setPen(QtCore.Qt.NoPen) # Draw inner background - if self._current_step == self._steps: - bg_color = self.checked_bg_color + if not self.isEnabled(): + bg_color = ( + self._checked_bg_color_disabled + if self._current_step == self._steps + else self._unchecked_bg_color_disabled + ) + + elif self._current_step == self._steps: + bg_color = self._checked_bg_color elif self._current_step == 0: - bg_color = self.unchecked_bg_color + bg_color = self._unchecked_bg_color else: offset_ratio = float(self._current_step) / self._steps # Animation bg bg_color = self.steped_color( - self.checked_bg_color, - self.unchecked_bg_color, + self._checked_bg_color, + self._unchecked_bg_color, offset_ratio ) @@ -378,14 +348,20 @@ class NiceCheckbox(QtWidgets.QFrame): -margin_size_c, -margin_size_c ) - if checkbox_rect.width() > checkbox_rect.height(): - radius = floor(checkbox_rect.height() * 0.5) - else: - radius = floor(checkbox_rect.width() * 0.5) + slider_rect = QtCore.QRect(checkbox_rect) + slider_offset = int( + ceil(min(slider_rect.width(), slider_rect.height())) * 0.08 + ) + if slider_offset < 1: + slider_offset = 1 + slider_rect.adjust( + slider_offset, slider_offset, + -slider_offset, -slider_offset + ) + radius = floor(min(slider_rect.width(), slider_rect.height()) * 0.5) - painter.setPen(QtCore.Qt.NoPen) painter.setBrush(bg_color) - painter.drawRoundedRect(checkbox_rect, radius, radius) + painter.drawRoundedRect(slider_rect, radius, radius) # Draw checker checker_size = size_without_margins - (margin_size_c * 2) @@ -394,9 +370,8 @@ class NiceCheckbox(QtWidgets.QFrame): - (margin_size_c * 2) - checker_size ) - if self._current_step == 0: - x_offset = 0 - else: + x_offset = 0 + if self._current_step != 0: x_offset = (float(area_width) / self._steps) * self._current_step pos_x = checkbox_rect.x() + x_offset + margin_size_c @@ -404,55 +379,80 @@ class NiceCheckbox(QtWidgets.QFrame): checker_rect = QtCore.QRect(pos_x, pos_y, checker_size, checker_size) - under_mouse = self.isEnabled() and self._under_mouse - if under_mouse: - checker_color = self.checker_hover_color - else: - checker_color = self.checker_color + checker_color = self._checker_color + if not self.isEnabled(): + checker_color = self._checker_color_disabled + elif self._under_mouse: + checker_color = self._checker_hover_color painter.setBrush(checker_color) painter.drawEllipse(checker_rect) if self._draw_icons: painter.setBrush(bg_color) - icon_path = self._get_icon_path(painter, checker_rect) + icon_path = self._get_icon_path(checker_rect) painter.drawPath(icon_path) - # Draw shadow overlay - if not self.isEnabled(): - level = 33 - alpha = 127 - painter.setPen(QtCore.Qt.transparent) - painter.setBrush(QtGui.QColor(level, level, level, alpha)) - painter.drawRoundedRect(checkbox_rect, radius, radius) - painter.end() - def _get_icon_path(self, painter, checker_rect): + @classmethod + def _load_colors(cls): + if cls._checked_bg_color is not None: + return + + colors_info = get_objected_colors("nice-checkbox") + + disabled_color = QtGui.QColor(33, 33, 33, 127) + + cls._checked_bg_color = colors_info["bg-checked"].get_qcolor() + cls._checked_bg_color_disabled = cls._merge_colors( + cls._checked_bg_color, disabled_color + ) + cls._unchecked_bg_color = colors_info["bg-unchecked"].get_qcolor() + cls._unchecked_bg_color_disabled = cls._merge_colors( + cls._unchecked_bg_color, disabled_color + ) + + cls._checker_color = colors_info["bg-checker"].get_qcolor() + cls._checker_color_disabled = cls._merge_colors( + cls._checker_color, disabled_color + ) + cls._checker_hover_color = colors_info["bg-checker-hover"].get_qcolor() + + @staticmethod + def _merge_colors(color_1, color_2): + a = color_2.alphaF() + return QtGui.QColor( + floor((color_1.red() + (color_2.red() * a)) * 0.5), + floor((color_1.green() + (color_2.green() * a)) * 0.5), + floor((color_1.blue() + (color_2.blue() * a)) * 0.5), + color_1.alpha() + ) + + def _get_icon_path(self, checker_rect): self.icon_path_stroker.setWidth(checker_rect.height() / 5) if self._current_step == self._steps: - return self._get_enabled_icon_path(painter, checker_rect) + return self._get_enabled_icon_path(checker_rect) if self._current_step == 0: - return self._get_disabled_icon_path(painter, checker_rect) + return self._get_disabled_icon_path(checker_rect) if self._current_step == self._middle_step: - return self._get_middle_circle_path(painter, checker_rect) + return self._get_middle_circle_path(checker_rect) disabled_step = self._steps - self._current_step enabled_step = self._steps - disabled_step half_steps = self._steps + 1 - ((self._steps + 1) % 2) if enabled_step > disabled_step: return self._get_enabled_icon_path( - painter, checker_rect, enabled_step, half_steps - ) - else: - return self._get_disabled_icon_path( - painter, checker_rect, disabled_step, half_steps + checker_rect, enabled_step, half_steps ) + return self._get_disabled_icon_path( + checker_rect, disabled_step, half_steps + ) - def _get_middle_circle_path(self, painter, checker_rect): + def _get_middle_circle_path(self, checker_rect): width = self.icon_path_stroker.width() path = QtGui.QPainterPath() path.addEllipse(checker_rect.center(), width, width) @@ -460,7 +460,7 @@ class NiceCheckbox(QtWidgets.QFrame): return path def _get_enabled_icon_path( - self, painter, checker_rect, step=None, half_steps=None + self, checker_rect, step=None, half_steps=None ): fifteenth = float(checker_rect.height()) / 15 # Left point @@ -509,7 +509,7 @@ class NiceCheckbox(QtWidgets.QFrame): return self.icon_path_stroker.createStroke(path) def _get_disabled_icon_path( - self, painter, checker_rect, step=None, half_steps=None + self, checker_rect, step=None, half_steps=None ): center_point = QtCore.QPointF( float(checker_rect.width()) / 2, From f4855402cf82e44554df9d471d82366c2637a2eb Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 16:50:38 +0200 Subject: [PATCH 182/319] remove unused import --- client/ayon_core/tools/utils/nice_checkbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/utils/nice_checkbox.py b/client/ayon_core/tools/utils/nice_checkbox.py index d1cc8d16f5..f16b62eb9c 100644 --- a/client/ayon_core/tools/utils/nice_checkbox.py +++ b/client/ayon_core/tools/utils/nice_checkbox.py @@ -2,7 +2,7 @@ from math import floor, ceil from qtpy import QtWidgets, QtCore, QtGui -from ayon_core.style import load_stylesheet, get_objected_colors +from ayon_core.style import get_objected_colors class NiceCheckbox(QtWidgets.QFrame): From 40e8384b1cb33c0771e62eba7b0dedaac9e28e94 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 16:50:44 +0200 Subject: [PATCH 183/319] formatting fix --- client/ayon_core/tools/utils/nice_checkbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/utils/nice_checkbox.py b/client/ayon_core/tools/utils/nice_checkbox.py index f16b62eb9c..c33533b0e4 100644 --- a/client/ayon_core/tools/utils/nice_checkbox.py +++ b/client/ayon_core/tools/utils/nice_checkbox.py @@ -358,7 +358,7 @@ class NiceCheckbox(QtWidgets.QFrame): slider_offset, slider_offset, -slider_offset, -slider_offset ) - radius = floor(min(slider_rect.width(), slider_rect.height()) * 0.5) + radius = floor(min(slider_rect.width(), slider_rect.height()) * 0.5) painter.setBrush(bg_color) painter.drawRoundedRect(slider_rect, radius, radius) From 65672ccafdd362be171bd48c01c01a8349ac2089 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:15:07 +0200 Subject: [PATCH 184/319] removed legacy create tool --- client/ayon_core/tools/creator/model.py | 2 - client/ayon_core/tools/creator/window.py | 1 - client/ayon_core/tools/utils/host_tools.py | 60 +++++----------------- 3 files changed, 14 insertions(+), 49 deletions(-) diff --git a/client/ayon_core/tools/creator/model.py b/client/ayon_core/tools/creator/model.py index bf6c7380a1..16d24cc8bc 100644 --- a/client/ayon_core/tools/creator/model.py +++ b/client/ayon_core/tools/creator/model.py @@ -1,8 +1,6 @@ import uuid from qtpy import QtGui, QtCore -from ayon_core.pipeline import discover_legacy_creator_plugins - from . constants import ( PRODUCT_TYPE_ROLE, ITEM_ID_ROLE diff --git a/client/ayon_core/tools/creator/window.py b/client/ayon_core/tools/creator/window.py index 5d1c0a272a..fe8ee86dcf 100644 --- a/client/ayon_core/tools/creator/window.py +++ b/client/ayon_core/tools/creator/window.py @@ -15,7 +15,6 @@ from ayon_core.pipeline import ( ) from ayon_core.pipeline.create import ( PRODUCT_NAME_ALLOWED_SYMBOLS, - legacy_create, CreatorError, ) diff --git a/client/ayon_core/tools/utils/host_tools.py b/client/ayon_core/tools/utils/host_tools.py index 3d356555f3..bfd008925b 100644 --- a/client/ayon_core/tools/utils/host_tools.py +++ b/client/ayon_core/tools/utils/host_tools.py @@ -31,7 +31,6 @@ class HostToolsHelper: # Prepare attributes for all tools self._workfiles_tool = None self._loader_tool = None - self._creator_tool = None self._publisher_tool = None self._subset_manager_tool = None self._scene_inventory_tool = None @@ -96,27 +95,6 @@ class HostToolsHelper: loader_tool.refresh() - def get_creator_tool(self, parent): - """Create, cache and return creator tool window.""" - if self._creator_tool is None: - from ayon_core.tools.creator import CreatorWindow - - creator_window = CreatorWindow(parent=parent or self._parent) - self._creator_tool = creator_window - - return self._creator_tool - - def show_creator(self, parent=None): - """Show tool to create new instantes for publishing.""" - with qt_app_context(): - creator_tool = self.get_creator_tool(parent) - creator_tool.refresh() - creator_tool.show() - - # Pull window to the front. - creator_tool.raise_() - creator_tool.activateWindow() - def get_subset_manager_tool(self, parent): """Create, cache and return subset manager tool window.""" if self._subset_manager_tool is None: @@ -261,35 +239,32 @@ class HostToolsHelper: if tool_name == "workfiles": return self.get_workfiles_tool(parent, *args, **kwargs) - elif tool_name == "loader": + if tool_name == "loader": return self.get_loader_tool(parent, *args, **kwargs) - elif tool_name == "libraryloader": + if tool_name == "libraryloader": return self.get_library_loader_tool(parent, *args, **kwargs) - elif tool_name == "creator": - return self.get_creator_tool(parent, *args, **kwargs) - - elif tool_name == "subsetmanager": + if tool_name == "subsetmanager": return self.get_subset_manager_tool(parent, *args, **kwargs) - elif tool_name == "sceneinventory": + if tool_name == "sceneinventory": return self.get_scene_inventory_tool(parent, *args, **kwargs) - elif tool_name == "publish": - self.log.info("Can't return publish tool window.") - - # "new" publisher - elif tool_name == "publisher": + if tool_name == "publisher": return self.get_publisher_tool(parent, *args, **kwargs) - elif tool_name == "experimental_tools": + if tool_name == "experimental_tools": return self.get_experimental_tools_dialog(parent, *args, **kwargs) - else: - self.log.warning( - "Can't show unknown tool name: \"{}\"".format(tool_name) - ) + if tool_name == "publish": + self.log.info("Can't return publish tool window.") + return None + + self.log.warning( + "Can't show unknown tool name: \"{}\"".format(tool_name) + ) + return None def show_tool_by_name(self, tool_name, parent=None, *args, **kwargs): """Show tool by it's name. @@ -305,9 +280,6 @@ class HostToolsHelper: elif tool_name == "libraryloader": self.show_library_loader(parent, *args, **kwargs) - elif tool_name == "creator": - self.show_creator(parent, *args, **kwargs) - elif tool_name == "subsetmanager": self.show_subset_manager(parent, *args, **kwargs) @@ -379,10 +351,6 @@ def show_library_loader(parent=None): _SingletonPoint.show_tool_by_name("libraryloader", parent) -def show_creator(parent=None): - _SingletonPoint.show_tool_by_name("creator", parent) - - def show_subset_manager(parent=None): _SingletonPoint.show_tool_by_name("subsetmanager", parent) From 81d30462e26d4ae05f853c06fe23c00f7ba5946f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:15:31 +0200 Subject: [PATCH 185/319] removed legacy create and related functions --- client/ayon_core/pipeline/__init__.py | 8 - client/ayon_core/pipeline/create/__init__.py | 14 -- .../pipeline/create/creator_plugins.py | 58 ----- .../pipeline/create/legacy_create.py | 216 ------------------ 4 files changed, 296 deletions(-) delete mode 100644 client/ayon_core/pipeline/create/legacy_create.py diff --git a/client/ayon_core/pipeline/__init__.py b/client/ayon_core/pipeline/__init__.py index 137736c302..65ad55d06e 100644 --- a/client/ayon_core/pipeline/__init__.py +++ b/client/ayon_core/pipeline/__init__.py @@ -19,9 +19,6 @@ from .create import ( CreatedInstance, CreatorError, - LegacyCreator, - legacy_create, - discover_creator_plugins, discover_legacy_creator_plugins, register_creator_plugin, @@ -141,12 +138,7 @@ __all__ = ( "CreatorError", - # - legacy creation - "LegacyCreator", - "legacy_create", - "discover_creator_plugins", - "discover_legacy_creator_plugins", "register_creator_plugin", "deregister_creator_plugin", "register_creator_plugin_path", diff --git a/client/ayon_core/pipeline/create/__init__.py b/client/ayon_core/pipeline/create/__init__.py index ced43528eb..2f076b63f6 100644 --- a/client/ayon_core/pipeline/create/__init__.py +++ b/client/ayon_core/pipeline/create/__init__.py @@ -44,9 +44,6 @@ from .creator_plugins import ( AutoCreator, HiddenCreator, - discover_legacy_creator_plugins, - get_legacy_creator_by_name, - discover_creator_plugins, register_creator_plugin, deregister_creator_plugin, @@ -58,11 +55,6 @@ from .creator_plugins import ( from .context import CreateContext -from .legacy_create import ( - LegacyCreator, - legacy_create, -) - __all__ = ( "PRODUCT_NAME_ALLOWED_SYMBOLS", @@ -105,9 +97,6 @@ __all__ = ( "AutoCreator", "HiddenCreator", - "discover_legacy_creator_plugins", - "get_legacy_creator_by_name", - "discover_creator_plugins", "register_creator_plugin", "deregister_creator_plugin", @@ -117,7 +106,4 @@ __all__ = ( "cache_and_get_instances", "CreateContext", - - "LegacyCreator", - "legacy_create", ) diff --git a/client/ayon_core/pipeline/create/creator_plugins.py b/client/ayon_core/pipeline/create/creator_plugins.py index cbc06145fb..b890704649 100644 --- a/client/ayon_core/pipeline/create/creator_plugins.py +++ b/client/ayon_core/pipeline/create/creator_plugins.py @@ -20,7 +20,6 @@ from ayon_core.pipeline.staging_dir import get_staging_dir_info, StagingDir from .constants import DEFAULT_VARIANT_VALUE from .product_name import get_product_name from .utils import get_next_versions_for_instances -from .legacy_create import LegacyCreator from .structures import CreatedInstance if TYPE_CHECKING: @@ -975,62 +974,10 @@ def discover_convertor_plugins(*args, **kwargs): return discover(ProductConvertorPlugin, *args, **kwargs) -def discover_legacy_creator_plugins(): - from ayon_core.pipeline import get_current_project_name - - log = Logger.get_logger("CreatorDiscover") - - plugins = discover(LegacyCreator) - project_name = get_current_project_name() - project_settings = get_project_settings(project_name) - for plugin in plugins: - try: - plugin.apply_settings(project_settings) - except Exception: - log.warning( - "Failed to apply settings to creator {}".format( - plugin.__name__ - ), - exc_info=True - ) - return plugins - - -def get_legacy_creator_by_name(creator_name, case_sensitive=False): - """Find creator plugin by name. - - Args: - creator_name (str): Name of creator class that should be returned. - case_sensitive (bool): Match of creator plugin name is case sensitive. - Set to `False` by default. - - Returns: - Creator: Return first matching plugin or `None`. - """ - - # Lower input creator name if is not case sensitive - if not case_sensitive: - creator_name = creator_name.lower() - - for creator_plugin in discover_legacy_creator_plugins(): - _creator_name = creator_plugin.__name__ - - # Lower creator plugin name if is not case sensitive - if not case_sensitive: - _creator_name = _creator_name.lower() - - if _creator_name == creator_name: - return creator_plugin - return None - - def register_creator_plugin(plugin): if issubclass(plugin, BaseCreator): register_plugin(BaseCreator, plugin) - elif issubclass(plugin, LegacyCreator): - register_plugin(LegacyCreator, plugin) - elif issubclass(plugin, ProductConvertorPlugin): register_plugin(ProductConvertorPlugin, plugin) @@ -1039,22 +986,17 @@ def deregister_creator_plugin(plugin): if issubclass(plugin, BaseCreator): deregister_plugin(BaseCreator, plugin) - elif issubclass(plugin, LegacyCreator): - deregister_plugin(LegacyCreator, plugin) - elif issubclass(plugin, ProductConvertorPlugin): deregister_plugin(ProductConvertorPlugin, plugin) def register_creator_plugin_path(path): register_plugin_path(BaseCreator, path) - register_plugin_path(LegacyCreator, path) register_plugin_path(ProductConvertorPlugin, path) def deregister_creator_plugin_path(path): deregister_plugin_path(BaseCreator, path) - deregister_plugin_path(LegacyCreator, path) deregister_plugin_path(ProductConvertorPlugin, path) diff --git a/client/ayon_core/pipeline/create/legacy_create.py b/client/ayon_core/pipeline/create/legacy_create.py deleted file mode 100644 index f6427d9bd1..0000000000 --- a/client/ayon_core/pipeline/create/legacy_create.py +++ /dev/null @@ -1,216 +0,0 @@ -"""Create workflow moved from avalon-core repository. - -Renamed classes and functions -- 'Creator' -> 'LegacyCreator' -- 'create' -> 'legacy_create' -""" - -import os -import logging -import collections - -from ayon_core.pipeline.constants import AYON_INSTANCE_ID - -from .product_name import get_product_name - - -class LegacyCreator: - """Determine how assets are created""" - label = None - product_type = None - defaults = None - maintain_selection = True - enabled = True - - dynamic_product_name_keys = [] - - log = logging.getLogger("LegacyCreator") - log.propagate = True - - def __init__(self, name, folder_path, options=None, data=None): - self.name = name # For backwards compatibility - self.options = options - - # Default data - self.data = collections.OrderedDict() - # TODO use 'AYON_INSTANCE_ID' when all hosts support it - self.data["id"] = AYON_INSTANCE_ID - self.data["productType"] = self.product_type - self.data["folderPath"] = folder_path - self.data["productName"] = name - self.data["active"] = True - - self.data.update(data or {}) - - @classmethod - def apply_settings(cls, project_settings): - """Apply AYON settings to a plugin class.""" - - host_name = os.environ.get("AYON_HOST_NAME") - plugin_type = "create" - plugin_type_settings = ( - project_settings - .get(host_name, {}) - .get(plugin_type, {}) - ) - global_type_settings = ( - project_settings - .get("core", {}) - .get(plugin_type, {}) - ) - if not global_type_settings and not plugin_type_settings: - return - - plugin_name = cls.__name__ - - plugin_settings = None - # Look for plugin settings in host specific settings - if plugin_name in plugin_type_settings: - plugin_settings = plugin_type_settings[plugin_name] - - # Look for plugin settings in global settings - elif plugin_name in global_type_settings: - plugin_settings = global_type_settings[plugin_name] - - if not plugin_settings: - return - - cls.log.debug(">>> We have preset for {}".format(plugin_name)) - for option, value in plugin_settings.items(): - if option == "enabled" and value is False: - cls.log.debug(" - is disabled by preset") - else: - cls.log.debug(" - setting `{}`: `{}`".format(option, value)) - setattr(cls, option, value) - - def process(self): - pass - - @classmethod - def get_dynamic_data( - cls, project_name, folder_entity, task_entity, variant, host_name - ): - """Return dynamic data for current Creator plugin. - - By default return keys from `dynamic_product_name_keys` attribute - as mapping to keep formatted template unchanged. - - ``` - dynamic_product_name_keys = ["my_key"] - --- - output = { - "my_key": "{my_key}" - } - ``` - - Dynamic keys may override default Creator keys (productType, task, - folderPath, ...) but do it wisely if you need. - - All of keys will be converted into 3 variants unchanged, capitalized - and all upper letters. Because of that are all keys lowered. - - This method can be modified to prefill some values just keep in mind it - is class method. - - Args: - project_name (str): Context's project name. - folder_entity (dict[str, Any]): Folder entity. - task_entity (dict[str, Any]): Task entity. - variant (str): What is entered by user in creator tool. - host_name (str): Name of host. - - Returns: - dict: Fill data for product name template. - """ - dynamic_data = {} - for key in cls.dynamic_product_name_keys: - key = key.lower() - dynamic_data[key] = "{" + key + "}" - return dynamic_data - - @classmethod - def get_product_name( - cls, project_name, folder_entity, task_entity, variant, host_name=None - ): - """Return product name created with entered arguments. - - Logic extracted from Creator tool. This method should give ability - to get product name without the tool. - - TODO: Maybe change `variant` variable. - - By default is output concatenated product type with variant. - - Args: - project_name (str): Context's project name. - folder_entity (dict[str, Any]): Folder entity. - task_entity (dict[str, Any]): Task entity. - variant (str): What is entered by user in creator tool. - host_name (str): Name of host. - - Returns: - str: Formatted product name with entered arguments. Should match - config's logic. - """ - - dynamic_data = cls.get_dynamic_data( - project_name, folder_entity, task_entity, variant, host_name - ) - task_name = task_type = None - if task_entity: - task_name = task_entity["name"] - task_type = task_entity["taskType"] - return get_product_name( - project_name, - task_name, - task_type, - host_name, - cls.product_type, - variant, - dynamic_data=dynamic_data - ) - - -def legacy_create( - Creator, product_name, folder_path, options=None, data=None -): - """Create a new instance - - Associate nodes with a product name and type. These nodes are later - validated, according to their `product type`, and integrated into the - shared environment, relative their `productName`. - - Data relative each product type, along with default data, are imprinted - into the resulting objectSet. This data is later used by extractors - and finally asset browsers to help identify the origin of the asset. - - Arguments: - Creator (Creator): Class of creator. - product_name (str): Name of product. - folder_path (str): Folder path. - options (dict, optional): Additional options from GUI. - data (dict, optional): Additional data from GUI. - - Raises: - NameError on `productName` already exists - KeyError on invalid dynamic property - RuntimeError on host error - - Returns: - Name of instance - - """ - from ayon_core.pipeline import registered_host - - host = registered_host() - plugin = Creator(product_name, folder_path, options, data) - - if plugin.maintain_selection is True: - with host.maintained_selection(): - print("Running %s with maintained selection" % plugin) - instance = plugin.process() - return instance - - print("Running %s" % plugin) - instance = plugin.process() - return instance From 027f148b102d464e8097173f4ff365cb0fa25125 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:16:11 +0200 Subject: [PATCH 186/319] remove legacy creators logic from template builder --- .../workfile/workfile_template_builder.py | 44 ++++--------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index e2add99752..37f76a2268 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -54,7 +54,6 @@ from ayon_core.pipeline.plugin_discover import ( ) from ayon_core.pipeline.create import ( - discover_legacy_creator_plugins, CreateContext, HiddenCreator, ) @@ -131,7 +130,6 @@ class AbstractTemplateBuilder(ABC): """ _log = None - use_legacy_creators = False def __init__(self, host): # Get host name @@ -321,19 +319,6 @@ class AbstractTemplateBuilder(ABC): return list(get_folders(project_name, folder_ids=linked_folder_ids)) - def _collect_legacy_creators(self): - creators_by_name = {} - for creator in discover_legacy_creator_plugins(): - if not creator.enabled: - continue - creator_name = creator.__name__ - if creator_name in creators_by_name: - raise KeyError( - "Duplicated creator name {} !".format(creator_name) - ) - creators_by_name[creator_name] = creator - self._creators_by_name = creators_by_name - def _collect_creators(self): self._creators_by_name = { identifier: creator @@ -345,10 +330,7 @@ class AbstractTemplateBuilder(ABC): def get_creators_by_name(self): if self._creators_by_name is None: - if self.use_legacy_creators: - self._collect_legacy_creators() - else: - self._collect_creators() + self._collect_creators() return self._creators_by_name @@ -1938,8 +1920,6 @@ class PlaceholderCreateMixin(object): pre_create_data (dict): dictionary of configuration from Creator configuration in UI """ - - legacy_create = self.builder.use_legacy_creators creator_name = placeholder.data["creator"] create_variant = placeholder.data["create_variant"] active = placeholder.data.get("active") @@ -1979,20 +1959,14 @@ class PlaceholderCreateMixin(object): # compile product name from variant try: - if legacy_create: - creator_instance = creator_plugin( - product_name, - folder_path - ).process() - else: - creator_instance = self.builder.create_context.create( - creator_plugin.identifier, - create_variant, - folder_entity, - task_entity, - pre_create_data=pre_create_data, - active=active - ) + creator_instance = self.builder.create_context.create( + creator_plugin.identifier, + create_variant, + folder_entity, + task_entity, + pre_create_data=pre_create_data, + active=active + ) except: # noqa: E722 failed = True From 94a55d588bc94d9f6f17564bdd5d1e798d29f5be Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:21:53 +0200 Subject: [PATCH 187/319] removed subset manager tool --- .../ayon_core/tools/subsetmanager/README.md | 19 -- .../ayon_core/tools/subsetmanager/__init__.py | 9 - client/ayon_core/tools/subsetmanager/model.py | 56 ----- .../ayon_core/tools/subsetmanager/widgets.py | 110 --------- .../ayon_core/tools/subsetmanager/window.py | 218 ------------------ client/ayon_core/tools/utils/host_tools.py | 33 --- 6 files changed, 445 deletions(-) delete mode 100644 client/ayon_core/tools/subsetmanager/README.md delete mode 100644 client/ayon_core/tools/subsetmanager/__init__.py delete mode 100644 client/ayon_core/tools/subsetmanager/model.py delete mode 100644 client/ayon_core/tools/subsetmanager/widgets.py delete mode 100644 client/ayon_core/tools/subsetmanager/window.py diff --git a/client/ayon_core/tools/subsetmanager/README.md b/client/ayon_core/tools/subsetmanager/README.md deleted file mode 100644 index 35b80ea114..0000000000 --- a/client/ayon_core/tools/subsetmanager/README.md +++ /dev/null @@ -1,19 +0,0 @@ -Subset manager --------------- - -Simple UI showing list of created subset that will be published via Pyblish. -Useful for applications (Photoshop, AfterEffects, TVPaint, Harmony) which are -storing metadata about instance hidden from user. - -This UI allows listing all created subset and removal of them if needed ( -in case use doesn't want to publish anymore, its using workfile as a starting -file for different task and instances should be completely different etc. -) - -Host is expected to implemented: -- `list_instances` - returning list of dictionaries (instances), must contain - unique uuid field - example: - ```[{"uuid":"15","active":true,"subset":"imageBG","family":"image","id":"ayon.create.instance","asset":"Town"}]``` -- `remove_instance(instance)` - removes instance from file's metadata - instance is a dictionary, with uuid field \ No newline at end of file diff --git a/client/ayon_core/tools/subsetmanager/__init__.py b/client/ayon_core/tools/subsetmanager/__init__.py deleted file mode 100644 index 6cfca7db66..0000000000 --- a/client/ayon_core/tools/subsetmanager/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -from .window import ( - show, - SubsetManagerWindow -) - -__all__ = ( - "show", - "SubsetManagerWindow" -) diff --git a/client/ayon_core/tools/subsetmanager/model.py b/client/ayon_core/tools/subsetmanager/model.py deleted file mode 100644 index 4964abd86d..0000000000 --- a/client/ayon_core/tools/subsetmanager/model.py +++ /dev/null @@ -1,56 +0,0 @@ -import uuid - -from qtpy import QtCore, QtGui - -from ayon_core.pipeline import registered_host - -ITEM_ID_ROLE = QtCore.Qt.UserRole + 1 - - -class InstanceModel(QtGui.QStandardItemModel): - def __init__(self, *args, **kwargs): - super(InstanceModel, self).__init__(*args, **kwargs) - self._instances_by_item_id = {} - - def get_instance_by_id(self, item_id): - return self._instances_by_item_id.get(item_id) - - def refresh(self): - self.clear() - - self._instances_by_item_id = {} - - instances = None - host = registered_host() - list_instances = getattr(host, "list_instances", None) - if list_instances: - instances = list_instances() - - if not instances: - return - - items = [] - for instance_data in instances: - item_id = str(uuid.uuid4()) - product_name = ( - instance_data.get("productName") - or instance_data.get("subset") - ) - label = instance_data.get("label") or product_name - item = QtGui.QStandardItem(label) - item.setEnabled(True) - item.setEditable(False) - item.setData(item_id, ITEM_ID_ROLE) - items.append(item) - self._instances_by_item_id[item_id] = instance_data - - if items: - self.invisibleRootItem().appendRows(items) - - def headerData(self, section, orientation, role): - if role == QtCore.Qt.DisplayRole and section == 0: - return "Instance" - - return super(InstanceModel, self).headerData( - section, orientation, role - ) diff --git a/client/ayon_core/tools/subsetmanager/widgets.py b/client/ayon_core/tools/subsetmanager/widgets.py deleted file mode 100644 index 1067474c44..0000000000 --- a/client/ayon_core/tools/subsetmanager/widgets.py +++ /dev/null @@ -1,110 +0,0 @@ -import json -from qtpy import QtWidgets, QtCore - - -class InstanceDetail(QtWidgets.QWidget): - save_triggered = QtCore.Signal() - - def __init__(self, parent=None): - super(InstanceDetail, self).__init__(parent) - - details_widget = QtWidgets.QPlainTextEdit(self) - details_widget.setObjectName("SubsetManagerDetailsText") - - save_btn = QtWidgets.QPushButton("Save", self) - - self._block_changes = False - self._editable = False - self._item_id = None - - layout = QtWidgets.QVBoxLayout(self) - layout.setContentsMargins(0, 0, 0, 0) - layout.addWidget(details_widget, 1) - layout.addWidget(save_btn, 0, QtCore.Qt.AlignRight) - - save_btn.clicked.connect(self._on_save_clicked) - details_widget.textChanged.connect(self._on_text_change) - - self._details_widget = details_widget - self._save_btn = save_btn - - self.set_editable(False) - - def _on_save_clicked(self): - if self.is_valid(): - self.save_triggered.emit() - - def set_editable(self, enabled=True): - self._editable = enabled - self.update_state() - - def update_state(self, valid=None): - editable = self._editable - if not self._item_id: - editable = False - - self._save_btn.setVisible(editable) - self._details_widget.setReadOnly(not editable) - if valid is None: - valid = self.is_valid() - - self._save_btn.setEnabled(valid) - self._set_invalid_detail(valid) - - def _set_invalid_detail(self, valid): - state = "" - if not valid: - state = "invalid" - - current_state = self._details_widget.property("state") - if current_state != state: - self._details_widget.setProperty("state", state) - self._details_widget.style().polish(self._details_widget) - - def set_details(self, container, item_id): - self._item_id = item_id - - text = "Nothing selected" - if item_id: - try: - text = json.dumps(container, indent=4) - except Exception: - text = str(container) - - self._block_changes = True - self._details_widget.setPlainText(text) - self._block_changes = False - - self.update_state() - - def instance_data_from_text(self): - try: - jsoned = json.loads(self._details_widget.toPlainText()) - except Exception: - jsoned = None - return jsoned - - def item_id(self): - return self._item_id - - def is_valid(self): - if not self._item_id: - return True - - value = self._details_widget.toPlainText() - valid = False - try: - jsoned = json.loads(value) - if jsoned and isinstance(jsoned, dict): - valid = True - - except Exception: - pass - return valid - - def _on_text_change(self): - if self._block_changes or not self._item_id: - return - - valid = self.is_valid() - self.update_state(valid) diff --git a/client/ayon_core/tools/subsetmanager/window.py b/client/ayon_core/tools/subsetmanager/window.py deleted file mode 100644 index 164ffa95a7..0000000000 --- a/client/ayon_core/tools/subsetmanager/window.py +++ /dev/null @@ -1,218 +0,0 @@ -import os -import sys - -from qtpy import QtWidgets, QtCore -import qtawesome - -from ayon_core import style -from ayon_core.pipeline import registered_host -from ayon_core.tools.utils import PlaceholderLineEdit -from ayon_core.tools.utils.lib import ( - iter_model_rows, - qt_app_context -) -from ayon_core.tools.utils.models import RecursiveSortFilterProxyModel -from .model import ( - InstanceModel, - ITEM_ID_ROLE -) -from .widgets import InstanceDetail - - -module = sys.modules[__name__] -module.window = None - - -class SubsetManagerWindow(QtWidgets.QDialog): - def __init__(self, parent=None): - super(SubsetManagerWindow, self).__init__(parent=parent) - self.setWindowTitle("Subset Manager 0.1") - self.setObjectName("SubsetManager") - if not parent: - self.setWindowFlags( - self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint - ) - - self.resize(780, 430) - - # Trigger refresh on first called show - self._first_show = True - - left_side_widget = QtWidgets.QWidget(self) - - # Header part - header_widget = QtWidgets.QWidget(left_side_widget) - - # Filter input - filter_input = PlaceholderLineEdit(header_widget) - filter_input.setPlaceholderText("Filter products..") - - # Refresh button - icon = qtawesome.icon("fa.refresh", color="white") - refresh_btn = QtWidgets.QPushButton(header_widget) - refresh_btn.setIcon(icon) - - header_layout = QtWidgets.QHBoxLayout(header_widget) - header_layout.setContentsMargins(0, 0, 0, 0) - header_layout.addWidget(filter_input) - header_layout.addWidget(refresh_btn) - - # Instances view - view = QtWidgets.QTreeView(left_side_widget) - view.setIndentation(0) - view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - - model = InstanceModel(view) - proxy = RecursiveSortFilterProxyModel() - proxy.setSourceModel(model) - proxy.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive) - - view.setModel(proxy) - - left_side_layout = QtWidgets.QVBoxLayout(left_side_widget) - left_side_layout.setContentsMargins(0, 0, 0, 0) - left_side_layout.addWidget(header_widget) - left_side_layout.addWidget(view) - - details_widget = InstanceDetail(self) - - layout = QtWidgets.QHBoxLayout(self) - layout.addWidget(left_side_widget, 0) - layout.addWidget(details_widget, 1) - - filter_input.textChanged.connect(proxy.setFilterFixedString) - refresh_btn.clicked.connect(self._on_refresh_clicked) - view.clicked.connect(self._on_activated) - view.customContextMenuRequested.connect(self.on_context_menu) - details_widget.save_triggered.connect(self._on_save) - - self._model = model - self._proxy = proxy - self._view = view - self._details_widget = details_widget - self._refresh_btn = refresh_btn - - def _on_refresh_clicked(self): - self.refresh() - - def _on_activated(self, index): - container = None - item_id = None - if index.isValid(): - item_id = index.data(ITEM_ID_ROLE) - container = self._model.get_instance_by_id(item_id) - - self._details_widget.set_details(container, item_id) - - def _on_save(self): - host = registered_host() - if not hasattr(host, "save_instances"): - print("BUG: Host does not have \"save_instances\" method") - return - - current_index = self._view.selectionModel().currentIndex() - if not current_index.isValid(): - return - - item_id = current_index.data(ITEM_ID_ROLE) - if item_id != self._details_widget.item_id(): - return - - item_data = self._details_widget.instance_data_from_text() - new_instances = [] - for index in iter_model_rows(self._model, 0): - _item_id = index.data(ITEM_ID_ROLE) - if _item_id == item_id: - instance_data = item_data - else: - instance_data = self._model.get_instance_by_id(item_id) - new_instances.append(instance_data) - - host.save_instances(new_instances) - - def on_context_menu(self, point): - point_index = self._view.indexAt(point) - item_id = point_index.data(ITEM_ID_ROLE) - instance_data = self._model.get_instance_by_id(item_id) - if instance_data is None: - return - - # Prepare menu - menu = QtWidgets.QMenu(self) - actions = [] - host = registered_host() - if hasattr(host, "remove_instance"): - action = QtWidgets.QAction("Remove instance", menu) - action.setData(host.remove_instance) - actions.append(action) - - if hasattr(host, "select_instance"): - action = QtWidgets.QAction("Select instance", menu) - action.setData(host.select_instance) - actions.append(action) - - if not actions: - actions.append(QtWidgets.QAction("* Nothing to do", menu)) - - for action in actions: - menu.addAction(action) - - # Show menu under mouse - global_point = self._view.mapToGlobal(point) - action = menu.exec_(global_point) - if not action or not action.data(): - return - - # Process action - # TODO catch exceptions - function = action.data() - function(instance_data) - - # Reset modified data - self.refresh() - - def refresh(self): - self._details_widget.set_details(None, None) - self._model.refresh() - - host = registered_host() - dev_mode = os.environ.get("AVALON_DEVELOP_MODE") or "" - editable = False - if dev_mode.lower() in ("1", "yes", "true", "on"): - editable = hasattr(host, "save_instances") - self._details_widget.set_editable(editable) - - def showEvent(self, *args, **kwargs): - super(SubsetManagerWindow, self).showEvent(*args, **kwargs) - if self._first_show: - self._first_show = False - self.setStyleSheet(style.load_stylesheet()) - self.refresh() - - -def show(root=None, debug=False, parent=None): - """Display Scene Inventory GUI - - Arguments: - debug (bool, optional): Run in debug-mode, - defaults to False - parent (QtCore.QObject, optional): When provided parent the interface - to this QObject. - - """ - - try: - module.window.close() - del module.window - except (RuntimeError, AttributeError): - pass - - with qt_app_context(): - window = SubsetManagerWindow(parent) - window.show() - - module.window = window - - # Pull window to the front. - module.window.raise_() - module.window.activateWindow() diff --git a/client/ayon_core/tools/utils/host_tools.py b/client/ayon_core/tools/utils/host_tools.py index 3d356555f3..94e3c946c5 100644 --- a/client/ayon_core/tools/utils/host_tools.py +++ b/client/ayon_core/tools/utils/host_tools.py @@ -33,7 +33,6 @@ class HostToolsHelper: self._loader_tool = None self._creator_tool = None self._publisher_tool = None - self._subset_manager_tool = None self._scene_inventory_tool = None self._experimental_tools_dialog = None @@ -117,28 +116,6 @@ class HostToolsHelper: creator_tool.raise_() creator_tool.activateWindow() - def get_subset_manager_tool(self, parent): - """Create, cache and return subset manager tool window.""" - if self._subset_manager_tool is None: - from ayon_core.tools.subsetmanager import SubsetManagerWindow - - subset_manager_window = SubsetManagerWindow( - parent=parent or self._parent - ) - self._subset_manager_tool = subset_manager_window - - return self._subset_manager_tool - - def show_subset_manager(self, parent=None): - """Show tool display/remove existing created instances.""" - with qt_app_context(): - subset_manager_tool = self.get_subset_manager_tool(parent) - subset_manager_tool.show() - - # Pull window to the front. - subset_manager_tool.raise_() - subset_manager_tool.activateWindow() - def get_scene_inventory_tool(self, parent): """Create, cache and return scene inventory tool window.""" if self._scene_inventory_tool is None: @@ -270,9 +247,6 @@ class HostToolsHelper: elif tool_name == "creator": return self.get_creator_tool(parent, *args, **kwargs) - elif tool_name == "subsetmanager": - return self.get_subset_manager_tool(parent, *args, **kwargs) - elif tool_name == "sceneinventory": return self.get_scene_inventory_tool(parent, *args, **kwargs) @@ -308,9 +282,6 @@ class HostToolsHelper: elif tool_name == "creator": self.show_creator(parent, *args, **kwargs) - elif tool_name == "subsetmanager": - self.show_subset_manager(parent, *args, **kwargs) - elif tool_name == "sceneinventory": self.show_scene_inventory(parent, *args, **kwargs) @@ -383,10 +354,6 @@ def show_creator(parent=None): _SingletonPoint.show_tool_by_name("creator", parent) -def show_subset_manager(parent=None): - _SingletonPoint.show_tool_by_name("subsetmanager", parent) - - def show_scene_inventory(parent=None): _SingletonPoint.show_tool_by_name("sceneinventory", parent) From 7b0d54e7a8a9842fd905e77fe7d8026a78a35b4c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:25:15 +0200 Subject: [PATCH 188/319] remove creator tool Now really remove it... --- client/ayon_core/tools/creator/__init__.py | 9 - client/ayon_core/tools/creator/constants.py | 8 - client/ayon_core/tools/creator/model.py | 59 --- client/ayon_core/tools/creator/widgets.py | 275 ----------- client/ayon_core/tools/creator/window.py | 507 -------------------- 5 files changed, 858 deletions(-) delete mode 100644 client/ayon_core/tools/creator/__init__.py delete mode 100644 client/ayon_core/tools/creator/constants.py delete mode 100644 client/ayon_core/tools/creator/model.py delete mode 100644 client/ayon_core/tools/creator/widgets.py delete mode 100644 client/ayon_core/tools/creator/window.py diff --git a/client/ayon_core/tools/creator/__init__.py b/client/ayon_core/tools/creator/__init__.py deleted file mode 100644 index 585b8bdf80..0000000000 --- a/client/ayon_core/tools/creator/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -from .window import ( - show, - CreatorWindow -) - -__all__ = ( - "show", - "CreatorWindow" -) diff --git a/client/ayon_core/tools/creator/constants.py b/client/ayon_core/tools/creator/constants.py deleted file mode 100644 index ec555fbe9c..0000000000 --- a/client/ayon_core/tools/creator/constants.py +++ /dev/null @@ -1,8 +0,0 @@ -from qtpy import QtCore - - -PRODUCT_TYPE_ROLE = QtCore.Qt.UserRole + 1 -ITEM_ID_ROLE = QtCore.Qt.UserRole + 2 - -SEPARATOR = "---" -SEPARATORS = {"---", "---separator---"} diff --git a/client/ayon_core/tools/creator/model.py b/client/ayon_core/tools/creator/model.py deleted file mode 100644 index 16d24cc8bc..0000000000 --- a/client/ayon_core/tools/creator/model.py +++ /dev/null @@ -1,59 +0,0 @@ -import uuid -from qtpy import QtGui, QtCore - -from . constants import ( - PRODUCT_TYPE_ROLE, - ITEM_ID_ROLE -) - - -class CreatorsModel(QtGui.QStandardItemModel): - def __init__(self, *args, **kwargs): - super(CreatorsModel, self).__init__(*args, **kwargs) - - self._creators_by_id = {} - - def reset(self): - # TODO change to refresh when clearing is not needed - self.clear() - self._creators_by_id = {} - - items = [] - creators = discover_legacy_creator_plugins() - for creator in creators: - if not creator.enabled: - continue - item_id = str(uuid.uuid4()) - self._creators_by_id[item_id] = creator - - label = creator.label or creator.product_type - item = QtGui.QStandardItem(label) - item.setEditable(False) - item.setData(item_id, ITEM_ID_ROLE) - item.setData(creator.product_type, PRODUCT_TYPE_ROLE) - items.append(item) - - if not items: - item = QtGui.QStandardItem("No registered create plugins") - item.setEnabled(False) - item.setData(False, QtCore.Qt.ItemIsEnabled) - items.append(item) - - items.sort(key=lambda item: item.text()) - self.invisibleRootItem().appendRows(items) - - def get_creator_by_id(self, item_id): - return self._creators_by_id.get(item_id) - - def get_indexes_by_product_type(self, product_type): - indexes = [] - for row in range(self.rowCount()): - index = self.index(row, 0) - item_id = index.data(ITEM_ID_ROLE) - creator_plugin = self._creators_by_id.get(item_id) - if creator_plugin and ( - creator_plugin.label.lower() == product_type.lower() - or creator_plugin.product_type.lower() == product_type.lower() - ): - indexes.append(index) - return indexes diff --git a/client/ayon_core/tools/creator/widgets.py b/client/ayon_core/tools/creator/widgets.py deleted file mode 100644 index bbc6848e6c..0000000000 --- a/client/ayon_core/tools/creator/widgets.py +++ /dev/null @@ -1,275 +0,0 @@ -import re -import inspect - -from qtpy import QtWidgets, QtCore, QtGui - -import qtawesome - -from ayon_core.pipeline.create import PRODUCT_NAME_ALLOWED_SYMBOLS -from ayon_core.tools.utils import ErrorMessageBox - -if hasattr(QtGui, "QRegularExpressionValidator"): - RegularExpressionValidatorClass = QtGui.QRegularExpressionValidator - RegularExpressionClass = QtCore.QRegularExpression -else: - RegularExpressionValidatorClass = QtGui.QRegExpValidator - RegularExpressionClass = QtCore.QRegExp - - -class CreateErrorMessageBox(ErrorMessageBox): - def __init__( - self, - product_type, - product_name, - folder_path, - exc_msg, - formatted_traceback, - parent - ): - self._product_type = product_type - self._product_name = product_name - self._folder_path = folder_path - self._exc_msg = exc_msg - self._formatted_traceback = formatted_traceback - super(CreateErrorMessageBox, self).__init__("Creation failed", parent) - - def _create_top_widget(self, parent_widget): - label_widget = QtWidgets.QLabel(parent_widget) - label_widget.setText( - "Failed to create" - ) - return label_widget - - def _get_report_data(self): - report_message = ( - "Failed to create Product: \"{product_name}\"" - " Type: \"{product_type}\"" - " in Folder: \"{folder_path}\"" - "\n\nError: {message}" - ).format( - product_name=self._product_name, - product_type=self._product_type, - folder_path=self._folder_path, - message=self._exc_msg - ) - if self._formatted_traceback: - report_message += "\n\n{}".format(self._formatted_traceback) - return [report_message] - - def _create_content(self, content_layout): - item_name_template = ( - "{}: {{}}
" - "{}: {{}}
" - "{}: {{}}
" - ).format( - "Product type", - "Product name", - "Folder" - ) - exc_msg_template = "{}" - - line = self._create_line() - content_layout.addWidget(line) - - item_name_widget = QtWidgets.QLabel(self) - item_name_widget.setText( - item_name_template.format( - self._product_type, self._product_name, self._folder_path - ) - ) - content_layout.addWidget(item_name_widget) - - message_label_widget = QtWidgets.QLabel(self) - message_label_widget.setText( - exc_msg_template.format(self.convert_text_for_html(self._exc_msg)) - ) - content_layout.addWidget(message_label_widget) - - if self._formatted_traceback: - line_widget = self._create_line() - tb_widget = self._create_traceback_widget( - self._formatted_traceback - ) - content_layout.addWidget(line_widget) - content_layout.addWidget(tb_widget) - - -class ProductNameValidator(RegularExpressionValidatorClass): - invalid = QtCore.Signal(set) - pattern = "^[{}]*$".format(PRODUCT_NAME_ALLOWED_SYMBOLS) - - def __init__(self): - reg = RegularExpressionClass(self.pattern) - super(ProductNameValidator, self).__init__(reg) - - def validate(self, text, pos): - results = super(ProductNameValidator, self).validate(text, pos) - if results[0] == RegularExpressionValidatorClass.Invalid: - self.invalid.emit(self.invalid_chars(text)) - return results - - def invalid_chars(self, text): - invalid = set() - re_valid = re.compile(self.pattern) - for char in text: - if char == " ": - invalid.add("' '") - continue - if not re_valid.match(char): - invalid.add(char) - return invalid - - -class VariantLineEdit(QtWidgets.QLineEdit): - report = QtCore.Signal(str) - colors = { - "empty": (QtGui.QColor("#78879b"), ""), - "exists": (QtGui.QColor("#4E76BB"), "border-color: #4E76BB;"), - "new": (QtGui.QColor("#7AAB8F"), "border-color: #7AAB8F;"), - } - - def __init__(self, *args, **kwargs): - super(VariantLineEdit, self).__init__(*args, **kwargs) - - validator = ProductNameValidator() - self.setValidator(validator) - self.setToolTip("Only alphanumeric characters (A-Z a-z 0-9), " - "'_' and '.' are allowed.") - - self._status_color = self.colors["empty"][0] - - anim = QtCore.QPropertyAnimation() - anim.setTargetObject(self) - anim.setPropertyName(b"status_color") - anim.setEasingCurve(QtCore.QEasingCurve.InCubic) - anim.setDuration(300) - anim.setStartValue(QtGui.QColor("#C84747")) # `Invalid` status color - self.animation = anim - - validator.invalid.connect(self.on_invalid) - - def on_invalid(self, invalid): - message = "Invalid character: %s" % ", ".join(invalid) - self.report.emit(message) - self.animation.stop() - self.animation.start() - - def as_empty(self): - self._set_border("empty") - self.report.emit("Empty product name ..") - - def as_exists(self): - self._set_border("exists") - self.report.emit("Existing product, appending next version.") - - def as_new(self): - self._set_border("new") - self.report.emit("New product, creating first version.") - - def _set_border(self, status): - qcolor, style = self.colors[status] - self.animation.setEndValue(qcolor) - self.setStyleSheet(style) - - def _get_status_color(self): - return self._status_color - - def _set_status_color(self, color): - self._status_color = color - self.setStyleSheet("border-color: %s;" % color.name()) - - status_color = QtCore.Property( - QtGui.QColor, _get_status_color, _set_status_color - ) - - -class ProductTypeDescriptionWidget(QtWidgets.QWidget): - """A product type description widget. - - Shows a product type icon, name and a help description. - Used in creator header. - - _______________________ - | ____ | - | |icon| PRODUCT TYPE | - | |____| help | - |_______________________| - - """ - - SIZE = 35 - - def __init__(self, parent=None): - super(ProductTypeDescriptionWidget, self).__init__(parent=parent) - - icon_label = QtWidgets.QLabel(self) - icon_label.setSizePolicy( - QtWidgets.QSizePolicy.Maximum, - QtWidgets.QSizePolicy.Maximum - ) - - # Add 4 pixel padding to avoid icon being cut off - icon_label.setFixedWidth(self.SIZE + 4) - icon_label.setFixedHeight(self.SIZE + 4) - - label_layout = QtWidgets.QVBoxLayout() - label_layout.setSpacing(0) - - product_type_label = QtWidgets.QLabel(self) - product_type_label.setObjectName("CreatorProductTypeLabel") - product_type_label.setAlignment( - QtCore.Qt.AlignBottom | QtCore.Qt.AlignLeft - ) - - help_label = QtWidgets.QLabel(self) - help_label.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft) - - label_layout.addWidget(product_type_label) - label_layout.addWidget(help_label) - - layout = QtWidgets.QHBoxLayout(self) - layout.setContentsMargins(0, 0, 0, 0) - layout.setSpacing(5) - layout.addWidget(icon_label) - layout.addLayout(label_layout) - - self._help_label = help_label - self._product_type_label = product_type_label - self._icon_label = icon_label - - def set_item(self, creator_plugin): - """Update elements to display information of a product type item. - - Args: - creator_plugin (dict): A product type item as registered with - name, help and icon. - - Returns: - None - - """ - if not creator_plugin: - self._icon_label.setPixmap(None) - self._product_type_label.setText("") - self._help_label.setText("") - return - - # Support a font-awesome icon - icon_name = getattr(creator_plugin, "icon", None) or "info-circle" - try: - icon = qtawesome.icon("fa.{}".format(icon_name), color="white") - pixmap = icon.pixmap(self.SIZE, self.SIZE) - except Exception: - print("BUG: Couldn't load icon \"fa.{}\"".format(str(icon_name))) - # Create transparent pixmap - pixmap = QtGui.QPixmap() - pixmap.fill(QtCore.Qt.transparent) - pixmap = pixmap.scaled(self.SIZE, self.SIZE) - - # Parse a clean line from the Creator's docstring - docstring = inspect.getdoc(creator_plugin) - creator_help = docstring.splitlines()[0] if docstring else "" - - self._icon_label.setPixmap(pixmap) - self._product_type_label.setText(creator_plugin.product_type) - self._help_label.setText(creator_help) diff --git a/client/ayon_core/tools/creator/window.py b/client/ayon_core/tools/creator/window.py deleted file mode 100644 index fe8ee86dcf..0000000000 --- a/client/ayon_core/tools/creator/window.py +++ /dev/null @@ -1,507 +0,0 @@ -import sys -import traceback -import re - -import ayon_api -from qtpy import QtWidgets, QtCore - -from ayon_core import style -from ayon_core.settings import get_current_project_settings -from ayon_core.tools.utils.lib import qt_app_context -from ayon_core.pipeline import ( - get_current_project_name, - get_current_folder_path, - get_current_task_name, -) -from ayon_core.pipeline.create import ( - PRODUCT_NAME_ALLOWED_SYMBOLS, - CreatorError, -) - -from .model import CreatorsModel -from .widgets import ( - CreateErrorMessageBox, - VariantLineEdit, - ProductTypeDescriptionWidget -) -from .constants import ( - ITEM_ID_ROLE, - SEPARATOR, - SEPARATORS -) - -module = sys.modules[__name__] -module.window = None - - -class CreatorWindow(QtWidgets.QDialog): - def __init__(self, parent=None): - super(CreatorWindow, self).__init__(parent) - self.setWindowTitle("Instance Creator") - self.setFocusPolicy(QtCore.Qt.StrongFocus) - if not parent: - self.setWindowFlags( - self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint - ) - - creator_info = ProductTypeDescriptionWidget(self) - - creators_model = CreatorsModel() - - creators_proxy = QtCore.QSortFilterProxyModel() - creators_proxy.setSourceModel(creators_model) - - creators_view = QtWidgets.QListView(self) - creators_view.setObjectName("CreatorsView") - creators_view.setModel(creators_proxy) - - folder_path_input = QtWidgets.QLineEdit(self) - variant_input = VariantLineEdit(self) - product_name_input = QtWidgets.QLineEdit(self) - product_name_input.setEnabled(False) - - variants_btn = QtWidgets.QPushButton() - variants_btn.setFixedWidth(18) - variants_menu = QtWidgets.QMenu(variants_btn) - variants_btn.setMenu(variants_menu) - - name_layout = QtWidgets.QHBoxLayout() - name_layout.addWidget(variant_input) - name_layout.addWidget(variants_btn) - name_layout.setSpacing(3) - name_layout.setContentsMargins(0, 0, 0, 0) - - body_layout = QtWidgets.QVBoxLayout() - body_layout.setContentsMargins(0, 0, 0, 0) - - body_layout.addWidget(creator_info, 0) - body_layout.addWidget(QtWidgets.QLabel("Product type", self), 0) - body_layout.addWidget(creators_view, 1) - body_layout.addWidget(QtWidgets.QLabel("Folder path", self), 0) - body_layout.addWidget(folder_path_input, 0) - body_layout.addWidget(QtWidgets.QLabel("Product name", self), 0) - body_layout.addLayout(name_layout, 0) - body_layout.addWidget(product_name_input, 0) - - useselection_chk = QtWidgets.QCheckBox("Use selection", self) - useselection_chk.setCheckState(QtCore.Qt.Checked) - - create_btn = QtWidgets.QPushButton("Create", self) - # Need to store error_msg to prevent garbage collection - msg_label = QtWidgets.QLabel(self) - - footer_layout = QtWidgets.QVBoxLayout() - footer_layout.addWidget(create_btn, 0) - footer_layout.addWidget(msg_label, 0) - footer_layout.setContentsMargins(0, 0, 0, 0) - - layout = QtWidgets.QVBoxLayout(self) - layout.addLayout(body_layout, 1) - layout.addWidget(useselection_chk, 0, QtCore.Qt.AlignLeft) - layout.addLayout(footer_layout, 0) - - msg_timer = QtCore.QTimer() - msg_timer.setSingleShot(True) - msg_timer.setInterval(5000) - - validation_timer = QtCore.QTimer() - validation_timer.setSingleShot(True) - validation_timer.setInterval(300) - - msg_timer.timeout.connect(self._on_msg_timer) - validation_timer.timeout.connect(self._on_validation_timer) - - create_btn.clicked.connect(self._on_create) - variant_input.returnPressed.connect(self._on_create) - variant_input.textChanged.connect(self._on_data_changed) - variant_input.report.connect(self.echo) - folder_path_input.textChanged.connect(self._on_data_changed) - creators_view.selectionModel().currentChanged.connect( - self._on_selection_changed - ) - - # Store valid states and - self._is_valid = False - create_btn.setEnabled(self._is_valid) - - self._first_show = True - - # Message dialog when something goes wrong during creation - self._message_dialog = None - - self._creator_info = creator_info - self._create_btn = create_btn - self._useselection_chk = useselection_chk - self._variant_input = variant_input - self._product_name_input = product_name_input - self._folder_path_input = folder_path_input - - self._creators_model = creators_model - self._creators_proxy = creators_proxy - self._creators_view = creators_view - - self._variants_btn = variants_btn - self._variants_menu = variants_menu - - self._msg_label = msg_label - - self._validation_timer = validation_timer - self._msg_timer = msg_timer - - # Defaults - self.resize(300, 500) - variant_input.setFocus() - - def _set_valid_state(self, valid): - if self._is_valid == valid: - return - self._is_valid = valid - self._create_btn.setEnabled(valid) - - def _build_menu(self, default_names=None): - """Create optional predefined variants. - - Args: - default_names(list): all predefined names - - Returns: - None - """ - if not default_names: - default_names = [] - - menu = self._variants_menu - button = self._variants_btn - - # Get and destroy the action group - group = button.findChild(QtWidgets.QActionGroup) - if group: - group.deleteLater() - - state = any(default_names) - button.setEnabled(state) - if state is False: - return - - # Build new action group - group = QtWidgets.QActionGroup(button) - for name in default_names: - if name in SEPARATORS: - menu.addSeparator() - continue - action = group.addAction(name) - menu.addAction(action) - - group.triggered.connect(self._on_action_clicked) - - def _on_action_clicked(self, action): - self._variant_input.setText(action.text()) - - def _on_data_changed(self, *args): - # Set invalid state until it's reconfirmed to be valid by the - # scheduled callback so any form of creation is held back until - # valid again - self._set_valid_state(False) - - self._validation_timer.start() - - def _on_validation_timer(self): - index = self._creators_view.currentIndex() - item_id = index.data(ITEM_ID_ROLE) - creator_plugin = self._creators_model.get_creator_by_id(item_id) - user_input_text = self._variant_input.text() - folder_path = self._folder_path_input.text() - - # Early exit if no folder path - if not folder_path: - self._build_menu() - self.echo("Folder is required ..") - self._set_valid_state(False) - return - - project_name = get_current_project_name() - folder_entity = None - if creator_plugin: - # Get the folder from the database which match with the name - folder_entity = ayon_api.get_folder_by_path( - project_name, folder_path, fields={"id"} - ) - - # Get plugin - if not folder_entity or not creator_plugin: - self._build_menu() - - if not creator_plugin: - self.echo("No registered product types ..") - else: - self.echo("Folder '{}' not found ..".format(folder_path)) - self._set_valid_state(False) - return - - folder_id = folder_entity["id"] - - task_name = get_current_task_name() - task_entity = ayon_api.get_task_by_name( - project_name, folder_id, task_name - ) - - # Calculate product name with Creator plugin - product_name = creator_plugin.get_product_name( - project_name, folder_entity, task_entity, user_input_text - ) - # Force replacement of prohibited symbols - # QUESTION should Creator care about this and here should be only - # validated with schema regex? - - # Allow curly brackets in product name for dynamic keys - curly_left = "__cbl__" - curly_right = "__cbr__" - tmp_product_name = ( - product_name - .replace("{", curly_left) - .replace("}", curly_right) - ) - # Replace prohibited symbols - tmp_product_name = re.sub( - "[^{}]+".format(PRODUCT_NAME_ALLOWED_SYMBOLS), - "", - tmp_product_name - ) - product_name = ( - tmp_product_name - .replace(curly_left, "{") - .replace(curly_right, "}") - ) - self._product_name_input.setText(product_name) - - # Get all products of the current folder - product_entities = ayon_api.get_products( - project_name, folder_ids={folder_id}, fields={"name"} - ) - existing_product_names = { - product_entity["name"] - for product_entity in product_entities - } - existing_product_names_low = set( - _name.lower() - for _name in existing_product_names - ) - - # Defaults to dropdown - defaults = [] - # Check if Creator plugin has set defaults - if ( - creator_plugin.defaults - and isinstance(creator_plugin.defaults, (list, tuple, set)) - ): - defaults = list(creator_plugin.defaults) - - # Replace - compare_regex = re.compile(re.sub( - user_input_text, "(.+)", product_name, flags=re.IGNORECASE - )) - variant_hints = set() - if user_input_text: - for _name in existing_product_names: - _result = compare_regex.search(_name) - if _result: - variant_hints |= set(_result.groups()) - - if variant_hints: - if defaults: - defaults.append(SEPARATOR) - defaults.extend(variant_hints) - self._build_menu(defaults) - - # Indicate product existence - if not user_input_text: - self._variant_input.as_empty() - elif product_name.lower() in existing_product_names_low: - # validate existence of product name with lowered text - # - "renderMain" vs. "rensermain" mean same path item for - # windows - self._variant_input.as_exists() - else: - self._variant_input.as_new() - - # Update the valid state - valid = product_name.strip() != "" - - self._set_valid_state(valid) - - def _on_selection_changed(self, old_idx, new_idx): - index = self._creators_view.currentIndex() - item_id = index.data(ITEM_ID_ROLE) - - creator_plugin = self._creators_model.get_creator_by_id(item_id) - - self._creator_info.set_item(creator_plugin) - - if creator_plugin is None: - return - - default = None - if hasattr(creator_plugin, "get_default_variant"): - default = creator_plugin.get_default_variant() - - if not default: - if ( - creator_plugin.defaults - and isinstance(creator_plugin.defaults, list) - ): - default = creator_plugin.defaults[0] - else: - default = "Default" - - self._variant_input.setText(default) - - self._on_data_changed() - - def keyPressEvent(self, event): - """Custom keyPressEvent. - - Override keyPressEvent to do nothing so that Maya's panels won't - take focus when pressing "SHIFT" whilst mouse is over viewport or - outliner. This way users don't accidentally perform Maya commands - whilst trying to name an instance. - - """ - pass - - def showEvent(self, event): - super(CreatorWindow, self).showEvent(event) - if self._first_show: - self._first_show = False - self.setStyleSheet(style.load_stylesheet()) - - def refresh(self): - self._folder_path_input.setText(get_current_folder_path()) - - self._creators_model.reset() - - product_types_smart_select = ( - get_current_project_settings() - ["core"] - ["tools"] - ["creator"] - ["product_types_smart_select"] - ) - current_index = None - product_type = None - task_name = get_current_task_name() or None - lowered_task_name = task_name.lower() - if task_name: - for smart_item in product_types_smart_select: - _low_task_names = { - name.lower() for name in smart_item["task_names"] - } - for _task_name in _low_task_names: - if _task_name in lowered_task_name: - product_type = smart_item["name"] - break - if product_type: - break - - if product_type: - indexes = self._creators_model.get_indexes_by_product_type( - product_type - ) - if indexes: - index = indexes[0] - current_index = self._creators_proxy.mapFromSource(index) - - if current_index is None or not current_index.isValid(): - current_index = self._creators_proxy.index(0, 0) - - self._creators_view.setCurrentIndex(current_index) - - def _on_create(self): - # Do not allow creation in an invalid state - if not self._is_valid: - return - - index = self._creators_view.currentIndex() - item_id = index.data(ITEM_ID_ROLE) - creator_plugin = self._creators_model.get_creator_by_id(item_id) - if creator_plugin is None: - return - - product_name = self._product_name_input.text() - folder_path = self._folder_path_input.text() - use_selection = self._useselection_chk.isChecked() - - variant = self._variant_input.text() - - error_info = None - try: - legacy_create( - creator_plugin, - product_name, - folder_path, - options={"useSelection": use_selection}, - data={"variant": variant} - ) - - except CreatorError as exc: - self.echo("Creator error: {}".format(str(exc))) - error_info = (str(exc), None) - - except Exception as exc: - self.echo("Program error: %s" % str(exc)) - - exc_type, exc_value, exc_traceback = sys.exc_info() - formatted_traceback = "".join(traceback.format_exception( - exc_type, exc_value, exc_traceback - )) - error_info = (str(exc), formatted_traceback) - - if error_info: - box = CreateErrorMessageBox( - creator_plugin.product_type, - product_name, - folder_path, - *error_info, - parent=self - ) - box.show() - # Store dialog so is not garbage collected before is shown - self._message_dialog = box - - else: - self.echo("Created %s .." % product_name) - - def _on_msg_timer(self): - self._msg_label.setText("") - - def echo(self, message): - self._msg_label.setText(str(message)) - self._msg_timer.start() - - -def show(parent=None): - """Display product creator GUI - - Arguments: - debug (bool, optional): Run loader in debug-mode, - defaults to False - parent (QtCore.QObject, optional): When provided parent the interface - to this QObject. - - """ - - try: - module.window.close() - del module.window - except (AttributeError, RuntimeError): - pass - - with qt_app_context(): - window = CreatorWindow(parent) - window.refresh() - window.show() - - module.window = window - - # Pull window to the front. - module.window.raise_() - module.window.activateWindow() From 7856ee98fef309a4404d37275631f7903864140c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:25:22 +0200 Subject: [PATCH 189/319] remove import --- client/ayon_core/pipeline/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/pipeline/__init__.py b/client/ayon_core/pipeline/__init__.py index 65ad55d06e..f2ec952cd6 100644 --- a/client/ayon_core/pipeline/__init__.py +++ b/client/ayon_core/pipeline/__init__.py @@ -20,7 +20,6 @@ from .create import ( CreatorError, discover_creator_plugins, - discover_legacy_creator_plugins, register_creator_plugin, deregister_creator_plugin, register_creator_plugin_path, From 8314d83a0d52adbef475e63dffdc85cc51f47e45 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:26:00 +0200 Subject: [PATCH 190/319] remove unused import --- client/ayon_core/pipeline/create/creator_plugins.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/pipeline/create/creator_plugins.py b/client/ayon_core/pipeline/create/creator_plugins.py index b890704649..7573589b82 100644 --- a/client/ayon_core/pipeline/create/creator_plugins.py +++ b/client/ayon_core/pipeline/create/creator_plugins.py @@ -6,7 +6,6 @@ from typing import TYPE_CHECKING, Optional, Dict, Any from abc import ABC, abstractmethod -from ayon_core.settings import get_project_settings from ayon_core.lib import Logger, get_version_from_path from ayon_core.pipeline.plugin_discover import ( discover, From 6b6c93376e18e16ebe3ef589345c121e0e2c2b06 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:08:27 +0200 Subject: [PATCH 191/319] implemented abstract host class --- client/ayon_core/host/abstract.py | 96 +++++++++++++++++++++++++++++++ client/ayon_core/host/typing.py | 7 +++ 2 files changed, 103 insertions(+) create mode 100644 client/ayon_core/host/abstract.py create mode 100644 client/ayon_core/host/typing.py diff --git a/client/ayon_core/host/abstract.py b/client/ayon_core/host/abstract.py new file mode 100644 index 0000000000..26771aaffa --- /dev/null +++ b/client/ayon_core/host/abstract.py @@ -0,0 +1,96 @@ +from __future__ import annotations + +import logging +from abc import ABC, abstractmethod +import typing +from typing import Optional, Any + +from .constants import ContextChangeReason + +if typing.TYPE_CHECKING: + from ayon_core.pipeline import Anatomy + + from .typing import HostContextData + + +class AbstractHost(ABC): + """Abstract definition of host implementation.""" + @property + @abstractmethod + def log(self) -> logging.Logger: + pass + + @property + @abstractmethod + def name(self) -> str: + """Host name.""" + pass + + @abstractmethod + def get_current_context(self) -> HostContextData: + """Get the current context of the host. + + Current context is defined by project name, folder path and task name. + + Returns: + HostContextData: The current context of the host. + + """ + pass + + @abstractmethod + def set_current_context( + self, + folder_entity: dict[str, Any], + task_entity: dict[str, Any], + *, + reason: ContextChangeReason = ContextChangeReason.undefined, + project_entity: Optional[dict[str, Any]] = None, + anatomy: Optional[Anatomy] = None, + ) -> HostContextData: + """Change context of the host. + + Args: + folder_entity (dict[str, Any]): Folder entity. + task_entity (dict[str, Any]): Task entity. + reason (ContextChangeReason): Reason for change. + project_entity (dict[str, Any]): Project entity. + anatomy (Anatomy): Anatomy entity. + + """ + pass + + @abstractmethod + def get_current_project_name(self) -> str: + """Get the current project name. + + Returns: + Optional[str]: The current project name. + + """ + pass + + @abstractmethod + def get_current_folder_path(self) -> Optional[str]: + """Get the current folder path. + + Returns: + Optional[str]: The current folder path. + + """ + pass + + @abstractmethod + def get_current_task_name(self) -> Optional[str]: + """Get the current task name. + + Returns: + Optional[str]: The current task name. + + """ + pass + + @abstractmethod + def get_context_title(self) -> str: + """Get the context title used in UIs.""" + pass diff --git a/client/ayon_core/host/typing.py b/client/ayon_core/host/typing.py new file mode 100644 index 0000000000..a51460713b --- /dev/null +++ b/client/ayon_core/host/typing.py @@ -0,0 +1,7 @@ +from typing import Optional, TypedDict + + +class HostContextData(TypedDict): + project_name: str + folder_path: Optional[str] + task_name: Optional[str] From 044e41471810b06e28ab4051775169896916a455 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:09:01 +0200 Subject: [PATCH 192/319] use AbstractHost for interfaces and HotBase --- client/ayon_core/host/host.py | 13 ++++--------- client/ayon_core/host/interfaces/interfaces.py | 6 ++++-- client/ayon_core/host/interfaces/workfiles.py | 3 ++- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/client/ayon_core/host/host.py b/client/ayon_core/host/host.py index 7fc4b19bdd..7fd63a5864 100644 --- a/client/ayon_core/host/host.py +++ b/client/ayon_core/host/host.py @@ -3,26 +3,21 @@ from __future__ import annotations import os import logging import contextlib -from abc import ABC, abstractmethod -from dataclasses import dataclass import typing from typing import Optional, Any +from dataclasses import dataclass import ayon_api from ayon_core.lib import emit_event from .constants import ContextChangeReason +from .abstract import AbstractHost if typing.TYPE_CHECKING: from ayon_core.pipeline import Anatomy - from typing import TypedDict - - class HostContextData(TypedDict): - project_name: str - folder_path: Optional[str] - task_name: Optional[str] + from .typing import HostContextData @dataclass @@ -34,7 +29,7 @@ class ContextChangeData: anatomy: Anatomy -class HostBase(ABC): +class HostBase(AbstractHost): """Base of host implementation class. Host is pipeline implementation of DCC application. This class should help diff --git a/client/ayon_core/host/interfaces/interfaces.py b/client/ayon_core/host/interfaces/interfaces.py index a41dffe92a..8b7005085e 100644 --- a/client/ayon_core/host/interfaces/interfaces.py +++ b/client/ayon_core/host/interfaces/interfaces.py @@ -1,9 +1,11 @@ from abc import abstractmethod +from ayon_core.host.abstract import AbstractHost + from .exceptions import MissingMethodsError -class ILoadHost: +class ILoadHost(AbstractHost): """Implementation requirements to be able use reference of representations. The load plugins can do referencing even without implementation of methods @@ -83,7 +85,7 @@ class ILoadHost: return self.get_containers() -class IPublishHost: +class IPublishHost(AbstractHost): """Functions related to new creation system in new publisher. New publisher is not storing information only about each created instance diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index 82d71d152a..93aad4c117 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -15,6 +15,7 @@ import arrow from ayon_core.lib import emit_event from ayon_core.settings import get_project_settings +from ayon_core.host.abstract import AbstractHost from ayon_core.host.constants import ContextChangeReason if typing.TYPE_CHECKING: @@ -821,7 +822,7 @@ class PublishedWorkfileInfo: return PublishedWorkfileInfo(**data) -class IWorkfileHost: +class IWorkfileHost(AbstractHost): """Implementation requirements to be able to use workfiles utils and tool. Some of the methods are pre-implemented as they generally do the same in From 89e92f555684382bce822165213e0b8cadee2f40 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:09:33 +0200 Subject: [PATCH 193/319] remove name abstraction --- client/ayon_core/host/host.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/client/ayon_core/host/host.py b/client/ayon_core/host/host.py index 7fd63a5864..9b7d43be94 100644 --- a/client/ayon_core/host/host.py +++ b/client/ayon_core/host/host.py @@ -114,13 +114,6 @@ class HostBase(AbstractHost): self._log = logging.getLogger(self.__class__.__name__) return self._log - @property - @abstractmethod - def name(self) -> str: - """Host name.""" - - pass - def get_current_project_name(self): """ Returns: From 77383fea1e3e23354e182e8637e94f51e4d11765 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:09:54 +0200 Subject: [PATCH 194/319] updated docstrings and type hints --- client/ayon_core/host/host.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/client/ayon_core/host/host.py b/client/ayon_core/host/host.py index 9b7d43be94..28cb6b0a09 100644 --- a/client/ayon_core/host/host.py +++ b/client/ayon_core/host/host.py @@ -104,41 +104,41 @@ class HostBase(AbstractHost): It is called automatically when 'ayon_core.pipeline.install_host' is triggered. - """ + """ pass @property - def log(self): + def log(self) -> logging.Logger: if self._log is None: self._log = logging.getLogger(self.__class__.__name__) return self._log - def get_current_project_name(self): + def get_current_project_name(self) -> str: """ Returns: - Union[str, None]: Current project name. - """ + str: Current project name. - return os.environ.get("AYON_PROJECT_NAME") + """ + return os.environ["AYON_PROJECT_NAME"] def get_current_folder_path(self) -> Optional[str]: """ Returns: - Union[str, None]: Current asset name. - """ + Optional[str]: Current asset name. + """ return os.environ.get("AYON_FOLDER_PATH") def get_current_task_name(self) -> Optional[str]: """ Returns: - Union[str, None]: Current task name. - """ + Optional[str]: Current task name. + """ return os.environ.get("AYON_TASK_NAME") - def get_current_context(self) -> "HostContextData": + def get_current_context(self) -> HostContextData: """Get current context information. This method should be used to get current context of host. Usage of @@ -147,10 +147,10 @@ class HostBase(AbstractHost): can't be caught properly. Returns: - Dict[str, Union[str, None]]: Context with 3 keys 'project_name', - 'folder_path' and 'task_name'. All of them can be 'None'. - """ + HostContextData: Current context with 'project_name', + 'folder_path' and 'task_name'. + """ return { "project_name": self.get_current_project_name(), "folder_path": self.get_current_folder_path(), @@ -165,7 +165,7 @@ class HostBase(AbstractHost): reason: ContextChangeReason = ContextChangeReason.undefined, project_entity: Optional[dict[str, Any]] = None, anatomy: Optional[Anatomy] = None, - ) -> "HostContextData": + ) -> HostContextData: """Set current context information. This method should be used to set current context of host. Usage of @@ -278,7 +278,7 @@ class HostBase(AbstractHost): project_name: str, folder_path: Optional[str], task_name: Optional[str], - ) -> "HostContextData": + ) -> HostContextData: """Emit context change event. Args: @@ -290,7 +290,7 @@ class HostBase(AbstractHost): HostContextData: Data send to context change event. """ - data = { + data: HostContextData = { "project_name": project_name, "folder_path": folder_path, "task_name": task_name, From 2bd18c4d9614e502d2a774093a2b4e8aa1b42397 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:39:32 +0200 Subject: [PATCH 195/319] added some of the classes to host init --- client/ayon_core/host/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/ayon_core/host/__init__.py b/client/ayon_core/host/__init__.py index ef5c324028..a20165bce2 100644 --- a/client/ayon_core/host/__init__.py +++ b/client/ayon_core/host/__init__.py @@ -1,6 +1,8 @@ from .constants import ContextChangeReason +from .abstract import AbstractHost from .host import ( HostBase, + HostContextData, ) from .interfaces import ( @@ -18,7 +20,10 @@ from .dirmap import HostDirmap __all__ = ( "ContextChangeReason", + "AbstractHost", + "HostBase", + "HostContextData", "IWorkfileHost", "WorkfileInfo", From 53d0d4985a1d1d1dfbcc8d9ec63006afca5bf10e Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:47:45 +0200 Subject: [PATCH 196/319] use 'AbstractHost' for type checking --- .../ayon_core/host/interfaces/interfaces.py | 8 ++++---- client/ayon_core/pipeline/context_tools.py | 20 +++++++++---------- .../workfile/workfile_template_builder.py | 16 +++++++-------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/client/ayon_core/host/interfaces/interfaces.py b/client/ayon_core/host/interfaces/interfaces.py index 8b7005085e..6f9a3d8c87 100644 --- a/client/ayon_core/host/interfaces/interfaces.py +++ b/client/ayon_core/host/interfaces/interfaces.py @@ -26,7 +26,7 @@ class ILoadHost(AbstractHost): loading. Checks only existence of methods. Args: - Union[ModuleType, HostBase]: Object of host where to look for + Union[ModuleType, AbstractHost]: Object of host where to look for required methods. Returns: @@ -48,7 +48,7 @@ class ILoadHost(AbstractHost): """Validate implemented methods of "old type" host for load workflow. Args: - Union[ModuleType, HostBase]: Object of host to validate. + Union[ModuleType, AbstractHost]: Object of host to validate. Raises: MissingMethodsError: If there are missing methods on host @@ -101,7 +101,7 @@ class IPublishHost(AbstractHost): new publish creation. Checks only existence of methods. Args: - Union[ModuleType, HostBase]: Host module where to look for + Union[ModuleType, AbstractHost]: Host module where to look for required methods. Returns: @@ -129,7 +129,7 @@ class IPublishHost(AbstractHost): """Validate implemented methods of "old type" host. Args: - Union[ModuleType, HostBase]: Host module to validate. + Union[ModuleType, AbstractHost]: Host module to validate. Raises: MissingMethodsError: If there are missing methods on host diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 423e8f7216..0589eeb49f 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -13,7 +13,7 @@ import pyblish.api from pyblish.lib import MessageHandler from ayon_core import AYON_CORE_ROOT -from ayon_core.host import HostBase +from ayon_core.host import AbstractHost from ayon_core.lib import ( is_in_tests, initialize_ayon_connection, @@ -100,16 +100,16 @@ def registered_root(): return _registered_root["_"] -def install_host(host: HostBase) -> None: +def install_host(host: AbstractHost) -> None: """Install `host` into the running Python session. Args: - host (HostBase): A host interface object. + host (AbstractHost): A host interface object. """ - if not isinstance(host, HostBase): + if not isinstance(host, AbstractHost): log.error( - f"Host must be a subclass of 'HostBase', got '{type(host)}'." + f"Host must be a subclass of 'AbstractHost', got '{type(host)}'." ) global _is_installed @@ -310,7 +310,7 @@ def get_current_host_name(): """ host = registered_host() - if isinstance(host, HostBase): + if isinstance(host, AbstractHost): return host.name return os.environ.get("AYON_HOST_NAME") @@ -346,28 +346,28 @@ def get_global_context(): def get_current_context(): host = registered_host() - if isinstance(host, HostBase): + if isinstance(host, AbstractHost): return host.get_current_context() return get_global_context() def get_current_project_name(): host = registered_host() - if isinstance(host, HostBase): + if isinstance(host, AbstractHost): return host.get_current_project_name() return get_global_context()["project_name"] def get_current_folder_path(): host = registered_host() - if isinstance(host, HostBase): + if isinstance(host, AbstractHost): return host.get_current_folder_path() return get_global_context()["folder_path"] def get_current_task_name(): host = registered_host() - if isinstance(host, HostBase): + if isinstance(host, AbstractHost): return host.get_current_task_name() return get_global_context()["task_name"] diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index e2add99752..4349585b82 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -30,7 +30,7 @@ from ayon_api import ( ) from ayon_core.settings import get_project_settings -from ayon_core.host import IWorkfileHost, HostBase +from ayon_core.host import IWorkfileHost, AbstractHost from ayon_core.lib import ( Logger, StringTemplate, @@ -127,7 +127,7 @@ class AbstractTemplateBuilder(ABC): placeholder population. Args: - host (Union[HostBase, ModuleType]): Implementation of host. + host (Union[AbstractHost, ModuleType]): Implementation of host. """ _log = None @@ -135,7 +135,7 @@ class AbstractTemplateBuilder(ABC): def __init__(self, host): # Get host name - if isinstance(host, HostBase): + if isinstance(host, AbstractHost): host_name = host.name else: host_name = os.environ.get("AYON_HOST_NAME") @@ -163,24 +163,24 @@ class AbstractTemplateBuilder(ABC): @property def project_name(self): - if isinstance(self._host, HostBase): + if isinstance(self._host, AbstractHost): return self._host.get_current_project_name() return os.getenv("AYON_PROJECT_NAME") @property def current_folder_path(self): - if isinstance(self._host, HostBase): + if isinstance(self._host, AbstractHost): return self._host.get_current_folder_path() return os.getenv("AYON_FOLDER_PATH") @property def current_task_name(self): - if isinstance(self._host, HostBase): + if isinstance(self._host, AbstractHost): return self._host.get_current_task_name() return os.getenv("AYON_TASK_NAME") def get_current_context(self): - if isinstance(self._host, HostBase): + if isinstance(self._host, AbstractHost): return self._host.get_current_context() return { "project_name": self.project_name, @@ -256,7 +256,7 @@ class AbstractTemplateBuilder(ABC): """Access to host implementation. Returns: - Union[HostBase, ModuleType]: Implementation of host. + Union[AbstractHost, ModuleType]: Implementation of host. """ return self._host From ec92be4cae509a5baa31b71725da4bd5c1d68c54 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:48:10 +0200 Subject: [PATCH 197/319] simplified few type hints --- client/ayon_core/pipeline/create/context.py | 7 ++----- client/ayon_core/tools/publisher/abstract.py | 4 ++-- client/ayon_core/tools/sceneinventory/control.py | 4 ++-- client/ayon_core/tools/workfiles/models/workfiles.py | 9 ++------- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index 929cc59d2a..bd7dd4414f 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -49,15 +49,12 @@ from .creator_plugins import ( discover_convertor_plugins, ) if typing.TYPE_CHECKING: - from ayon_core.host import HostBase from ayon_core.lib import AbstractAttrDef from ayon_core.lib.events import EventCallback, Event from .structures import CreatedInstance from .creator_plugins import BaseCreator - class PublishHost(HostBase, IPublishHost): - pass # Import of functions and classes that were moved to different file # TODO Should be removed in future release - Added 24/08/28, 0.4.3-dev.1 @@ -163,7 +160,7 @@ class CreateContext: context which should be handled by host. Args: - host (PublishHost): Host implementation which handles implementation + host (IPublishHost): Host implementation which handles implementation and global metadata. headless (bool): Context is created out of UI (Current not used). reset (bool): Reset context on initialization. @@ -173,7 +170,7 @@ class CreateContext: def __init__( self, - host: "PublishHost", + host: IPublishHost, headless: bool = False, reset: bool = True, discover_publish_plugins: bool = True, diff --git a/client/ayon_core/tools/publisher/abstract.py b/client/ayon_core/tools/publisher/abstract.py index 6d0027d35d..14da15793d 100644 --- a/client/ayon_core/tools/publisher/abstract.py +++ b/client/ayon_core/tools/publisher/abstract.py @@ -13,7 +13,7 @@ from typing import ( ) from ayon_core.lib import AbstractAttrDef -from ayon_core.host import HostBase +from ayon_core.host import AbstractHost from ayon_core.pipeline.create import ( CreateContext, ConvertorItem, @@ -176,7 +176,7 @@ class AbstractPublisherBackend(AbstractPublisherCommon): pass @abstractmethod - def get_host(self) -> HostBase: + def get_host(self) -> AbstractHost: pass @abstractmethod diff --git a/client/ayon_core/tools/sceneinventory/control.py b/client/ayon_core/tools/sceneinventory/control.py index 60d9bc77a9..45f76a54ac 100644 --- a/client/ayon_core/tools/sceneinventory/control.py +++ b/client/ayon_core/tools/sceneinventory/control.py @@ -1,7 +1,7 @@ import ayon_api from ayon_core.lib.events import QueuedEventSystem -from ayon_core.host import HostBase +from ayon_core.host import ILoadHost from ayon_core.pipeline import ( registered_host, get_current_context, @@ -35,7 +35,7 @@ class SceneInventoryController: self._projects_model = ProjectsModel(self) self._event_system = self._create_event_system() - def get_host(self) -> HostBase: + def get_host(self) -> ILoadHost: return self._host def emit_event(self, topic, data=None, source=None): diff --git a/client/ayon_core/tools/workfiles/models/workfiles.py b/client/ayon_core/tools/workfiles/models/workfiles.py index d33a532222..5b5591fe43 100644 --- a/client/ayon_core/tools/workfiles/models/workfiles.py +++ b/client/ayon_core/tools/workfiles/models/workfiles.py @@ -14,7 +14,6 @@ from ayon_core.lib import ( Logger, ) from ayon_core.host import ( - HostBase, IWorkfileHost, WorkfileInfo, PublishedWorkfileInfo, @@ -49,19 +48,15 @@ if typing.TYPE_CHECKING: _NOT_SET = object() -class HostType(HostBase, IWorkfileHost): - pass - - class WorkfilesModel: """Workfiles model.""" def __init__( self, - host: HostType, + host: IWorkfileHost, controller: AbstractWorkfilesBackend ): - self._host: HostType = host + self._host: IWorkfileHost = host self._controller: AbstractWorkfilesBackend = controller self._log = Logger.get_logger("WorkfilesModel") From 644130ad7a4a09e9b51652773ec9cb83c12424a9 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:51:33 +0200 Subject: [PATCH 198/319] fix imported class --- client/ayon_core/host/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/host/__init__.py b/client/ayon_core/host/__init__.py index a20165bce2..950c14564e 100644 --- a/client/ayon_core/host/__init__.py +++ b/client/ayon_core/host/__init__.py @@ -2,7 +2,7 @@ from .constants import ContextChangeReason from .abstract import AbstractHost from .host import ( HostBase, - HostContextData, + ContextChangeData, ) from .interfaces import ( @@ -23,7 +23,7 @@ __all__ = ( "AbstractHost", "HostBase", - "HostContextData", + "ContextChangeData", "IWorkfileHost", "WorkfileInfo", From 9ffaa15dfb4ec0484a5303ed1a8a04bd2805c7e9 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 15 Aug 2025 22:09:15 +0800 Subject: [PATCH 199/319] make sure the hero version can be created successfully by ensuring to copy the path into the right path --- .../plugins/load/create_hero_version.py | 141 ++++++++++++++---- 1 file changed, 110 insertions(+), 31 deletions(-) diff --git a/client/ayon_core/plugins/load/create_hero_version.py b/client/ayon_core/plugins/load/create_hero_version.py index 7e1a0d8a3d..b18e874644 100644 --- a/client/ayon_core/plugins/load/create_hero_version.py +++ b/client/ayon_core/plugins/load/create_hero_version.py @@ -14,7 +14,7 @@ from ayon_api.utils import create_entity_id from qtpy import QtWidgets, QtCore from ayon_core import style from ayon_core.pipeline import load, Anatomy -from ayon_core.lib import create_hard_link, source_hash +from ayon_core.lib import create_hard_link, source_hash, StringTemplate from ayon_core.lib.file_transaction import wait_for_future_errors from ayon_core.pipeline.publish import get_publish_template_name from ayon_core.pipeline.template_data import get_template_data @@ -83,7 +83,10 @@ class CreateHeroVersion(load.ProductLoaderPlugin): version_id = version["id"] project_name = project["name"] repres = list( - ayon_api.get_representations(project_name, version_ids={version_id})) + ayon_api.get_representations( + project_name, version_ids={version_id} + ) + ) anatomy_data = get_template_data( project_entity=project, folder_entity=folder, @@ -95,8 +98,9 @@ class CreateHeroVersion(load.ProductLoaderPlugin): } published_representations = {} for repre in repres: - repre_anatomy = anatomy_data - repre_anatomy["ext"] = repre.get("ext", "") + repre_anatomy = copy.deepcopy(anatomy_data) + if "ext" not in repre_anatomy: + repre_anatomy["ext"] = repre.get("context", {}).get("ext", "") published_representations[repre["id"]] = { "representation": repre, "published_files": [f["path"] for f in repre.get("files", [])], @@ -140,13 +144,18 @@ class CreateHeroVersion(load.ProductLoaderPlugin): hero=True, logger=None ) - hero_template = anatomy.get_template_item("hero", template_key, "path", default=None) + hero_template = anatomy.get_template_item( + "hero", template_key, "path", default=None + ) if hero_template is None: - raise RuntimeError(f"Project anatomy does not have hero template key: {template_key}") + raise RuntimeError("Project anatomy does not have hero " + f"template key: {template_key}") print(f"Hero template: {hero_template.template}") - hero_publish_dir = self.get_publish_dir(instance_data, anatomy, template_key) + hero_publish_dir = self.get_publish_dir( + instance_data, anatomy, template_key + ) print(f"Hero publish dir: {hero_publish_dir}") @@ -162,7 +171,8 @@ class CreateHeroVersion(load.ProductLoaderPlugin): raise RuntimeError("All published representations were filtered by name.") if src_version_entity is None: - src_version_entity = self.version_from_representations(project_name, published_repres) + src_version_entity = self.version_from_representations( + project_name, published_repres) if not src_version_entity: raise RuntimeError("Can't find origin version in database.") if src_version_entity["version"] == 0: @@ -195,10 +205,14 @@ class CreateHeroVersion(load.ProductLoaderPlugin): continue if file_path in all_repre_file_paths: continue - dst_filepath = file_path.replace(instance_publish_dir, hero_publish_dir) + dst_filepath = file_path.replace( + instance_publish_dir, hero_publish_dir + ) other_file_paths_mapping.append((file_path, dst_filepath)) - old_version, old_repres = self.current_hero_ents(project_name, src_version_entity) + old_version, old_repres = self.current_hero_ents( + project_name, src_version_entity + ) inactive_old_repres_by_name = {} old_repres_by_name = {} for repre in old_repres: @@ -220,7 +234,9 @@ class CreateHeroVersion(load.ProductLoaderPlugin): ) if old_version: update_data = prepare_changes(old_version, new_hero_version) - op_session.update_entity(project_name, "version", old_version["id"], update_data) + op_session.update_entity( + project_name, "version", old_version["id"], update_data + ) else: op_session.create_entity(project_name, "version", new_hero_version) @@ -233,7 +249,9 @@ class CreateHeroVersion(load.ProductLoaderPlugin): repre = repre_info["representation"] repre_name_low = repre["name"].lower() if repre_name_low in old_repres_by_name: - old_repres_to_replace[repre_name_low] = old_repres_by_name.pop(repre_name_low) + old_repres_to_replace[repre_name_low] = ( + old_repres_by_name.pop(repre_name_low) + ) if old_repres_by_name: old_repres_to_delete = old_repres_by_name @@ -254,7 +272,9 @@ class CreateHeroVersion(load.ProductLoaderPlugin): backup_hero_publish_dir = _backup_hero_publish_dir break if idx > max_idx: - raise AssertionError(f"Backup folders are fully occupied to max index {max_idx}") + raise AssertionError( + f"Backup folders are fully occupied to max index {max_idx}" + ) idx += 1 try: os.rename(hero_publish_dir, backup_hero_publish_dir) @@ -268,6 +288,7 @@ class CreateHeroVersion(load.ProductLoaderPlugin): repre_integrate_data = [] path_template_obj = anatomy.get_template_item( "hero", template_key, "path") + anatomy_root = {"root": anatomy.roots} for repre_info in published_repres.values(): published_files = repre_info["published_files"] if len(published_files) == 0: @@ -289,10 +310,21 @@ class CreateHeroVersion(load.ProductLoaderPlugin): "template": hero_template.template } dst_paths = [] + if len(published_files) == 1: dst_paths.append(str(template_filled)) - src_to_dst_file_paths.append((published_files[0], template_filled)) - print(f"Single published file: {published_files[0]} -> {template_filled}") + mapped_published_file = StringTemplate( + published_files[0]).format_strict( + anatomy_root + ) + src_to_dst_file_paths.append( + (mapped_published_file, template_filled) + ) + print( + f"Single published file: {mapped_published_file} -> " + f"{template_filled}" + ) + # src_to_dst_file_paths being wrong else: collections, remainders = clique.assemble(published_files) if remainders or not collections or len(collections) > 1: @@ -302,23 +334,34 @@ class CreateHeroVersion(load.ProductLoaderPlugin): src_col = collections[0] frame_splitter = "_-_FRAME_SPLIT_-_" anatomy_data["frame"] = frame_splitter - _template_filled = path_template_obj.format_strict(anatomy_data) + _template_filled = path_template_obj.format_strict( + anatomy_data + ) head, tail = _template_filled.split(frame_splitter) padding = anatomy.templates_obj.frame_padding - dst_col = clique.Collection(head=head, padding=padding, tail=tail) + dst_col = clique.Collection( + head=head, padding=padding, tail=tail + ) dst_col.indexes.clear() dst_col.indexes.update(src_col.indexes) for src_file, dst_file in zip(src_col, dst_col): + src_file = StringTemplate(src_file).format_strict( + anatomy_root + ) src_to_dst_file_paths.append((src_file, dst_file)) dst_paths.append(dst_file) - print(f"Collection published file: {src_file} -> {dst_file}") + print( + f"Collection published file: {src_file} " + f"-> {dst_file}" + ) repre_integrate_data.append((repre_entity, dst_paths)) # Copy files with ThreadPoolExecutor(max_workers=8) as executor: futures = [ executor.submit(self.copy_file, src_path, dst_path) - for src_path, dst_path in itertools.chain(src_to_dst_file_paths, other_file_paths_mapping) + for src_path, dst_path in itertools.chain( + src_to_dst_file_paths, other_file_paths_mapping) ] wait_for_future_errors(executor, futures) @@ -331,25 +374,49 @@ class CreateHeroVersion(load.ProductLoaderPlugin): old_repre = old_repres_to_replace.pop(repre_name_low) repre_entity["id"] = old_repre["id"] update_data = prepare_changes(old_repre, repre_entity) - op_session.update_entity(project_name, "representation", old_repre["id"], update_data) + op_session.update_entity( + project_name, + "representation", + old_repre["id"], + update_data + ) elif repre_name_low in inactive_old_repres_by_name: - inactive_repre = inactive_old_repres_by_name.pop(repre_name_low) + inactive_repre = inactive_old_repres_by_name.pop( + repre_name_low + ) repre_entity["id"] = inactive_repre["id"] update_data = prepare_changes(inactive_repre, repre_entity) - op_session.update_entity(project_name, "representation", inactive_repre["id"], update_data) + op_session.update_entity( + project_name, + "representation", + inactive_repre["id"], + update_data + ) else: - op_session.create_entity(project_name, "representation", repre_entity) + op_session.create_entity( + project_name, + "representation", + repre_entity + ) for repre in old_repres_to_delete.values(): - op_session.update_entity(project_name, "representation", repre["id"], {"active": False}) + op_session.update_entity( + project_name, + "representation", + repre["id"], + {"active": False} + ) op_session.commit() - if backup_hero_publish_dir is not None and os.path.exists(backup_hero_publish_dir): + if backup_hero_publish_dir is not None and os.path.exists( + backup_hero_publish_dir + ): shutil.rmtree(backup_hero_publish_dir) except Exception: - if backup_hero_publish_dir is not None and os.path.exists(backup_hero_publish_dir): + if backup_hero_publish_dir is not None and os.path.exists( + backup_hero_publish_dir): if os.path.exists(hero_publish_dir): shutil.rmtree(hero_publish_dir) os.rename(backup_hero_publish_dir, hero_publish_dir) @@ -375,8 +442,12 @@ class CreateHeroVersion(load.ProductLoaderPlugin): def get_publish_dir(self, instance_data, anatomy, template_key): template_data = copy.deepcopy(instance_data.get("anatomyData", {})) if "originalBasename" in instance_data: - template_data["originalBasename"] = instance_data["originalBasename"] - template_obj = anatomy.get_template_item("hero", template_key, "directory") + template_data["originalBasename"] = ( + instance_data["originalBasename"] + ) + template_obj = anatomy.get_template_item( + "hero", template_key, "directory" + ) return os.path.normpath(template_obj.format_strict(template_data)) def get_rootless_path(self, anatomy, path): @@ -403,13 +474,21 @@ class CreateHeroVersion(load.ProductLoaderPlugin): def version_from_representations(self, project_name, repres): for repre_info in repres.values(): - version = ayon_api.get_version_by_id(project_name, repre_info["representation"]["versionId"]) + version = ayon_api.get_version_by_id( + project_name, repre_info["representation"]["versionId"] + ) if version: return version def current_hero_ents(self, project_name, version): - hero_version = ayon_api.get_hero_version_by_product_id(project_name, version["productId"]) + hero_version = ayon_api.get_hero_version_by_product_id( + project_name, version["productId"] + ) if not hero_version: return (None, []) - hero_repres = list(ayon_api.get_representations(project_name, version_ids={hero_version["id"]})) + hero_repres = list( + ayon_api.get_representations( + project_name, version_ids={hero_version["id"]} + ) + ) return (hero_version, hero_repres) From 7e9493736d1abbddda6b2efa37302ac03a864fe3 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 15 Aug 2025 22:27:22 +0800 Subject: [PATCH 200/319] ruff fix --- .../plugins/load/create_hero_version.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/client/ayon_core/plugins/load/create_hero_version.py b/client/ayon_core/plugins/load/create_hero_version.py index b18e874644..d741dafcce 100644 --- a/client/ayon_core/plugins/load/create_hero_version.py +++ b/client/ayon_core/plugins/load/create_hero_version.py @@ -64,7 +64,6 @@ class CreateHeroVersion(load.ProductLoaderPlugin): ) msgBox.exec_() - def load(self, context, name=None, namespace=None, options=None) -> None: """Load hero version from context (dict as in context.py).""" success = True @@ -168,7 +167,9 @@ class CreateHeroVersion(load.ProductLoaderPlugin): for repre_id in filtered_repre_ids: published_repres.pop(repre_id, None) if not published_repres: - raise RuntimeError("All published representations were filtered by name.") + raise RuntimeError( + "All published representations were filtered by name." + ) if src_version_entity is None: src_version_entity = self.version_from_representations( @@ -266,15 +267,18 @@ class CreateHeroVersion(load.ProductLoaderPlugin): shutil.rmtree(_backup_hero_publish_dir) backup_hero_publish_dir = _backup_hero_publish_dir break - except Exception: - _backup_hero_publish_dir = backup_hero_publish_dir + str(idx) + except Exception as exc: + _backup_hero_publish_dir = ( + backup_hero_publish_dir + str(idx) + ) if not os.path.exists(_backup_hero_publish_dir): backup_hero_publish_dir = _backup_hero_publish_dir break if idx > max_idx: raise AssertionError( - f"Backup folders are fully occupied to max index {max_idx}" - ) + "Backup folders are fully occupied to max index " + f"{max_idx}" + ) from exc idx += 1 try: os.rename(hero_publish_dir, backup_hero_publish_dir) @@ -324,13 +328,16 @@ class CreateHeroVersion(load.ProductLoaderPlugin): f"Single published file: {mapped_published_file} -> " f"{template_filled}" ) - # src_to_dst_file_paths being wrong else: collections, remainders = clique.assemble(published_files) if remainders or not collections or len(collections) > 1: raise Exception( - "Integrity error. Files of published representation is " - "combination of frame collections and single files.") + ( + "Integrity error. Files of published " + "representation is combination of frame " + "collections and single files." + ) + ) src_col = collections[0] frame_splitter = "_-_FRAME_SPLIT_-_" anatomy_data["frame"] = frame_splitter From 60558e440c93a167c1c58e8614178ff15e9af23f Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:16:17 +0200 Subject: [PATCH 201/319] Removed unnecessary field --- client/ayon_core/tools/push_to_project/control.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index eb985a3f8c..b52eeb5fad 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -40,7 +40,6 @@ class PushToContextController: self.set_source(project_name, version_id) - self._library_only = True # Events system def emit_event(self, topic, data=None, source=None): From 86130207186b40667ff436d077712958cecab31f Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:17:10 +0200 Subject: [PATCH 202/319] Change formatting --- client/ayon_core/tools/push_to_project/ui/window.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 344295f177..b2f3983557 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -99,8 +99,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): header_layout = QtWidgets.QHBoxLayout(header_widget) header_layout.setContentsMargins(0, 0, 0, 0) - header_layout.addWidget(header_label) - header_layout.addStretch(1) + header_layout.addWidget(header_label, 1) header_layout.addWidget(library_only_label, 0) header_layout.addWidget(library_only_checkbox, 0) From e7c0c8dab4fb91b010e587ac5f43694ac2beed50 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:19:04 +0200 Subject: [PATCH 203/319] Removed unnecessary refresh --- client/ayon_core/tools/push_to_project/ui/window.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index b2f3983557..38c343b023 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -410,6 +410,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._projects_combobox.set_standard_filter_enabled(state) self._projects_combobox.refresh() + def _on_user_input_timer(self): folder_name_enabled = self._new_folder_name_enabled folder_name = self._new_folder_name_input_text From 92ecc854c9396e6bef33d9b68619320cc4ecf08e Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:23:51 +0200 Subject: [PATCH 204/319] Simplified _copy_version_thumbnail logic Used cached get_thumbnail_path --- .../tools/push_to_project/models/integrate.py | 50 ++++++++----------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 341858148b..b180892d62 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -22,6 +22,7 @@ from ayon_core.lib import ( source_hash, ) from ayon_core.lib.file_transaction import FileTransaction +from ayon_core.pipeline.thumbnails import get_thumbnail_path from ayon_core.settings import get_project_settings from ayon_core.pipeline import Anatomy from ayon_core.pipeline.version_start import get_versioning_start @@ -1150,36 +1151,27 @@ class ProjectPushItemProcess: ) def _copy_version_thumbnail(self): - version_thumbnail = ayon_api.get_version_thumbnail( - self._item.src_project_name, self._src_version_entity["id"]) - if not version_thumbnail or not version_thumbnail.id: + thumbnail_id = self._src_version_entity["thumbnailId"] + if not thumbnail_id: return - - temp_file_name = None - try: - with tempfile.NamedTemporaryFile(mode='w+b', delete=False) as fp: - fp.write(version_thumbnail.content) - temp_file_name = fp.name - - new_thumbnail_id = ayon_api.create_thumbnail( - self._item.dst_project_name, - temp_file_name - ) - - task_id = None - if self._task_info: - task_id = self._task_info["id"] - - self._operations.update_version( - project_name=self._item.dst_project_name, - version_id=self._version_entity["id"], - task_id=task_id, - thumbnail_id=new_thumbnail_id - ) - self._operations.commit() - finally: - if temp_file_name and os.path.exists(temp_file_name): - os.remove(temp_file_name) + path = get_thumbnail_path( + self._item.src_project_name, + "version", + self._src_version_entity["id"], + thumbnail_id + ) + if not path: + return + new_thumbnail_id = ayon_api.create_thumbnail( + self._item.dst_project_name, + path + ) + self._operations.update_version( + project_name=self._item.dst_project_name, + version_id=self._version_entity["id"], + thumbnail_id=new_thumbnail_id + ) + self._operations.commit() class IntegrateModel: From 3faee05cf6c05e089d8be8d42708493e7114933b Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:28:24 +0200 Subject: [PATCH 205/319] Added toggle for keeping original names of publishes --- .../ayon_core/tools/push_to_project/control.py | 10 ++++++---- .../tools/push_to_project/ui/window.py | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index b52eeb5fad..5e1f758d79 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -40,6 +40,8 @@ class PushToContextController: self.set_source(project_name, version_id) + self._use_original_name = False + # Events system def emit_event(self, topic, data=None, source=None): @@ -315,6 +317,8 @@ class PushToContextController: return product_name def _check_submit_validations(self): + if self._use_original_name: + return True if not self._user_values.is_valid: return False @@ -339,10 +343,8 @@ class PushToContextController: ) def _submit_callback(self): - process_item_id = self._process_item_id - if process_item_id is None: - return - self._integrate_model.integrate_item(process_item_id) + for process_item_id in self._process_item_ids: + self._integrate_model.integrate_item(process_item_id) self._emit_event("submit.finished", {}) if process_item_id == self._process_item_id: self._process_item_id = None diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 38c343b023..1f40958a66 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -133,6 +133,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): inputs_widget = QtWidgets.QWidget(main_splitter) new_folder_checkbox = NiceCheckbox(True, parent=inputs_widget) + original_names_checkbox = NiceCheckbox(False, parent=inputs_widget) folder_name_input = PlaceholderLineEdit(inputs_widget) folder_name_input.setPlaceholderText("< Name of new folder >") @@ -151,6 +152,8 @@ class PushToContextSelectWindow(QtWidgets.QWidget): inputs_layout.addRow("Create new folder", new_folder_checkbox) inputs_layout.addRow("New folder name", folder_name_input) inputs_layout.addRow("Variant", variant_input) + inputs_layout.addRow( + "Use original product names", original_names_checkbox) inputs_layout.addRow("Comment", comment_input) main_splitter.addWidget(context_widget) @@ -250,6 +253,8 @@ class PushToContextSelectWindow(QtWidgets.QWidget): variant_input.textChanged.connect(self._on_variant_change) comment_input.textChanged.connect(self._on_comment_change) library_only_checkbox.stateChanged.connect(self._on_library_only_change) + original_names_checkbox.stateChanged.connect( + self._on_original_names_change) publish_btn.clicked.connect(self._on_select_click) cancel_btn.clicked.connect(self._on_close_click) @@ -408,8 +413,15 @@ class PushToContextSelectWindow(QtWidgets.QWidget): """Change toggle state, reset filter, recalculate dropdown""" state = bool(state) self._projects_combobox.set_standard_filter_enabled(state) - self._projects_combobox.refresh() + def _on_original_names_change(self, state: int) -> None: + use_original_name = bool(state) + self._new_folder_name_enabled = not use_original_name + self._new_folder_checkbox.setEnabled(not use_original_name) + self._folder_name_input.setEnabled(not use_original_name) + self._variant_input.setEnabled(not use_original_name) + self._controller._use_original_name = use_original_name + self.refresh() def _on_user_input_timer(self): folder_name_enabled = self._new_folder_name_enabled @@ -466,6 +478,8 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._header_label.setText(self._controller.get_source_label()) def _invalidate_new_folder_name(self, folder_name, is_valid): + if self._controller._use_original_name: + is_valid = True self._tasks_widget.setVisible(folder_name is None) if self._folder_is_valid is is_valid: return @@ -478,6 +492,8 @@ class PushToContextSelectWindow(QtWidgets.QWidget): ) def _invalidate_variant(self, is_valid): + if self._controller._use_original_name: + is_valid = True if self._variant_is_valid is is_valid: return self._variant_is_valid = is_valid From ef9ab3bcdc106854472608a5a0772888ed128089 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:31:31 +0200 Subject: [PATCH 206/319] Changed main input to accept multiple version ids --- client/ayon_core/tools/push_to_project/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/main.py b/client/ayon_core/tools/push_to_project/main.py index a6ff38c16f..3a80dc2bb2 100644 --- a/client/ayon_core/tools/push_to_project/main.py +++ b/client/ayon_core/tools/push_to_project/main.py @@ -4,28 +4,28 @@ from ayon_core.tools.utils import get_ayon_qt_app from ayon_core.tools.push_to_project.ui import PushToContextSelectWindow -def main_show(project_name, version_id): +def main_show(project_name, version_ids): app = get_ayon_qt_app() window = PushToContextSelectWindow() window.show() - window.set_source(project_name, version_id) + window.set_source(project_name, version_ids) app.exec_() @click.command() @click.option("--project", help="Source project name") -@click.option("--version", help="Source version id") -def main(project, version): +@click.option("--versions", help="Source version ids") +def main(project, versions): """Run PushToProject tool to integrate version in different project. Args: project (str): Source project name. - version (str): Version id. + versions (str): comma separated versions for same context """ - main_show(project, version) + main_show(project, versions) if __name__ == "__main__": From 965f937e28022e6154e4f2f5ace34e429580a764 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:32:15 +0200 Subject: [PATCH 207/319] Implemented loader action to push multiple versions --- client/ayon_core/plugins/load/push_to_library.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/plugins/load/push_to_library.py b/client/ayon_core/plugins/load/push_to_library.py index 22c10bbad7..42a63a8625 100644 --- a/client/ayon_core/plugins/load/push_to_library.py +++ b/client/ayon_core/plugins/load/push_to_library.py @@ -28,25 +28,22 @@ class PushToLibraryProject(load.ProductLoaderPlugin): if not filtered_contexts: raise LoadError("Nothing to push for your selection") - if len(filtered_contexts) > 1: - raise LoadError("Please select only one item") - - context = tuple(filtered_contexts)[0] - push_tool_script_path = os.path.join( AYON_CORE_ROOT, "tools", "push_to_project", "main.py" ) + project_name = tuple(filtered_contexts)[0]["project"]["name"] - project_name = context["project"]["name"] - version_id = context["version"]["id"] + version_ids = [] + for context in filtered_contexts: + version_ids.append(context["version"]["id"]) args = get_ayon_launcher_args( "run", push_tool_script_path, "--project", project_name, - "--version", version_id + "--versions", ",".join(version_ids) ) run_detached_process(args) From 073f8bfec58f4ab97d04ee74e4f88b20857e87ec Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:35:05 +0200 Subject: [PATCH 208/319] Implemented processing of multiple items --- .../tools/push_to_project/control.py | 121 ++++++++++-------- .../tools/push_to_project/ui/window.py | 46 ++++--- 2 files changed, 100 insertions(+), 67 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 5e1f758d79..88031d2a8a 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -27,11 +27,11 @@ class PushToContextController: self._user_values = UserPublishValuesModel(self) self._src_project_name = None - self._src_version_id = None + self._src_version_ids = [] self._src_folder_entity = None self._src_folder_task_entities = {} - self._src_product_entity = None - self._src_version_entity = None + self._src_product_entities = [] + self._src_version_entities = [] self._src_label = None self._submission_enabled = False @@ -54,38 +54,43 @@ class PushToContextController: def register_event_callback(self, topic, callback): self._event_system.add_callback(topic, callback) - def set_source(self, project_name, version_id): + def set_source(self, project_name, version_ids): """Set source project and version. Args: project_name (Union[str, None]): Source project name. - version_id (Union[str, None]): Source version id. + version_id (Union[str, None]): Comma separated source version ids. """ if ( project_name == self._src_project_name - and version_id == self._src_version_id + and version_ids == self._src_version_ids ): return self._src_project_name = project_name - self._src_version_id = version_id + self._src_version_ids = version_ids.split(",") self._src_label = None folder_entity = None task_entities = {} - product_entity = None - version_entity = None - if project_name and version_id: - version_entity = ayon_api.get_version_by_id( - project_name, version_id + product_entities = None + version_entities = None + if project_name and self._src_version_ids: + version_entities = list(ayon_api.get_versions( + project_name, version_ids=self._src_version_ids)) + + if version_entities: + product_ids = [ + version_entity["productId"] + for version_entity in version_entities + ] + product_entities = list(ayon_api.get_products( + project_name, product_ids=product_ids) ) - if version_entity: - product_entity = ayon_api.get_product_by_id( - project_name, version_entity["productId"] - ) - - if product_entity: + if product_entities: + # all products for same folder + product_entity = product_entities[0] folder_entity = ayon_api.get_folder_by_id( project_name, product_entity["folderId"] ) @@ -100,15 +105,15 @@ class PushToContextController: self._src_folder_entity = folder_entity self._src_folder_task_entities = task_entities - self._src_product_entity = product_entity - self._src_version_entity = version_entity - if folder_entity: + self._src_product_entities = product_entities + self._src_version_entities = version_entities + if folder_entity and len(list(version_entities)) == 1: self._user_values.set_new_folder_name(folder_entity["name"]) variant = self._get_src_variant() if variant: self._user_values.set_variant(variant) - comment = version_entity["attrib"].get("comment") + comment = version_entities[0]["attrib"].get("comment") if comment: self._user_values.set_comment(comment) @@ -116,7 +121,7 @@ class PushToContextController: "source.changed", { "project_name": project_name, - "version_id": version_id + "version_ids": self._src_version_ids } ) @@ -179,29 +184,32 @@ class PushToContextController: if self._process_thread is not None: return - item_id = self._integrate_model.create_process_item( - self._src_project_name, - self._src_version_id, - self._selection_model.get_selected_project_name(), - self._selection_model.get_selected_folder_id(), - self._selection_model.get_selected_task_name(), - self._user_values.variant, - comment=self._user_values.comment, - new_folder_name=self._user_values.new_folder_name, - dst_version=1 - ) + item_ids = [] + for src_version_entity in self._src_version_entities: + item_id = self._integrate_model.create_process_item( + self._src_project_name, + src_version_entity["id"], + self._selection_model.get_selected_project_name(), + self._selection_model.get_selected_folder_id(), + self._selection_model.get_selected_task_name(), + self._user_values.variant, + comment=self._user_values.comment, + new_folder_name=self._user_values.new_folder_name, + dst_version=1, + ) + item_ids.append(item_id) - self._process_item_id = item_id + self._process_item_ids = item_ids self._emit_event("submit.started") if wait: self._submit_callback() - self._process_item_id = None + self._process_item_ids = [] return item_id thread = threading.Thread(target=self._submit_callback) self._process_thread = thread thread.start() - return item_id + return item_ids def wait_for_process_thread(self): if self._process_thread is None: @@ -210,22 +218,34 @@ class PushToContextController: self._process_thread = None def _prepare_source_label(self): - if not self._src_project_name or not self._src_version_id: + if not self._src_project_name or not self._src_version_ids: return "Source is not defined" folder_entity = self._src_folder_entity if not folder_entity: return "Source is invalid" + no_of_products = len(self._src_product_entities) + no_of_versions = len(self._src_version_entities) + if no_of_products != no_of_versions: + return (f"Not matching number of products {no_of_products} and " + f"versions {no_of_versions}") + folder_path = folder_entity["path"] - product_entity = self._src_product_entity - version_entity = self._src_version_entity - return "Source: {}{}/{}/v{:0>3}".format( - self._src_project_name, - folder_path, - product_entity["name"], - version_entity["version"] - ) + src_labels = [] + for idx in range(0, no_of_versions): + product_entity = self._src_product_entities[idx] + version_entity = self._src_version_entities[idx] + src_labels.append( + "Source: {}{}/{}/v{:0>3}".format( + self._src_project_name, + folder_path, + product_entity["name"], + version_entity["version"], + ) + ) + + return "\n".join(src_labels) def _get_task_info_from_repre_entities( self, task_entities, repre_entities @@ -258,8 +278,9 @@ class PushToContextController: return None, None def _get_src_variant(self): + """Could be triggered only if single version is moved.""" project_name = self._src_project_name - version_entity = self._src_version_entity + version_entity = self._src_version_entities[0] task_entities = self._src_folder_task_entities repre_entities = ayon_api.get_representations( project_name, version_ids={version_entity["id"]} @@ -269,7 +290,7 @@ class PushToContextController: ) project_settings = get_project_settings(project_name) - product_type = self._src_product_entity["productType"] + product_type = self._src_product_entities[0]["productType"] template = get_product_name_template( self._src_project_name, product_type, @@ -303,7 +324,7 @@ class PushToContextController: print("Failed format", exc) return "" - product_name = self._src_product_entity["name"] + product_name = self._src_product_entities[0]["name"] if ( (product_s and not product_name.startswith(product_s)) or (product_e and not product_name.endswith(product_e)) @@ -346,8 +367,6 @@ class PushToContextController: for process_item_id in self._process_item_ids: self._integrate_model.integrate_item(process_item_id) self._emit_event("submit.finished", {}) - if process_item_id == self._process_item_id: - self._process_item_id = None def _emit_event(self, topic, data=None): if data is None: diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 1f40958a66..147191e659 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -331,7 +331,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._main_thread_timer = main_thread_timer self._main_thread_timer_can_stop = True self._last_submit_message = None - self._process_item_id = None + self._process_item_ids = [] self._variant_is_valid = None self._folder_is_valid = None @@ -342,17 +342,17 @@ class PushToContextSelectWindow(QtWidgets.QWidget): overlay_try_btn.setVisible(False) # Support of public api function of controller - def set_source(self, project_name, version_id): + def set_source(self, project_name, version_ids): """Set source project and version. Call the method on controller. Args: project_name (Union[str, None]): Name of project. - version_id (Union[str, None]): Version id. + version_id (Union[str, None]): Version ids. """ - self._controller.set_source(project_name, version_id) + self._controller.set_source(project_name, version_ids) def showEvent(self, event): super(PushToContextSelectWindow, self).showEvent(event) @@ -528,31 +528,45 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._overlay_label.setText(self._last_submit_message) self._last_submit_message = None - process_status = self._controller.get_process_item_status( - self._process_item_id - ) - push_failed = process_status["failed"] - fail_traceback = process_status["full_traceback"] + failed_pushes = [] + fail_tracebacks = [] + for process_item_id in self._process_item_ids: + process_status = self._controller.get_process_item_status( + process_item_id + ) + if process_status["failed"]: + failed_pushes.append(process_status) + # push_failed = process_status["failed"] + # fail_traceback = process_status["full_traceback"] if self._main_thread_timer_can_stop: self._main_thread_timer.stop() self._overlay_close_btn.setVisible(True) - if push_failed: + if failed_pushes: self._overlay_try_btn.setVisible(True) - if fail_traceback: + fail_tracebacks = [ + process_status["full_traceback"] + for process_status in failed_pushes + if process_status["full_traceback"] + ] + if fail_tracebacks: self._show_detail_btn.setVisible(True) - if push_failed: - reason = process_status["fail_reason"] - if fail_traceback: + if failed_pushes: + reasons = [ + process_status["fail_reason"] + for process_status in failed_pushes + ] + if fail_tracebacks: + reason = "\n".join(reasons) message = ( "Unhandled error happened." " Check error detail for more information." ) self._error_detail_dialog.set_detail( - reason, fail_traceback + reason, "\n".join(fail_tracebacks) ) else: - message = f"Push Failed:\n{reason}" + message = f"Push Failed:\n{reasons}" self._overlay_label.setText(message) set_style_property(self._overlay_close_btn, "state", "error") From c7c28e1153777d12f4c69b3f76095fcd2bb667df Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:37:03 +0200 Subject: [PATCH 209/319] Pushed use_original_name to ProjectPushItem --- .../tools/push_to_project/control.py | 1 + .../tools/push_to_project/models/integrate.py | 66 +++++++++++-------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 88031d2a8a..483efdd22d 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -196,6 +196,7 @@ class PushToContextController: comment=self._user_values.comment, new_folder_name=self._user_values.new_folder_name, dst_version=1, + use_original_name=self._use_original_name, ) item_ids.append(item_id) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index b180892d62..c66c74219c 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -90,6 +90,7 @@ class ProjectPushItem: new_folder_name, dst_version, item_id=None, + use_original_name=False ): if not item_id: item_id = uuid.uuid4().hex @@ -104,6 +105,7 @@ class ProjectPushItem: self.comment = comment or "" self.item_id = item_id self._repr_value = None + self.use_original_name = use_original_name @property def _repr(self): @@ -115,7 +117,8 @@ class ProjectPushItem: str(self.dst_folder_id), str(self.new_folder_name), str(self.dst_task_name), - str(self.dst_version) + str(self.dst_version), + self.use_original_name ]) return self._repr_value @@ -134,6 +137,7 @@ class ProjectPushItem: "comment": self.comment, "new_folder_name": self.new_folder_name, "item_id": self.item_id, + "use_original_name": self.use_original_name } @classmethod @@ -373,7 +377,7 @@ class ProjectPushRepreItem: resource_files.append(ResourceFile(filepath, relative_path)) continue - filepath = os.path.join(src_dirpath, basename) + # filepath = os.path.join(src_dirpath, basename) frame = None udim = None for item in src_basename_regex.finditer(basename): @@ -819,31 +823,34 @@ class ProjectPushItemProcess: self._template_name = template_name def _determine_product_name(self): - product_type = self._product_type - task_info = self._task_info - task_name = task_type = None - if task_info: - task_name = task_info["name"] - task_type = task_info["taskType"] + if self._item.use_original_name: + product_name = self._src_product_entity["name"] + else: + product_type = self._product_type + task_info = self._task_info + task_name = task_type = None + if task_info: + task_name = task_info["name"] + task_type = task_info["taskType"] - try: - product_name = get_product_name( - self._item.dst_project_name, - task_name, - task_type, - self.host_name, - product_type, - self._item.variant, - project_settings=self._project_settings - ) - except TaskNotSetError: - self._status.set_failed( - "Target product name template requires task name. To continue" - " you have to select target task or change settings" - " ayon+settings://core/tools/creator/product_name_profiles" - f"?project={self._item.dst_project_name}." - ) - raise PushToProjectError(self._status.fail_reason) + try: + product_name = get_product_name( + self._item.dst_project_name, + task_name, + task_type, + self.host_name, + product_type, + self._item.variant, + project_settings=self._project_settings + ) + except TaskNotSetError: + self._status.set_failed( + "Target product name template requires task name. To " + "continue you have to select target task or change settings " + " ayon+settings://core/tools/creator/product_name_profiles" + f"?project={self._item.dst_project_name}." + ) + raise PushToProjectError(self._status.fail_reason) self._log_info( f"Push will be integrating to product with name '{product_name}'" @@ -1137,7 +1144,7 @@ class ProjectPushItemProcess: self._item.dst_project_name, "representation", entity_id, - changes + changes, ) existing_repre_names = set(existing_repres_by_low_name.keys()) @@ -1196,6 +1203,7 @@ class IntegrateModel: comment, new_folder_name, dst_version, + use_original_name ): """Create new item for integration. @@ -1209,6 +1217,7 @@ class IntegrateModel: comment (Union[str, None]): Comment. new_folder_name (Union[str, None]): New folder name. dst_version (int): Destination version number. + use_original_name (bool): If original product names should be used Returns: str: Item id. The id can be used to trigger integration or get @@ -1224,7 +1233,8 @@ class IntegrateModel: variant, comment=comment, new_folder_name=new_folder_name, - dst_version=dst_version + dst_version=dst_version, + use_original_name=use_original_name ) process_item = ProjectPushItemProcess(self, item) self._process_items[item.item_id] = process_item From 4a44570799f6d5a020a72b6cef60446163782600 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:37:36 +0200 Subject: [PATCH 210/319] Invalidate all input fields after refresh --- client/ayon_core/tools/push_to_project/ui/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 147191e659..d07488e719 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -370,7 +370,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._invalidate_new_folder_name( new_folder_name, user_values["is_new_folder_name_valid"] ) - + self._controller._invalidate() self._projects_combobox.refresh() def _on_first_show(self): From 6c6be3508f5292324123fad320d78d98644b7de9 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:53:14 +0200 Subject: [PATCH 211/319] Propagate taskId to limit json parse issue --- client/ayon_core/tools/push_to_project/models/integrate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index b180892d62..0c654a5495 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -1169,6 +1169,7 @@ class ProjectPushItemProcess: self._operations.update_version( project_name=self._item.dst_project_name, version_id=self._version_entity["id"], + task_id=self._version_entity.get("taskId"), thumbnail_id=new_thumbnail_id ) self._operations.commit() From 7860c7d875c539f52bfdd78c590ebc77a80c5af6 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 13:55:49 +0200 Subject: [PATCH 212/319] Removed unnecessary refresh --- client/ayon_core/tools/push_to_project/ui/window.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 38c343b023..495ef83ce6 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -408,8 +408,6 @@ class PushToContextSelectWindow(QtWidgets.QWidget): """Change toggle state, reset filter, recalculate dropdown""" state = bool(state) self._projects_combobox.set_standard_filter_enabled(state) - self._projects_combobox.refresh() - def _on_user_input_timer(self): folder_name_enabled = self._new_folder_name_enabled From d79bd055bcf771553076016b5cfd02e9ad4c5468 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 14:03:08 +0200 Subject: [PATCH 213/319] Removed unnecessary import --- client/ayon_core/tools/push_to_project/models/integrate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 0c654a5495..ac2f506112 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -3,7 +3,6 @@ import re import copy import itertools import sys -import tempfile import traceback import uuid From 930439ba12990611d8b01a7114fc4cdd5a77dab2 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 14:26:28 +0200 Subject: [PATCH 214/319] Fix copy of frames based representations --- client/ayon_core/tools/push_to_project/models/integrate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index ac2f506112..40c418e513 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -372,7 +372,6 @@ class ProjectPushRepreItem: resource_files.append(ResourceFile(filepath, relative_path)) continue - filepath = os.path.join(src_dirpath, basename) frame = None udim = None for item in src_basename_regex.finditer(basename): From 18ad64e2260124407cef7d01d37e5ceba0527f20 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 14:43:29 +0200 Subject: [PATCH 215/319] Updated _copy_version_thumbnail logic --- .../tools/push_to_project/models/integrate.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 40c418e513..08fafcbf2d 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -484,7 +484,6 @@ class ProjectPushItemProcess: self._make_sure_version_exists() self._log_info("Prerequirements were prepared") self._integrate_representations() - self._copy_version_thumbnail() self._log_info("Integration finished") except PushToProjectError as exc: @@ -918,14 +917,19 @@ class ProjectPushItemProcess: task_name=self._task_info["name"], task_type=self._task_info["taskType"], product_type=product_type, - product_name=product_entity["name"] + product_name=product_entity["name"], ) existing_version_entity = ayon_api.get_version_by_name( project_name, version, product_id ) + thumbnail_id = self._copy_version_thumbnail() + # Update existing version if existing_version_entity: + updata_data = {"attrib": dst_attrib} + if thumbnail_id: + updata_data["thumbnailId"] = thumbnail_id self._operations.update_entity( project_name, "version", @@ -940,6 +944,7 @@ class ProjectPushItemProcess: version, product_id, attribs=dst_attrib, + thumbnail_id=thumbnail_id, ) self._operations.create_entity( project_name, "version", version_entity @@ -1160,17 +1165,10 @@ class ProjectPushItemProcess: ) if not path: return - new_thumbnail_id = ayon_api.create_thumbnail( + return ayon_api.create_thumbnail( self._item.dst_project_name, path ) - self._operations.update_version( - project_name=self._item.dst_project_name, - version_id=self._version_entity["id"], - task_id=self._version_entity.get("taskId"), - thumbnail_id=new_thumbnail_id - ) - self._operations.commit() class IntegrateModel: From c2b6204c0a1c10b463e9810009015b3e326df8ba Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 15:09:17 +0200 Subject: [PATCH 216/319] Formatting change --- client/ayon_core/tools/push_to_project/control.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index b52eeb5fad..fb080d158b 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -40,7 +40,6 @@ class PushToContextController: self.set_source(project_name, version_id) - # Events system def emit_event(self, topic, data=None, source=None): """Use implemented event system to trigger event.""" From 8586431f17ac6503f604e7c1cf9be440f6483e6b Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 15:34:54 +0200 Subject: [PATCH 217/319] Fix version id argument --- client/ayon_core/tools/push_to_project/control.py | 9 +++++---- client/ayon_core/tools/push_to_project/ui/window.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 1ccda9440d..b90e938cf3 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -16,7 +16,7 @@ from .models import ( class PushToContextController: - def __init__(self, project_name=None, version_id=None): + def __init__(self, project_name=None, version_ids=None): self._event_system = self._create_event_system() self._projects_model = ProjectsModel(self) @@ -38,7 +38,7 @@ class PushToContextController: self._process_thread = None self._process_item_id = None - self.set_source(project_name, version_id) + self.set_source(project_name, version_ids) self._use_original_name = False @@ -58,9 +58,10 @@ class PushToContextController: Args: project_name (Union[str, None]): Source project name. - version_id (Union[str, None]): Comma separated source version ids. + version_ids (Union[str, None]): Comma separated source version ids. """ - + if not project_name or not version_ids: + return if ( project_name == self._src_project_name and version_ids == self._src_version_ids diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index d07488e719..3fb1822d92 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -349,7 +349,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): Args: project_name (Union[str, None]): Name of project. - version_id (Union[str, None]): Version ids. + version_ids (Union[str, None]): comma separated Version ids. """ self._controller.set_source(project_name, version_ids) From cb09825b8b36802b443d1ad5a06ac250361ca004 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 16:33:57 +0200 Subject: [PATCH 218/319] Removed set_source in init --- client/ayon_core/tools/push_to_project/control.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index b90e938cf3..d02cd4dfc0 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -38,8 +38,6 @@ class PushToContextController: self._process_thread = None self._process_item_id = None - self.set_source(project_name, version_ids) - self._use_original_name = False # Events system From 629794f6d64d4569fa03f48b13e5d2013697ff4e Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 16:41:08 +0200 Subject: [PATCH 219/319] Return formatting change Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/models/integrate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 08fafcbf2d..73a00a5cd9 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -1156,7 +1156,7 @@ class ProjectPushItemProcess: def _copy_version_thumbnail(self): thumbnail_id = self._src_version_entity["thumbnailId"] if not thumbnail_id: - return + return None path = get_thumbnail_path( self._item.src_project_name, "version", From 78cd71138337f54fef8544a34625cf5d06b9e53b Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 16:41:18 +0200 Subject: [PATCH 220/319] Return formatting change Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/models/integrate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 73a00a5cd9..197cefe819 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -1164,7 +1164,7 @@ class ProjectPushItemProcess: thumbnail_id ) if not path: - return + return None return ayon_api.create_thumbnail( self._item.dst_project_name, path From 8d4bcd1310c5c71e74785fbb11a421f8a8c45e72 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 16:41:31 +0200 Subject: [PATCH 221/319] Typing Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/models/integrate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 197cefe819..c512d3ef68 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -1153,7 +1153,7 @@ class ProjectPushItemProcess: {"active": False} ) - def _copy_version_thumbnail(self): + def _copy_version_thumbnail(self) -> Optional[str]: thumbnail_id = self._src_version_entity["thumbnailId"] if not thumbnail_id: return None From 3b9b5e8063d3c44615ffa8cda43cd2fcd279cc98 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 16:50:55 +0200 Subject: [PATCH 222/319] Removed run argument to not filter out project argument Current develop filters out 'project' cli argument as it is now used as key world for bundle per project implementation. --- client/ayon_core/plugins/load/push_to_library.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/plugins/load/push_to_library.py b/client/ayon_core/plugins/load/push_to_library.py index 22c10bbad7..3c7c7e503d 100644 --- a/client/ayon_core/plugins/load/push_to_library.py +++ b/client/ayon_core/plugins/load/push_to_library.py @@ -44,7 +44,6 @@ class PushToLibraryProject(load.ProductLoaderPlugin): version_id = context["version"]["id"] args = get_ayon_launcher_args( - "run", push_tool_script_path, "--project", project_name, "--version", version_id From ef34e9f79eebe12f3f1fdf845e1963a8dd83cd0b Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 16:53:33 +0200 Subject: [PATCH 223/319] Renamed loader --- .../plugins/load/{push_to_library.py => push_to_project.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename client/ayon_core/plugins/load/{push_to_library.py => push_to_project.py} (91%) diff --git a/client/ayon_core/plugins/load/push_to_library.py b/client/ayon_core/plugins/load/push_to_project.py similarity index 91% rename from client/ayon_core/plugins/load/push_to_library.py rename to client/ayon_core/plugins/load/push_to_project.py index 3c7c7e503d..dccac42444 100644 --- a/client/ayon_core/plugins/load/push_to_library.py +++ b/client/ayon_core/plugins/load/push_to_project.py @@ -6,8 +6,8 @@ from ayon_core.pipeline import load from ayon_core.pipeline.load import LoadError -class PushToLibraryProject(load.ProductLoaderPlugin): - """Export selected versions to folder structure from Template""" +class PushToProject(load.ProductLoaderPlugin): + """Export selected versions to different project""" is_multiple_contexts_compatible = True From bae1f64a91d8b4ec74bdb059048d42b96b4e346e Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 16:55:28 +0200 Subject: [PATCH 224/319] Fix typing --- client/ayon_core/tools/push_to_project/models/integrate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index c512d3ef68..89cd78cb0e 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -5,6 +5,7 @@ import itertools import sys import traceback import uuid +from typing import Optional import ayon_api from ayon_api.utils import create_entity_id From 12f415a639781b16c299e4b16edf128e9381e1a7 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 18 Aug 2025 17:01:42 +0200 Subject: [PATCH 225/319] Added tooltip --- client/ayon_core/tools/push_to_project/ui/window.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 3fb1822d92..b58904a31a 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -208,6 +208,10 @@ class PushToContextSelectWindow(QtWidgets.QWidget): show_detail_btn.setToolTip( "Show error detail dialog to copy full error." ) + original_names_checkbox.setToolTip( + "Required for multi copy, doesn't allow changes in folder or " + "variant values." + ) overlay_close_btn = QtWidgets.QPushButton( "Close", overlay_btns_widget From e5bf5d3070ea27d8b4f7755cf64f5d0967a500b3 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 20 Aug 2025 10:13:21 +0200 Subject: [PATCH 226/319] Split versions directly in main Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/main.py b/client/ayon_core/tools/push_to_project/main.py index 3a80dc2bb2..d3c9d3a537 100644 --- a/client/ayon_core/tools/push_to_project/main.py +++ b/client/ayon_core/tools/push_to_project/main.py @@ -25,7 +25,7 @@ def main(project, versions): versions (str): comma separated versions for same context """ - main_show(project, versions) + main_show(project, versions.split(",")) if __name__ == "__main__": From 26ab3671039ea6ea68198288a384d514058c6426 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 20 Aug 2025 10:13:43 +0200 Subject: [PATCH 227/319] Keep set_source Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/control.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index d02cd4dfc0..42f45ae500 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -39,6 +39,8 @@ class PushToContextController: self._process_item_id = None self._use_original_name = False + + self.set_source(project_name, version_ids) # Events system def emit_event(self, topic, data=None, source=None): From cd7b6212ccbf2fc48f2bfdbbeafd160d34e1d288 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 20 Aug 2025 10:13:59 +0200 Subject: [PATCH 228/319] Update docstrign Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 42f45ae500..c1c5a1bd37 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -58,7 +58,7 @@ class PushToContextController: Args: project_name (Union[str, None]): Source project name. - version_ids (Union[str, None]): Comma separated source version ids. + version_ids (Optional[list[str]]): Version ids. """ if not project_name or not version_ids: return From 015e7c11a500957392c0bb4e0c0adce9421a48fe Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 20 Aug 2025 10:14:17 +0200 Subject: [PATCH 229/319] Split done before Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index c1c5a1bd37..cbcfb75157 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -69,7 +69,7 @@ class PushToContextController: return self._src_project_name = project_name - self._src_version_ids = version_ids.split(",") + self._src_version_ids = version_ids self._src_label = None folder_entity = None task_entities = {} From 2bea321e9b34c2a48ce94e9912c1a4ecb38eeaad Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 20 Aug 2025 10:14:39 +0200 Subject: [PATCH 230/319] Update initializations Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/control.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index cbcfb75157..d28cb17c98 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -73,8 +73,8 @@ class PushToContextController: self._src_label = None folder_entity = None task_entities = {} - product_entities = None - version_entities = None + product_entities = [] + version_entities = [] if project_name and self._src_version_ids: version_entities = list(ayon_api.get_versions( project_name, version_ids=self._src_version_ids)) From 0574fa46b8f37d3f04823125e8c503617ad50695 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 20 Aug 2025 10:27:18 +0200 Subject: [PATCH 231/319] Fix formatting --- client/ayon_core/tools/push_to_project/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index d28cb17c98..9d5a1cb90c 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -39,7 +39,7 @@ class PushToContextController: self._process_item_id = None self._use_original_name = False - + self.set_source(project_name, version_ids) # Events system From e4305cc37a095511f89b87c791136b9c212a5168 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 20 Aug 2025 10:30:23 +0200 Subject: [PATCH 232/319] Removed product_entities Used only on 2 places --- .../tools/push_to_project/control.py | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 9d5a1cb90c..666a9a94a2 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -30,7 +30,6 @@ class PushToContextController: self._src_version_ids = [] self._src_folder_entity = None self._src_folder_task_entities = {} - self._src_product_entities = [] self._src_version_entities = [] self._src_label = None @@ -105,7 +104,6 @@ class PushToContextController: self._src_folder_entity = folder_entity self._src_folder_task_entities = task_entities - self._src_product_entities = product_entities self._src_version_entities = version_entities if folder_entity and len(list(version_entities)) == 1: self._user_values.set_new_folder_name(folder_entity["name"]) @@ -226,17 +224,13 @@ class PushToContextController: if not folder_entity: return "Source is invalid" - no_of_products = len(self._src_product_entities) - no_of_versions = len(self._src_version_entities) - if no_of_products != no_of_versions: - return (f"Not matching number of products {no_of_products} and " - f"versions {no_of_versions}") - folder_path = folder_entity["path"] src_labels = [] - for idx in range(0, no_of_versions): - product_entity = self._src_product_entities[idx] - version_entity = self._src_version_entities[idx] + for version_entity in self._src_version_entities: + product_entity = ayon_api.get_product_by_id( + self._src_project_name, + version_entity["productId"] + ) src_labels.append( "Source: {}{}/{}/v{:0>3}".format( self._src_project_name, @@ -289,9 +283,13 @@ class PushToContextController: task_name, task_type = self._get_task_info_from_repre_entities( task_entities, repre_entities ) + product_entity = ayon_api.get_product_by_id( + project_name, + version_entity["productId"] + ) project_settings = get_project_settings(project_name) - product_type = self._src_product_entities[0]["productType"] + product_type = product_entity["productType"] template = get_product_name_template( self._src_project_name, product_type, @@ -325,7 +323,7 @@ class PushToContextController: print("Failed format", exc) return "" - product_name = self._src_product_entities[0]["name"] + product_name = product_entity["name"] if ( (product_s and not product_name.startswith(product_s)) or (product_e and not product_name.endswith(product_e)) From cbc227ae2df9920339fc8a423c33f4eb69910ccc Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 20 Aug 2025 10:42:51 +0200 Subject: [PATCH 233/319] Parse variant and folder name even for multi push --- client/ayon_core/tools/push_to_project/control.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 666a9a94a2..c661c05d5d 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -105,7 +105,7 @@ class PushToContextController: self._src_folder_entity = folder_entity self._src_folder_task_entities = task_entities self._src_version_entities = version_entities - if folder_entity and len(list(version_entities)) == 1: + if folder_entity: self._user_values.set_new_folder_name(folder_entity["name"]) variant = self._get_src_variant() if variant: @@ -273,8 +273,8 @@ class PushToContextController: return None, None def _get_src_variant(self): - """Could be triggered only if single version is moved.""" project_name = self._src_project_name + # parse variant only from first version version_entity = self._src_version_entities[0] task_entities = self._src_folder_task_entities repre_entities = ayon_api.get_representations( From 1e9d6997731e7bf0ec72b9a855d93f316c763a04 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 20 Aug 2025 10:50:26 +0200 Subject: [PATCH 234/319] Allow folder create even if Use original name --- client/ayon_core/tools/push_to_project/ui/window.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index b58904a31a..d63b2582e4 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -209,7 +209,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): "Show error detail dialog to copy full error." ) original_names_checkbox.setToolTip( - "Required for multi copy, doesn't allow changes in folder or " + "Required for multi copy, doesn't allow changes " "variant values." ) @@ -420,9 +420,6 @@ class PushToContextSelectWindow(QtWidgets.QWidget): def _on_original_names_change(self, state: int) -> None: use_original_name = bool(state) - self._new_folder_name_enabled = not use_original_name - self._new_folder_checkbox.setEnabled(not use_original_name) - self._folder_name_input.setEnabled(not use_original_name) self._variant_input.setEnabled(not use_original_name) self._controller._use_original_name = use_original_name self.refresh() @@ -482,8 +479,6 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._header_label.setText(self._controller.get_source_label()) def _invalidate_new_folder_name(self, folder_name, is_valid): - if self._controller._use_original_name: - is_valid = True self._tasks_widget.setVisible(folder_name is None) if self._folder_is_valid is is_valid: return From 13e1cc71030323e6afb1040adcb172e6aae70ede Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 11:33:51 +0200 Subject: [PATCH 235/319] Fix project_name Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/plugins/load/push_to_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/load/push_to_project.py b/client/ayon_core/plugins/load/push_to_project.py index aff3efd6f6..6d641f2a57 100644 --- a/client/ayon_core/plugins/load/push_to_project.py +++ b/client/ayon_core/plugins/load/push_to_project.py @@ -34,7 +34,7 @@ class PushToProject(load.ProductLoaderPlugin): "push_to_project", "main.py" ) - project_name = tuple(filtered_contexts)[0]["project"]["name"] + project_name = filtered_contexts[0]["project"]["name"] version_ids = [] for context in filtered_contexts: From 60e6d4df2f3ba0d819cb867f05ed23efdecdd77c Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 11:34:19 +0200 Subject: [PATCH 236/319] Update logic for versions Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/plugins/load/push_to_project.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/plugins/load/push_to_project.py b/client/ayon_core/plugins/load/push_to_project.py index 6d641f2a57..d5dd8960a3 100644 --- a/client/ayon_core/plugins/load/push_to_project.py +++ b/client/ayon_core/plugins/load/push_to_project.py @@ -36,9 +36,10 @@ class PushToProject(load.ProductLoaderPlugin): ) project_name = filtered_contexts[0]["project"]["name"] - version_ids = [] - for context in filtered_contexts: - version_ids.append(context["version"]["id"]) + version_ids = { + context["version"]["id"] + for context in filtered_contexts + } args = get_ayon_launcher_args( push_tool_script_path, From bab05592bc242d7ca1f4a1913e19342b8af646f9 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 11:35:13 +0200 Subject: [PATCH 237/319] Update when even is emitted Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/control.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index c661c05d5d..6247fe14ce 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -363,10 +363,15 @@ class PushToContextController: ) def _submit_callback(self): - for process_item_id in self._process_item_ids: + process_item_ids = self._process_item_ids + for process_item_id in process_item_ids: self._integrate_model.integrate_item(process_item_id) + self._emit_event("submit.finished", {}) + if process_item_ids is self._process_item_ids: + self._process_item_ids = [] + def _emit_event(self, topic, data=None): if data is None: data = {} From 641d7879820c4b07f4be49ba5303582b19188d99 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 11:36:40 +0200 Subject: [PATCH 238/319] Reordered input fields validations --- client/ayon_core/tools/push_to_project/control.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 6247fe14ce..ea01165859 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -337,11 +337,6 @@ class PushToContextController: return product_name def _check_submit_validations(self): - if self._use_original_name: - return True - if not self._user_values.is_valid: - return False - if not self._selection_model.get_selected_project_name(): return False @@ -350,6 +345,13 @@ class PushToContextController: and not self._selection_model.get_selected_folder_id() ): return False + + if self._use_original_name: + return True + + if not self._user_values.is_valid: + return False + return True def _invalidate(self): From 0933e882e200f09cb194dc847df8e55247056c1c Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 13:45:21 +0200 Subject: [PATCH 239/319] Fix wrong repre["context"] content Contained only values used in resolving template. Missed project["name"] etc. --- .../tools/push_to_project/models/integrate.py | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index f9d524ba3a..c888adf733 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -1019,10 +1019,18 @@ class ProjectPushItemProcess: self, anatomy, template_name, formatting_data, file_template ): processed_repre_items = [] + repre_context = None for repre_item in self._src_repre_items: repre_entity = repre_item.repre_entity repre_name = repre_entity["name"] repre_format_data = copy.deepcopy(formatting_data) + + if not repre_context: + repre_context = self._update_repre_context( + repre_entity, + formatting_data + ) + repre_format_data["representation"] = repre_name for src_file in repre_item.src_files: ext = os.path.splitext(src_file.path)[-1] @@ -1038,7 +1046,6 @@ class ProjectPushItemProcess: "publish", template_name, "directory" ) folder_path = template_obj.format_strict(formatting_data) - repre_context = folder_path.used_values folder_path_rootless = folder_path.rootless repre_filepaths = [] published_path = None @@ -1061,7 +1068,6 @@ class ProjectPushItemProcess: ) if published_path is None or frame == repre_item.frame: published_path = dst_filepath - repre_context.update(filename.used_values) repre_filepaths.append((dst_filepath, dst_rootless_path)) self._file_transaction.add(src_file.path, dst_filepath) @@ -1178,6 +1184,28 @@ class ProjectPushItemProcess: path ) + def _update_repre_context(self, repre_entity, formatting_data): + """Replace old context value with new ones. + + Folder might change, project definitely changes etc. + """ + repre_context = repre_entity["context"] + for context_key, context_value in repre_context.items(): + if context_value and isinstance(context_value, dict): + for context_sub_key in context_value.keys(): + value_to_update = formatting_data.get(context_key, {}).get( + context_sub_key) + if value_to_update: + repre_context[context_key][ + context_sub_key] = value_to_update + else: + value_to_update = formatting_data.get(context_key) + if value_to_update: + repre_context[context_key] = value_to_update + if "task" not in formatting_data: + repre_context.pop("task") + return repre_context + class IntegrateModel: def __init__(self, controller): From b032d26ec6d417c0d31bfe74c6cb65bc60b50f21 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 13:57:16 +0200 Subject: [PATCH 240/319] Formatting change --- client/ayon_core/tools/push_to_project/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index ea01165859..58d06dd19d 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -368,7 +368,7 @@ class PushToContextController: process_item_ids = self._process_item_ids for process_item_id in process_item_ids: self._integrate_model.integrate_item(process_item_id) - + self._emit_event("submit.finished", {}) if process_item_ids is self._process_item_ids: From 3f941a1dff82cce941a7c1f4ef6523441daf43d1 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 15:08:09 +0200 Subject: [PATCH 241/319] Fix where to pull process_item_ids --- client/ayon_core/tools/push_to_project/ui/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index d63b2582e4..4d947103be 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -529,7 +529,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): failed_pushes = [] fail_tracebacks = [] - for process_item_id in self._process_item_ids: + for process_item_id in self._controller._process_item_ids: process_status = self._controller.get_process_item_status( process_item_id ) From c7d0f2b9871c59f334ce062d57c0d73af0256675 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 15:08:44 +0200 Subject: [PATCH 242/319] Add more logging to exception handling --- client/ayon_core/tools/push_to_project/models/integrate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index c888adf733..054a5f1b18 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -497,8 +497,11 @@ class ProjectPushItemProcess: except Exception as exc: _exc, _value, _tb = sys.exc_info() + product_name = self._src_product_entity["name"] self._status.set_failed( - "Unhandled error happened: {}".format(str(exc)), + "Unhandled error happened for `{}`: {}".format( + product_name, str(exc) + ), (_exc, _value, _tb) ) From de281f34c39e93cb1a5c0948470c17f6e92ffb79 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 15:09:01 +0200 Subject: [PATCH 243/319] Remove unnecessary _process_item_ids --- client/ayon_core/tools/push_to_project/ui/window.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 4d947103be..f5ee5f247c 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -335,7 +335,6 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._main_thread_timer = main_thread_timer self._main_thread_timer_can_stop = True self._last_submit_message = None - self._process_item_ids = [] self._variant_is_valid = None self._folder_is_valid = None From cb4df370670edfe7e6a56ed39c4d24afac134867 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 16:15:07 +0200 Subject: [PATCH 244/319] Use property instead private variable --- .../tools/push_to_project/models/integrate.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 054a5f1b18..dadae7e1f9 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -317,7 +317,7 @@ class ProjectPushRepreItem: if self._src_files is not None: return self._src_files, self._resource_files - repre_context = self._repre_entity["context"] + repre_context = self.repre_entity["context"] if "frame" in repre_context or "udim" in repre_context: src_files, resource_files = self._get_source_files_with_frames() else: @@ -334,7 +334,7 @@ class ProjectPushRepreItem: udim_placeholder = "__udim__" src_files = [] resource_files = [] - template = self._repre_entity["attrib"]["template"] + template = self.repre_entity["attrib"]["template"] # Remove padding from 'udim' and 'frame' formatting keys # - "{frame:0>4}" -> "{frame}" for key in ("udim", "frame"): @@ -342,7 +342,7 @@ class ProjectPushRepreItem: replacement = "{{{}}}".format(key) template = re.sub(sub_part, replacement, template) - repre_context = self._repre_entity["context"] + repre_context = self.repre_entity["context"] fill_repre_context = copy.deepcopy(repre_context) if "frame" in fill_repre_context: fill_repre_context["frame"] = frame_placeholder @@ -363,7 +363,7 @@ class ProjectPushRepreItem: .replace(udim_placeholder, "(?P[0-9]+)") ) src_basename_regex = re.compile("^{}$".format(src_basename)) - for file_info in self._repre_entity["files"]: + for file_info in self.repre_entity["files"]: filepath_template = self._clean_path(file_info["path"]) filepath = self._clean_path( filepath_template.format(root=self._roots) @@ -394,8 +394,8 @@ class ProjectPushRepreItem: def _get_source_files(self): src_files = [] resource_files = [] - template = self._repre_entity["attrib"]["template"] - repre_context = self._repre_entity["context"] + template = self.repre_entity["attrib"]["template"] + repre_context = self.repre_entity["context"] fill_repre_context = copy.deepcopy(repre_context) fill_roots = fill_repre_context["root"] for root_name in tuple(fill_roots.keys()): @@ -404,7 +404,7 @@ class ProjectPushRepreItem: fill_repre_context) repre_path = self._clean_path(repre_path) src_dirpath = os.path.dirname(repre_path) - for file_info in self._repre_entity["files"]: + for file_info in self.repre_entity["files"]: filepath_template = self._clean_path(file_info["path"]) filepath = self._clean_path( filepath_template.format(root=self._roots)) From 4229950f361718ffc81748290f96037377e98c75 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 17:16:30 +0200 Subject: [PATCH 245/319] Do not overwrite source entity context --- client/ayon_core/tools/push_to_project/models/integrate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index dadae7e1f9..f9de351632 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -1030,7 +1030,7 @@ class ProjectPushItemProcess: if not repre_context: repre_context = self._update_repre_context( - repre_entity, + copy.deepcopy(repre_entity), formatting_data ) From 2bd5418caeb7a753f155b588891b4a9f16d9c883 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 17:56:13 +0200 Subject: [PATCH 246/319] Simplified querying status of ProjectPushItemProcess Makes error logging more stable, limits hard fails in debugger. --- .../tools/push_to_project/control.py | 7 +++++-- .../tools/push_to_project/models/integrate.py | 19 ++++--------------- .../tools/push_to_project/ui/window.py | 6 ++---- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 58d06dd19d..466dfcc994 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -1,4 +1,5 @@ import threading +from typing import Dict import ayon_api @@ -13,6 +14,7 @@ from .models import ( UserPublishValuesModel, IntegrateModel, ) +from .models.integrate import ProjectPushItemProcess class PushToContextController: @@ -171,8 +173,9 @@ class PushToContextController: def set_selected_task(self, task_id, task_name): self._selection_model.set_selected_task(task_id, task_name) - def get_process_item_status(self, item_id): - return self._integrate_model.get_item_status(item_id) + def get_process_items(self) -> Dict[str, ProjectPushItemProcess]: + """Returns dict of all ProjectPushItemProcess items """ + return self._integrate_model.get_items() # Processing methods def submit(self, wait=True): diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index f9de351632..ed5c5b31ab 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -5,7 +5,7 @@ import itertools import sys import traceback import uuid -from typing import Optional +from typing import Optional, Dict import ayon_api from ayon_api.utils import create_entity_id @@ -1281,17 +1281,6 @@ class IntegrateModel: return item.integrate() - def get_item_status(self, item_id): - """Status of an item. - - Args: - item_id (str): Item id for which status should be returned. - - Returns: - dict[str, Any]: Status data. - """ - - item = self._process_items.get(item_id) - if item is not None: - return item.get_status_data() - return None + def get_items(self) -> Dict[str, ProjectPushItemProcess]: + """Returns dict of all ProjectPushItemProcess items """ + return self._process_items diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index f5ee5f247c..d01da4cb3f 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -528,10 +528,8 @@ class PushToContextSelectWindow(QtWidgets.QWidget): failed_pushes = [] fail_tracebacks = [] - for process_item_id in self._controller._process_item_ids: - process_status = self._controller.get_process_item_status( - process_item_id - ) + for process_item in self._controller.get_process_items().values(): + process_status = process_item.get_status_data() if process_status["failed"]: failed_pushes.append(process_status) # push_failed = process_status["failed"] From dc987ed64f5cdbc0edb1d0985661905cbfdb6bb1 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 18:00:42 +0200 Subject: [PATCH 247/319] Ruff --- client/ayon_core/tools/push_to_project/models/integrate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index ed5c5b31ab..ef49838152 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -847,8 +847,8 @@ class ProjectPushItemProcess: except TaskNotSetError: self._status.set_failed( "Target product name template requires task name. To " - "continue you have to select target task or change settings " - " ayon+settings://core/tools/creator/product_name_profiles" + "continue you have to select target task or change settings " # noqa: E501 + " ayon+settings://core/tools/creator/product_name_profiles" # noqa: E501 f"?project={self._item.dst_project_name}." ) raise PushToProjectError(self._status.fail_reason) From 651fc3f068a5ce0dfc9a976c47ae36a2120286fa Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 21 Aug 2025 18:07:19 +0200 Subject: [PATCH 248/319] Add validation for only single folder products selection --- client/ayon_core/plugins/load/push_to_project.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/ayon_core/plugins/load/push_to_project.py b/client/ayon_core/plugins/load/push_to_project.py index d5dd8960a3..33f9a68b23 100644 --- a/client/ayon_core/plugins/load/push_to_project.py +++ b/client/ayon_core/plugins/load/push_to_project.py @@ -28,6 +28,10 @@ class PushToProject(load.ProductLoaderPlugin): if not filtered_contexts: raise LoadError("Nothing to push for your selection") + folder_ids = [context["folder"]["id"] for context in filtered_contexts] + if len(folder_ids) > 1: + raise LoadError("Please select products from single folder") + push_tool_script_path = os.path.join( AYON_CORE_ROOT, "tools", From 5740b9f495f3c81f7eb405e83d81e804493a19c5 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 22 Aug 2025 16:04:27 +0800 Subject: [PATCH 249/319] update publishDir as being part of the instance_data --- .../plugins/load/create_hero_version.py | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/plugins/load/create_hero_version.py b/client/ayon_core/plugins/load/create_hero_version.py index d741dafcce..2d55069abf 100644 --- a/client/ayon_core/plugins/load/create_hero_version.py +++ b/client/ayon_core/plugins/load/create_hero_version.py @@ -75,7 +75,8 @@ class CreateHeroVersion(load.ProductLoaderPlugin): version = context.get("version") folder = context.get("folder") task_entity = ayon_api.get_task_by_id( - task_id=version.get("taskId"), project_name=project["name"]) + task_id=version.get("taskId"), project_name=project["name"] + ) anatomy = Anatomy(project["name"]) @@ -95,6 +96,7 @@ class CreateHeroVersion(load.ProductLoaderPlugin): "name": product["name"], "type": product["productType"], } + anatomy_data["version"] = version["version"] published_representations = {} for repre in repres: repre_anatomy = copy.deepcopy(anatomy_data) @@ -105,12 +107,26 @@ class CreateHeroVersion(load.ProductLoaderPlugin): "published_files": [f["path"] for f in repre.get("files", [])], "anatomy_data": repre_anatomy } - + publish_template_key = get_publish_template_name( + project_name, + context.get("hostName"), + product["productType"], + task_name=anatomy_data.get("task", {}).get("name"), + task_type=anatomy_data.get("task", {}).get("type"), + project_settings=context.get("project_settings", {}), + logger=self.log + ) + published_template_obj = anatomy.get_template_item( + "publish", publish_template_key, "directory" + ) + published_dir = os.path.normpath( + published_template_obj.format_strict(anatomy_data) + ) instance_data = { "productName": product["name"], "productType": product["productType"], "anatomyData": anatomy_data, - "publishDir": "", # TODO: Set to actual publish directory + "publishDir": published_dir, "published_representations": published_representations, "versionEntity": version, } @@ -199,7 +215,12 @@ class CreateHeroVersion(load.ProductLoaderPlugin): if file_path not in all_repre_file_paths: all_repre_file_paths.append(file_path) - instance_publish_dir = os.path.normpath(instance_data["publishDir"]) + publish_dir = instance_data.get("publishDir", "") + if not publish_dir: + raise RuntimeError( + "publishDir is empty in instance_data, cannot continue." + ) + instance_publish_dir = os.path.normpath(publish_dir) other_file_paths_mapping = [] for file_path in all_copied_files: if not file_path.startswith(instance_publish_dir): @@ -331,7 +352,7 @@ class CreateHeroVersion(load.ProductLoaderPlugin): else: collections, remainders = clique.assemble(published_files) if remainders or not collections or len(collections) > 1: - raise Exception( + raise RuntimeError( ( "Integrity error. Files of published " "representation is combination of frame " From 22e18cdfa253c7c4c53751bff2928e11206101fa Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 22 Aug 2025 16:07:02 +0800 Subject: [PATCH 250/319] add comment --- client/ayon_core/plugins/load/create_hero_version.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/plugins/load/create_hero_version.py b/client/ayon_core/plugins/load/create_hero_version.py index 2d55069abf..e9dbbfa652 100644 --- a/client/ayon_core/plugins/load/create_hero_version.py +++ b/client/ayon_core/plugins/load/create_hero_version.py @@ -107,6 +107,7 @@ class CreateHeroVersion(load.ProductLoaderPlugin): "published_files": [f["path"] for f in repre.get("files", [])], "anatomy_data": repre_anatomy } + # get the publish directory publish_template_key = get_publish_template_name( project_name, context.get("hostName"), From 89d0777bafcda1da9a7355a00da619cf8c326870 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 22 Aug 2025 16:21:37 +0800 Subject: [PATCH 251/319] copilot's feedback on - backup directory loop --- .../plugins/load/create_hero_version.py | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/client/ayon_core/plugins/load/create_hero_version.py b/client/ayon_core/plugins/load/create_hero_version.py index e9dbbfa652..adf9d5f669 100644 --- a/client/ayon_core/plugins/load/create_hero_version.py +++ b/client/ayon_core/plugins/load/create_hero_version.py @@ -167,13 +167,13 @@ class CreateHeroVersion(load.ProductLoaderPlugin): raise RuntimeError("Project anatomy does not have hero " f"template key: {template_key}") - print(f"Hero template: {hero_template.template}") + self.log.info(f"Hero template: {hero_template.template}") hero_publish_dir = self.get_publish_dir( instance_data, anatomy, template_key ) - print(f"Hero publish dir: {hero_publish_dir}") + self.log.info(f"Hero publish dir: {hero_publish_dir}") src_version_entity = instance_data.get("versionEntity") filtered_repre_ids = [] @@ -280,28 +280,22 @@ class CreateHeroVersion(load.ProductLoaderPlugin): backup_hero_publish_dir = None if os.path.exists(hero_publish_dir): - backup_hero_publish_dir = hero_publish_dir + ".BACKUP" + base_backup_dir = hero_publish_dir + ".BACKUP" max_idx = 10 - idx = 0 - _backup_hero_publish_dir = backup_hero_publish_dir - while os.path.exists(_backup_hero_publish_dir): - try: - shutil.rmtree(_backup_hero_publish_dir) - backup_hero_publish_dir = _backup_hero_publish_dir + # Find the first available backup directory name + for idx in range(max_idx + 1): + if idx == 0: + candidate_backup_dir = base_backup_dir + else: + candidate_backup_dir = f"{base_backup_dir}{idx}" + if not os.path.exists(candidate_backup_dir): + backup_hero_publish_dir = candidate_backup_dir break - except Exception as exc: - _backup_hero_publish_dir = ( - backup_hero_publish_dir + str(idx) - ) - if not os.path.exists(_backup_hero_publish_dir): - backup_hero_publish_dir = _backup_hero_publish_dir - break - if idx > max_idx: - raise AssertionError( - "Backup folders are fully occupied to max index " - f"{max_idx}" - ) from exc - idx += 1 + else: + raise AssertionError( + f"Backup folders are fully occupied to max index {max_idx}" + ) + try: os.rename(hero_publish_dir, backup_hero_publish_dir) except PermissionError: @@ -346,7 +340,7 @@ class CreateHeroVersion(load.ProductLoaderPlugin): src_to_dst_file_paths.append( (mapped_published_file, template_filled) ) - print( + self.log.info( f"Single published file: {mapped_published_file} -> " f"{template_filled}" ) @@ -379,7 +373,7 @@ class CreateHeroVersion(load.ProductLoaderPlugin): ) src_to_dst_file_paths.append((src_file, dst_file)) dst_paths.append(dst_file) - print( + self.log.info( f"Collection published file: {src_file} " f"-> {dst_file}" ) From 8d6f83ffa704fbc4d6bb4a73e6e065a631d3802d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:30:48 +0200 Subject: [PATCH 252/319] restore saved painter --- client/ayon_core/tools/sceneinventory/select_version_dialog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/tools/sceneinventory/select_version_dialog.py b/client/ayon_core/tools/sceneinventory/select_version_dialog.py index 68284ad1fe..18a39e495c 100644 --- a/client/ayon_core/tools/sceneinventory/select_version_dialog.py +++ b/client/ayon_core/tools/sceneinventory/select_version_dialog.py @@ -127,6 +127,7 @@ class SelectVersionComboBox(QtWidgets.QComboBox): status_text_rect.setLeft(icon_rect.right() + 2) if status_text_rect.width() <= 0: + painter.restore() return if status_text_rect.width() < metrics.width(status_name): @@ -144,6 +145,7 @@ class SelectVersionComboBox(QtWidgets.QComboBox): QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter, status_name ) + painter.restore() def set_current_index(self, index): model = self._combo_view.model() From 16828011d22c633f0a2c9473c1f9ca2029397829 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 22 Aug 2025 13:40:26 +0200 Subject: [PATCH 253/319] Fix wrong check on folders --- client/ayon_core/plugins/load/push_to_project.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/load/push_to_project.py b/client/ayon_core/plugins/load/push_to_project.py index 33f9a68b23..0b218d6ea1 100644 --- a/client/ayon_core/plugins/load/push_to_project.py +++ b/client/ayon_core/plugins/load/push_to_project.py @@ -28,7 +28,10 @@ class PushToProject(load.ProductLoaderPlugin): if not filtered_contexts: raise LoadError("Nothing to push for your selection") - folder_ids = [context["folder"]["id"] for context in filtered_contexts] + folder_ids = set( + context["folder"]["id"] + for context in filtered_contexts + ) if len(folder_ids) > 1: raise LoadError("Please select products from single folder") From 941d4aee9ea66b758bd337560fb48b6e38a1b1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 26 Aug 2025 15:13:52 +0200 Subject: [PATCH 254/319] :recycle: add docstrings and hints --- .../plugins/load/create_hero_version.py | 165 +++++++++++++++--- 1 file changed, 139 insertions(+), 26 deletions(-) diff --git a/client/ayon_core/plugins/load/create_hero_version.py b/client/ayon_core/plugins/load/create_hero_version.py index adf9d5f669..aef0cf8863 100644 --- a/client/ayon_core/plugins/load/create_hero_version.py +++ b/client/ayon_core/plugins/load/create_hero_version.py @@ -1,10 +1,12 @@ - +"""Plugin to create hero version from selected context.""" +from __future__ import annotations import os import copy import shutil import errno import itertools from concurrent.futures import ThreadPoolExecutor +from typing import Any, Optional from speedcopy import copyfile import clique @@ -20,7 +22,17 @@ from ayon_core.pipeline.publish import get_publish_template_name from ayon_core.pipeline.template_data import get_template_data -def prepare_changes(old_entity, new_entity): +def prepare_changes(old_entity: dict, new_entity: dict) -> dict: + """Prepare changes dict for update entity operation. + + Args: + old_entity (dict): Existing entity data from database. + new_entity (dict): New entity data to compare against old. + + Returns: + dict: Changes to apply to old entity to make it like new entity. + + """ changes = {} for key in set(new_entity.keys()): if key == "attrib": @@ -48,19 +60,21 @@ class CreateHeroVersion(load.ProductLoaderPlugin): icon = "star" color = "#ffd700" - ignored_representation_names = [] + ignored_representation_names: list[str] = [] db_representation_context_keys = [ "project", "folder", "asset", "hierarchy", "task", "product", "subset", "family", "representation", "username", "user", "output" ] use_hardlinks = False - def message(self, text): + @staticmethod + def message(text: str) -> None: + """Show message box with text.""" msgBox = QtWidgets.QMessageBox() msgBox.setText(text) msgBox.setStyleSheet(style.load_stylesheet()) msgBox.setWindowFlags( - msgBox.windowFlags() | QtCore.Qt.FramelessWindowHint + msgBox.windowFlags() | QtCore.Qt.WindowType.FramelessWindowHint ) msgBox.exec_() @@ -143,8 +157,31 @@ class CreateHeroVersion(load.ProductLoaderPlugin): self.message( f"Failed to create hero version:\n{chr(10).join(errors)}") - def create_hero_version(self, instance_data, anatomy, context): - """Create hero version from instance data.""" + def create_hero_version( + self, + instance_data: dict[str, Any], + anatomy: Anatomy, + context: dict[str, Any]) -> None: + """Create hero version from instance data. + + Args: + instance_data (dict): Instance data with keys: + - productName (str): Name of the product. + - productType (str): Type of the product. + - anatomyData (dict): Anatomy data for templates. + - publishDir (str): Directory where the product is published. + - published_representations (dict): Published representations. + - versionEntity (dict, optional): Source version entity. + anatomy (Anatomy): Anatomy object for the project. + context (dict): Context data with keys: + - hostName (str): Name of the host application. + - project_settings (dict): Project settings. + + Raises: + RuntimeError: If any required data is missing or an error occurs + during the hero version creation process. + + """ published_repres = instance_data.get("published_representations") if not published_repres: raise RuntimeError("No published representations found.") @@ -158,7 +195,6 @@ class CreateHeroVersion(load.ProductLoaderPlugin): instance_data.get("anatomyData", {}).get("task", {}).get("type"), project_settings=context.get("project_settings", {}), hero=True, - logger=None ) hero_template = anatomy.get_template_item( "hero", template_key, "path", default=None @@ -197,12 +233,12 @@ class CreateHeroVersion(load.ProductLoaderPlugin): raise RuntimeError("Version 0 cannot have hero version.") all_copied_files = [] - transfers = instance_data.get("transfers", list()) + transfers = instance_data.get("transfers", []) for _src, dst in transfers: dst = os.path.normpath(dst) if dst not in all_copied_files: all_copied_files.append(dst) - hardlinks = instance_data.get("hardlinks", list()) + hardlinks = instance_data.get("hardlinks", []) for _src, dst in hardlinks: dst = os.path.normpath(dst) if dst not in all_copied_files: @@ -267,7 +303,6 @@ class CreateHeroVersion(load.ProductLoaderPlugin): instance_data["heroVersionEntity"] = new_hero_version old_repres_to_replace = {} - old_repres_to_delete = {} for repre_info in published_repres.values(): repre = repre_info["representation"] repre_name_low = repre["name"].lower() @@ -275,12 +310,10 @@ class CreateHeroVersion(load.ProductLoaderPlugin): old_repres_to_replace[repre_name_low] = ( old_repres_by_name.pop(repre_name_low) ) - if old_repres_by_name: - old_repres_to_delete = old_repres_by_name - + old_repres_to_delete = old_repres_by_name or {} backup_hero_publish_dir = None if os.path.exists(hero_publish_dir): - base_backup_dir = hero_publish_dir + ".BACKUP" + base_backup_dir = f"{hero_publish_dir}.BACKUP" max_idx = 10 # Find the first available backup directory name for idx in range(max_idx + 1): @@ -298,10 +331,11 @@ class CreateHeroVersion(load.ProductLoaderPlugin): try: os.rename(hero_publish_dir, backup_hero_publish_dir) - except PermissionError: + except PermissionError as e: raise AssertionError( "Could not create hero version because it is " - "not possible to replace current hero files.") + "not possible to replace current hero files." + ) from e try: src_to_dst_file_paths = [] @@ -445,14 +479,41 @@ class CreateHeroVersion(load.ProductLoaderPlugin): os.rename(backup_hero_publish_dir, hero_publish_dir) raise - def get_files_info(self, filepaths, anatomy): + def get_files_info( + self, filepaths: list[str], anatomy: Anatomy) -> list[dict]: + """Get list of file info dictionaries for given file paths. + + Args: + filepaths (list[str]): List of absolute file paths. + anatomy (Anatomy): Anatomy object for the project. + + Returns: + list[dict]: List of file info dictionaries. + + """ file_infos = [] for filepath in filepaths: file_info = self.prepare_file_info(filepath, anatomy) file_infos.append(file_info) return file_infos - def prepare_file_info(self, path, anatomy): + def prepare_file_info(self, path: str, anatomy: Anatomy) -> dict: + """Prepare file info dictionary for given path. + + Args: + path (str): Absolute file path. + anatomy (Anatomy): Anatomy object for the project. + + Returns: + dict: File info dictionary with keys: + - id (str): Unique identifier for the file. + - name (str): Base name of the file. + - path (str): Rootless file path. + - size (int): Size of the file in bytes. + - hash (str): Hash of the file content. + - hash_type (str): Type of the hash used. + + """ return { "id": create_entity_id(), "name": os.path.basename(path), @@ -462,7 +523,22 @@ class CreateHeroVersion(load.ProductLoaderPlugin): "hash_type": "op3", } - def get_publish_dir(self, instance_data, anatomy, template_key): + @staticmethod + def get_publish_dir( + instance_data: dict, + anatomy: Anatomy, + template_key: str) -> str: + """Get publish directory from instance data and anatomy. + + Args: + instance_data (dict): Instance data with "anatomyData" key. + anatomy (Anatomy): Anatomy object for the project. + template_key (str): Template key for the hero template. + + Returns: + str: Normalized publish directory path. + + """ template_data = copy.deepcopy(instance_data.get("anatomyData", {})) if "originalBasename" in instance_data: template_data["originalBasename"] = ( @@ -473,13 +549,34 @@ class CreateHeroVersion(load.ProductLoaderPlugin): ) return os.path.normpath(template_obj.format_strict(template_data)) - def get_rootless_path(self, anatomy, path): + @staticmethod + def get_rootless_path(anatomy: Anatomy, path: str) -> str: + """Get rootless path from absolute path. + + Args: + anatomy (Anatomy): Anatomy object for the project. + path (str): Absolute file path. + + Returns: + str: Rootless file path if root found, else original path. + + """ success, rootless_path = anatomy.find_root_template_from_path(path) if success: path = rootless_path return path - def copy_file(self, src_path, dst_path): + def copy_file(self, src_path: str, dst_path: str) -> None: + """Copy file from src to dst with creating directories. + + Args: + src_path (str): Source file path. + dst_path (str): Destination file path. + + Raises: + OSError: If copying or linking fails. + + """ dirname = os.path.dirname(dst_path) try: os.makedirs(dirname) @@ -495,23 +592,39 @@ class CreateHeroVersion(load.ProductLoaderPlugin): raise copyfile(src_path, dst_path) - def version_from_representations(self, project_name, repres): + @staticmethod + def version_from_representations( + project_name: str, repres: dict) -> Optional[dict[str, Any]]: + """Find version from representations. + + Args: + project_name (str): Name of the project. + repres (dict): Dictionary of representations info. + + Returns: + Optional[dict]: Version entity if found, else None. + + """ for repre_info in repres.values(): version = ayon_api.get_version_by_id( project_name, repre_info["representation"]["versionId"] ) if version: return version + return None - def current_hero_ents(self, project_name, version): + @staticmethod + def current_hero_ents( + project_name: str, + version: dict[str, Any]) -> tuple[Any, list[dict[str, Any]]]: hero_version = ayon_api.get_hero_version_by_product_id( project_name, version["productId"] ) if not hero_version: - return (None, []) + return None, [] hero_repres = list( ayon_api.get_representations( project_name, version_ids={hero_version["id"]} ) ) - return (hero_version, hero_repres) + return hero_version, hero_repres From 22d6819a322ed126ccde1a3f410bd080ba47e718 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 28 Aug 2025 10:51:39 +0200 Subject: [PATCH 255/319] Updated docstring --- client/ayon_core/tools/push_to_project/control.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 466dfcc994..ad7cc58c5c 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -57,6 +57,9 @@ class PushToContextController: def set_source(self, project_name, version_ids): """Set source project and version. + There is currently assumption that tool is working on products of same + folder. + Args: project_name (Union[str, None]): Source project name. version_ids (Optional[list[str]]): Version ids. From 763c650a9f133623a6e4d1d768ecad9bb99896b3 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 28 Aug 2025 11:03:13 +0200 Subject: [PATCH 256/319] Cache product entities --- client/ayon_core/tools/push_to_project/control.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index ad7cc58c5c..2f712337a4 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -33,6 +33,7 @@ class PushToContextController: self._src_folder_entity = None self._src_folder_task_entities = {} self._src_version_entities = [] + self._src_product_entities = {} self._src_label = None self._submission_enabled = False @@ -110,6 +111,10 @@ class PushToContextController: self._src_folder_entity = folder_entity self._src_folder_task_entities = task_entities self._src_version_entities = version_entities + self._src_product_entities = { + product["id"]: product + for product in product_entities + } if folder_entity: self._user_values.set_new_folder_name(folder_entity["name"]) variant = self._get_src_variant() @@ -233,8 +238,7 @@ class PushToContextController: folder_path = folder_entity["path"] src_labels = [] for version_entity in self._src_version_entities: - product_entity = ayon_api.get_product_by_id( - self._src_project_name, + product_entity = self._src_product_entities.get( version_entity["productId"] ) src_labels.append( @@ -289,8 +293,7 @@ class PushToContextController: task_name, task_type = self._get_task_info_from_repre_entities( task_entities, repre_entities ) - product_entity = ayon_api.get_product_by_id( - project_name, + product_entity = self._src_product_entities.get( version_entity["productId"] ) From f6efb6c80dcf86bd2c61f3d3137404099d49b6a1 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 29 Aug 2025 14:08:16 +0200 Subject: [PATCH 257/319] Expose check for original names requirement --- client/ayon_core/tools/push_to_project/control.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 2f712337a4..b4e0d56dfd 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -158,6 +158,14 @@ class PushToContextController: def get_user_values(self): return self._user_values.get_data() + def original_names_required(self): + """Checks if original product names must be used. + + Currently simple check if multiple versions, but if multiple products + with different product_type were used, it wouldn't be necessary. + """ + return len(self._src_version_entities) > 1 + def set_user_value_folder_name(self, folder_name): self._user_values.set_new_folder_name(folder_name) self._invalidate() From 47be2d41c5cd06bd6c2d0e077a1334d08559f165 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 29 Aug 2025 14:09:44 +0200 Subject: [PATCH 258/319] Exposed _use_original_names_checkbox --- client/ayon_core/tools/push_to_project/ui/window.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index d01da4cb3f..99b4d6ecb3 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -307,6 +307,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._new_folder_checkbox = new_folder_checkbox self._folder_name_input = folder_name_input self._comment_input = comment_input + self._use_original_names_checkbox = original_names_checkbox self._publish_btn = publish_btn From 779fa33be21f65966d708421a9b41f5c9cb77a1c Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 29 Aug 2025 14:10:44 +0200 Subject: [PATCH 259/319] Added function to decide state of _use_original_names_checkbox --- .../ayon_core/tools/push_to_project/ui/window.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 99b4d6ecb3..3867e98b3b 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -368,6 +368,8 @@ class PushToContextSelectWindow(QtWidgets.QWidget): user_values = self._controller.get_user_values() new_folder_name = user_values["new_folder_name"] variant = user_values["variant"] + self._invalidate_use_original_names( + self._use_original_names_checkbox.isChecked()) self._folder_name_input.setText(new_folder_name or "") self._variant_input.setText(variant or "") self._invalidate_variant(user_values["is_variant_valid"]) @@ -420,9 +422,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): def _on_original_names_change(self, state: int) -> None: use_original_name = bool(state) - self._variant_input.setEnabled(not use_original_name) - self._controller._use_original_name = use_original_name - self.refresh() + self._invalidate_use_original_names(use_original_name) def _on_user_input_timer(self): folder_name_enabled = self._new_folder_name_enabled @@ -499,6 +499,16 @@ class PushToContextSelectWindow(QtWidgets.QWidget): state = "valid" if is_valid else "invalid" set_style_property(self._variant_input, "state", state) + def _invalidate_use_original_names(self, use_original_names): + variant_used = True + if self._controller.original_names_required(): + variant_used = False + use_original_names = True + + self._controller._use_original_name = use_original_names + self._use_original_names_checkbox.setChecked(use_original_names) + self._variant_input.setEnabled(variant_used) + def _on_submission_change(self, event): self._publish_btn.setEnabled(event["enabled"]) From f4f94e75e8c90b2dc72562d491b507f102080528 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 29 Aug 2025 14:21:32 +0200 Subject: [PATCH 260/319] Simplified variant invalidation --- .../tools/push_to_project/ui/window.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 3867e98b3b..ed38f24469 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -368,11 +368,11 @@ class PushToContextSelectWindow(QtWidgets.QWidget): user_values = self._controller.get_user_values() new_folder_name = user_values["new_folder_name"] variant = user_values["variant"] - self._invalidate_use_original_names( - self._use_original_names_checkbox.isChecked()) self._folder_name_input.setText(new_folder_name or "") self._variant_input.setText(variant or "") self._invalidate_variant(user_values["is_variant_valid"]) + self._invalidate_use_original_names( + self._use_original_names_checkbox.isChecked()) self._invalidate_new_folder_name( new_folder_name, user_values["is_new_folder_name_valid"] ) @@ -486,28 +486,27 @@ class PushToContextSelectWindow(QtWidgets.QWidget): state = "" if folder_name is not None: state = "valid" if is_valid else "invalid" - set_style_property( - self._folder_name_input, "state", state - ) + set_style_property(self._folder_name_input, "state", state) def _invalidate_variant(self, is_valid): - if self._controller._use_original_name: - is_valid = True - if self._variant_is_valid is is_valid: - return self._variant_is_valid = is_valid state = "valid" if is_valid else "invalid" set_style_property(self._variant_input, "state", state) def _invalidate_use_original_names(self, use_original_names): - variant_used = True + """Checks if original names must be used. + + Invalidates Variant if necessary + """ if self._controller.original_names_required(): - variant_used = False use_original_names = True + if use_original_names: + self._variant_input.setEnabled(not use_original_names) + self._invalidate_variant(not use_original_names) + self._controller._use_original_name = use_original_names self._use_original_names_checkbox.setChecked(use_original_names) - self._variant_input.setEnabled(variant_used) def _on_submission_change(self, event): self._publish_btn.setEnabled(event["enabled"]) From 12618488055958ff0e04c267d02dc16b42eda42e Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 29 Aug 2025 14:56:25 +0200 Subject: [PATCH 261/319] Fix resetting invalid variant --- client/ayon_core/tools/push_to_project/ui/window.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index ed38f24469..f382ccce64 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -501,9 +501,8 @@ class PushToContextSelectWindow(QtWidgets.QWidget): if self._controller.original_names_required(): use_original_names = True - if use_original_names: - self._variant_input.setEnabled(not use_original_names) - self._invalidate_variant(not use_original_names) + self._variant_input.setEnabled(not use_original_names) + self._invalidate_variant(not use_original_names) self._controller._use_original_name = use_original_names self._use_original_names_checkbox.setChecked(use_original_names) From a6a32b49fc176cb5039d47980c0252073f800350 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 2 Sep 2025 11:36:36 +0200 Subject: [PATCH 262/319] update opentimelineio to 0.17.0 --- client/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pyproject.toml b/client/pyproject.toml index 6416d9b8e1..bccc0b9872 100644 --- a/client/pyproject.toml +++ b/client/pyproject.toml @@ -15,7 +15,7 @@ qtawesome = "0.7.3" [ayon.runtimeDependencies] aiohttp-middlewares = "^2.0.0" Click = "^8" -OpenTimelineIO = "0.16.0" +OpenTimelineIO = "0.17.0" opencolorio = "^2.3.2,<2.4.0" Pillow = "9.5.0" websocket-client = ">=0.40.0,<2" From c3b8f76501f5327343f98f5a5f106e264d34b06b Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 3 Sep 2025 20:18:44 +0800 Subject: [PATCH 263/319] max hosts for pre ocio hook so that the environment variable for ocio would be collected accuratly --- client/ayon_core/hooks/pre_ocio_hook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/hooks/pre_ocio_hook.py b/client/ayon_core/hooks/pre_ocio_hook.py index 85fcef47f2..be086dae65 100644 --- a/client/ayon_core/hooks/pre_ocio_hook.py +++ b/client/ayon_core/hooks/pre_ocio_hook.py @@ -14,7 +14,7 @@ class OCIOEnvHook(PreLaunchHook): "fusion", "blender", "aftereffects", - "3dsmax", + "max", "houdini", "maya", "nuke", From 14ab55e7ee75f25a34ccf1aa54865ef4f5cbe37e Mon Sep 17 00:00:00 2001 From: Ynbot Date: Fri, 5 Sep 2025 13:40:16 +0000 Subject: [PATCH 264/319] [Automated] Add generated package files from main --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index f2aa94020f..8eb2aa68f8 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.5.3+dev" +__version__ = "1.6.0" diff --git a/package.py b/package.py index 4393b7be40..37c3133eb0 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.5.3+dev" +version = "1.6.0" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index ee6c35b50b..302d249cca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.5.3+dev" +version = "1.6.0" description = "" authors = ["Ynput Team "] readme = "README.md" From 95a143ea4602b0fb12cefa9d0a1bd8911c799084 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Fri, 5 Sep 2025 13:40:54 +0000 Subject: [PATCH 265/319] [Automated] Update version in package.py for develop --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 8eb2aa68f8..9ca5e1bc30 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.6.0" +__version__ = "1.6.0+dev" diff --git a/package.py b/package.py index 37c3133eb0..e430524dd5 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.6.0" +version = "1.6.0+dev" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 302d249cca..9a62a408ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.6.0" +version = "1.6.0+dev" description = "" authors = ["Ynput Team "] readme = "README.md" From a269244e78c56b049cfc381bd0a927f2373f7f1d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 5 Sep 2025 13:41:47 +0000 Subject: [PATCH 266/319] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index ce5982969c..24c2b568b3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to AYON Tray options: + - 1.6.0 - 1.5.3 - 1.5.2 - 1.5.1 From 257dfe204a62dedf4a88d598bbba54cd133cf5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 8 Sep 2025 14:35:57 +0200 Subject: [PATCH 267/319] :sparkles: resolve environments in dev bundle paths --- client/ayon_core/addon/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index f7fee13dc7..9f1d60fe88 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -302,6 +302,9 @@ def _load_ayon_addons(log): milestone_version = MOVED_ADDON_MILESTONE_VERSIONS.get(addon_name) if use_dev_path: addon_dir = dev_addon_info["path"] + if addon_dir: + addon_dir.format(os.environ) + if not addon_dir or not os.path.exists(addon_dir): log.warning(( "Dev addon {} {} path does not exists. Path \"{}\"" From 8ac8352dcd14c7d720c8439961e014cff34fc884 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 8 Sep 2025 14:47:00 +0200 Subject: [PATCH 268/319] added burnins adapter --- client/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/client/pyproject.toml b/client/pyproject.toml index bccc0b9872..5acfdf439d 100644 --- a/client/pyproject.toml +++ b/client/pyproject.toml @@ -16,6 +16,7 @@ qtawesome = "0.7.3" aiohttp-middlewares = "^2.0.0" Click = "^8" OpenTimelineIO = "0.17.0" +otio-burnins-adapter = "1.0.0" opencolorio = "^2.3.2,<2.4.0" Pillow = "9.5.0" websocket-client = ">=0.40.0,<2" From 2e881902037299ed09553984553640c2320e1d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 8 Sep 2025 15:48:30 +0200 Subject: [PATCH 269/319] :bug: fix handling of `os.environ` --- client/ayon_core/addon/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index 9f1d60fe88..3ec09f32a3 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -303,7 +303,7 @@ def _load_ayon_addons(log): if use_dev_path: addon_dir = dev_addon_info["path"] if addon_dir: - addon_dir.format(os.environ) + addon_dir = addon_dir.format(**os.environ) if not addon_dir or not os.path.exists(addon_dir): log.warning(( From db2c1858d5a0014d27a16ecf138075f437b096a6 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 8 Sep 2025 16:10:49 +0200 Subject: [PATCH 270/319] Updates color space handling in OIIO transcode. Temporarily disables upstream OCIO color space logic. Uses 'colorspaceDisplay' and 'colorspaceView' instead. This is a temporary workaround. --- .../ayon_core/plugins/publish/extract_color_transcode.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_color_transcode.py b/client/ayon_core/plugins/publish/extract_color_transcode.py index 24820f7022..8b351c7f31 100644 --- a/client/ayon_core/plugins/publish/extract_color_transcode.py +++ b/client/ayon_core/plugins/publish/extract_color_transcode.py @@ -88,9 +88,12 @@ class ExtractOIIOTranscode(publish.Extractor): repres = instance.data["representations"] for idx, repre in enumerate(list(repres)): # target space, display and view might be defined upstream - target_colorspace = instance.data.get("targetOCIOColorspace") - target_display = instance.data.get("targetOCIODisplay") - target_view = instance.data.get("targetOCIOView") + # TODO: address https://github.com/ynput/ayon-core/pull/1268#discussion_r2156555474 + # Implement upstream logic to handle target_colorspace, + # target_display, target_view in other DCCs + target_colorspace = False + target_display = instance.data.get("colorspaceDisplay") + target_view = instance.data.get("colorspaceView") self.log.debug("repre ({}): `{}`".format(idx + 1, repre["name"])) if not self._repre_is_valid(repre): From 8e0585c50d06c13e17cfbc0f78ddc0efcae71932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= <33513211+antirotor@users.noreply.github.com> Date: Mon, 8 Sep 2025 17:52:56 +0200 Subject: [PATCH 271/319] Update client/ayon_core/addon/base.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/addon/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index 3ec09f32a3..70bb9dca40 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -303,7 +303,9 @@ def _load_ayon_addons(log): if use_dev_path: addon_dir = dev_addon_info["path"] if addon_dir: - addon_dir = addon_dir.format(**os.environ) + addon_dir = os.path.expandvars( + addon_dir.format_map(os.environ) + ) if not addon_dir or not os.path.exists(addon_dir): log.warning(( From 6419e3ed749fe33c80100a5fe5716166d4f404e2 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 11 Sep 2025 13:35:19 +0200 Subject: [PATCH 272/319] use python 3 super --- client/ayon_core/tools/utils/widgets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/utils/widgets.py b/client/ayon_core/tools/utils/widgets.py index 941aa692f9..4b787ff830 100644 --- a/client/ayon_core/tools/utils/widgets.py +++ b/client/ayon_core/tools/utils/widgets.py @@ -418,7 +418,7 @@ class ExpandingTextEdit(QtWidgets.QTextEdit): """QTextEdit which does not have sroll area but expands height.""" def __init__(self, parent=None): - super(ExpandingTextEdit, self).__init__(parent) + super().__init__(parent) size_policy = self.sizePolicy() size_policy.setHeightForWidth(True) From 6b058fccf092717111444b89e168e4f678d9ca51 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 11 Sep 2025 13:35:50 +0200 Subject: [PATCH 273/319] disable scroll bards on message input --- client/ayon_core/tools/publisher/widgets/report_page.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/tools/publisher/widgets/report_page.py b/client/ayon_core/tools/publisher/widgets/report_page.py index 1e46e7e52c..033ddab0ef 100644 --- a/client/ayon_core/tools/publisher/widgets/report_page.py +++ b/client/ayon_core/tools/publisher/widgets/report_page.py @@ -1147,6 +1147,8 @@ class LogItemMessage(QtWidgets.QTextEdit): QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum ) + self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) document = self.document() document.documentLayout().documentSizeChanged.connect( self._adjust_minimum_size From 23a905b837938da661e30d3cafca3f4e917f32b7 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 11 Sep 2025 15:10:45 +0200 Subject: [PATCH 274/319] move addons manager to controller --- client/ayon_core/tools/launcher/abstract.py | 5 +++++ client/ayon_core/tools/launcher/control.py | 8 ++++++++ client/ayon_core/tools/launcher/models/actions.py | 10 +--------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/client/ayon_core/tools/launcher/abstract.py b/client/ayon_core/tools/launcher/abstract.py index 1d7dafd62f..c0fc115f31 100644 --- a/client/ayon_core/tools/launcher/abstract.py +++ b/client/ayon_core/tools/launcher/abstract.py @@ -4,6 +4,7 @@ from abc import ABC, abstractmethod from dataclasses import dataclass from typing import Optional, Any +from ayon_core.addon import AddonsManager from ayon_core.tools.common_models import ( ProjectItem, FolderItem, @@ -85,6 +86,10 @@ class AbstractLauncherBackend(AbstractLauncherCommon): pass + @abstractmethod + def get_addons_manager(self) -> AddonsManager: + pass + @abstractmethod def get_project_settings(self, project_name): """Project settings for current project. diff --git a/client/ayon_core/tools/launcher/control.py b/client/ayon_core/tools/launcher/control.py index 58d22453be..ce23b0323f 100644 --- a/client/ayon_core/tools/launcher/control.py +++ b/client/ayon_core/tools/launcher/control.py @@ -1,5 +1,6 @@ from ayon_core.lib import Logger, get_ayon_username from ayon_core.lib.events import QueuedEventSystem +from ayon_core.addon import AddonsManager from ayon_core.settings import get_project_settings, get_studio_settings from ayon_core.tools.common_models import ProjectsModel, HierarchyModel @@ -17,6 +18,8 @@ class BaseLauncherController( self._event_system = None self._log = None + self._addons_manager = None + self._username = NOT_SET self._selection_model = LauncherSelectionModel(self) @@ -59,6 +62,11 @@ class BaseLauncherController( def register_event_callback(self, topic, callback): self.event_system.add_callback(topic, callback) + def get_addons_manager(self) -> AddonsManager: + if self._addons_manager is None: + self._addons_manager = AddonsManager() + return self._addons_manager + # Entity items for UI def get_project_items(self, sender=None): return self._projects_model.get_project_items(sender) diff --git a/client/ayon_core/tools/launcher/models/actions.py b/client/ayon_core/tools/launcher/models/actions.py index 51fbe72143..5f888effb5 100644 --- a/client/ayon_core/tools/launcher/models/actions.py +++ b/client/ayon_core/tools/launcher/models/actions.py @@ -15,7 +15,6 @@ from ayon_core.lib import ( get_settings_variant, run_detached_ayon_launcher_process, ) -from ayon_core.addon import AddonsManager from ayon_core.pipeline.actions import ( discover_launcher_actions, LauncherActionSelection, @@ -104,8 +103,6 @@ class ActionsModel: levels=2, default_factory=list, lifetime=20, ) - self._addons_manager = None - self._variant = get_settings_variant() @staticmethod @@ -333,11 +330,6 @@ class ActionsModel: exc_info=True ) - def _get_addons_manager(self): - if self._addons_manager is None: - self._addons_manager = AddonsManager() - return self._addons_manager - def _prepare_selection(self, project_name, folder_id, task_id): project_entity = None if project_name: @@ -542,7 +534,7 @@ class ActionsModel: # NOTE We don't need to register the paths, but that would # require to change discovery logic and deprecate all functions # related to registering and discovering launcher actions. - addons_manager = self._get_addons_manager() + addons_manager = self._controller.get_addons_manager() actions_paths = addons_manager.collect_launcher_action_paths() for path in actions_paths: if path and os.path.exists(path): From d960694f453bee2a50847649bfbc79f1eea97656 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Sep 2025 12:58:15 +0200 Subject: [PATCH 275/319] added workfile items to launcher controller --- client/ayon_core/tools/launcher/abstract.py | 26 +++++ client/ayon_core/tools/launcher/control.py | 28 ++++- .../tools/launcher/models/__init__.py | 2 + .../tools/launcher/models/workfiles.py | 101 ++++++++++++++++++ 4 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 client/ayon_core/tools/launcher/models/workfiles.py diff --git a/client/ayon_core/tools/launcher/abstract.py b/client/ayon_core/tools/launcher/abstract.py index c0fc115f31..b0a7a8b213 100644 --- a/client/ayon_core/tools/launcher/abstract.py +++ b/client/ayon_core/tools/launcher/abstract.py @@ -57,6 +57,14 @@ class ActionItem: addon_version: Optional[str] = None +@dataclass +class WorkfileItem: + filename : str + exists: bool + icon: Optional[str] + version: Optional[int] + + class AbstractLauncherCommon(ABC): @abstractmethod def register_event_callback(self, topic, callback): @@ -470,3 +478,21 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): """ pass + + @abstractmethod + def get_workfile_items( + self, + project_name: Optional[str], + task_id: Optional[str], + ) -> list[WorkfileItem]: + """Get workfile items for a given context. + + Args: + project_name (Optional[str]): Project name. + task_id (Optional[str]): Task id. + + Returns: + list[WorkfileItem]: List of workfile items. + + """ + pass diff --git a/client/ayon_core/tools/launcher/control.py b/client/ayon_core/tools/launcher/control.py index ce23b0323f..66afebc247 100644 --- a/client/ayon_core/tools/launcher/control.py +++ b/client/ayon_core/tools/launcher/control.py @@ -1,11 +1,21 @@ +from typing import Optional + from ayon_core.lib import Logger, get_ayon_username from ayon_core.lib.events import QueuedEventSystem from ayon_core.addon import AddonsManager from ayon_core.settings import get_project_settings, get_studio_settings from ayon_core.tools.common_models import ProjectsModel, HierarchyModel -from .abstract import AbstractLauncherFrontEnd, AbstractLauncherBackend -from .models import LauncherSelectionModel, ActionsModel +from .abstract import ( + AbstractLauncherFrontEnd, + AbstractLauncherBackend, + WorkfileItem, +) +from .models import ( + LauncherSelectionModel, + ActionsModel, + WorkfilesModel, +) NOT_SET = object() @@ -26,6 +36,7 @@ class BaseLauncherController( self._projects_model = ProjectsModel(self) self._hierarchy_model = HierarchyModel(self) self._actions_model = ActionsModel(self) + self._workfiles_model = WorkfilesModel(self) @property def log(self): @@ -141,6 +152,17 @@ class BaseLauncherController( "task_name": self.get_selected_task_name(), } + # Workfiles + def get_workfile_items( + self, + project_name: Optional[str], + task_id: Optional[str], + ) -> list[WorkfileItem]: + return self._workfiles_model.get_workfile_items( + project_name, + task_id, + ) + # Actions def get_action_items(self, project_name, folder_id, task_id): return self._actions_model.get_action_items( @@ -194,6 +216,8 @@ class BaseLauncherController( self._projects_model.reset() # Refresh actions self._actions_model.refresh() + # Reset workfiles model + self._workfiles_model.reset() self._emit_event("controller.refresh.actions.finished") diff --git a/client/ayon_core/tools/launcher/models/__init__.py b/client/ayon_core/tools/launcher/models/__init__.py index 1bc60c85f0..efc0de96ca 100644 --- a/client/ayon_core/tools/launcher/models/__init__.py +++ b/client/ayon_core/tools/launcher/models/__init__.py @@ -1,8 +1,10 @@ from .actions import ActionsModel from .selection import LauncherSelectionModel +from .workfiles import WorkfilesModel __all__ = ( "ActionsModel", "LauncherSelectionModel", + "WorkfilesModel", ) diff --git a/client/ayon_core/tools/launcher/models/workfiles.py b/client/ayon_core/tools/launcher/models/workfiles.py new file mode 100644 index 0000000000..2ba15c1800 --- /dev/null +++ b/client/ayon_core/tools/launcher/models/workfiles.py @@ -0,0 +1,101 @@ +import os +from typing import Optional, Any + +import ayon_api + +from ayon_core.lib import ( + Logger, + NestedCacheItem, +) +from ayon_core.pipeline import Anatomy +from ayon_core.tools.launcher.abstract import ( + WorkfileItem, + AbstractLauncherBackend, +) + + +class WorkfilesModel: + def __init__(self, controller: AbstractLauncherBackend): + self._controller = controller + + self._log = Logger.get_logger(self.__class__.__name__) + + self._host_icons = None + self._workfile_items = NestedCacheItem( + levels=2, default_factory=list, lifetime=60, + ) + + def reset(self) -> None: + self._workfile_items.reset() + + def get_workfile_items( + self, + project_name: Optional[str], + task_id: Optional[str], + ) -> list[WorkfileItem]: + if not project_name or not task_id: + return [] + + cache = self._workfile_items[project_name][task_id] + if cache.is_valid: + return cache.get_data() + + project_entity = self._controller.get_project_entity(project_name) + anatomy = Anatomy(project_name, project_entity=project_entity) + items = [] + for workfile_entity in ayon_api.get_workfiles_info( + project_name, task_ids={task_id}, fields={"path", "data"} + ): + rootless_path = workfile_entity["path"] + exists = False + try: + path = anatomy.fill_root(rootless_path) + exists = os.path.exists(path) + except Exception: + self._log.warning( + "Failed to fill root for workfile path", + exc_info=True, + ) + workfile_data = workfile_entity["data"] + host_name = workfile_data.get("host_name") + version = workfile_data.get("version") + + items.append(WorkfileItem( + os.path.basename(rootless_path), + exists=exists, + icon=self._get_host_icon(host_name), + version=version, + )) + cache.update_data(items) + return items + + def _get_host_icon( + self, host_name: Optional[str] + ) -> Optional[dict[str, Any]]: + if self._host_icons is None: + host_icons = {} + try: + host_icons = self._get_host_icons() + except Exception: + self._log.warning( + "Failed to get host icons", + exc_info=True, + ) + self._host_icons = host_icons + return self._host_icons.get(host_name) + + def _get_host_icons(self) -> dict[str, Any]: + addons_manager = self._controller.get_addons_manager() + applications_addon = addons_manager["applications"] + apps_manager = applications_addon.get_applications_manager() + output = {} + for app_group in apps_manager.app_groups.values(): + host_name = app_group.host_name + icon_filename = app_group.icon + if not host_name or not icon_filename: + continue + icon_url = applications_addon.get_app_icon_url( + icon_filename, server=True + ) + output[host_name] = icon_url + return output From 0794db9ac2d6fc6165c12a90aba2084433fab4eb Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Sep 2025 12:58:37 +0200 Subject: [PATCH 276/319] added workfiles page to launcher window --- .../tools/launcher/ui/hierarchy_page.py | 13 +- client/ayon_core/tools/launcher/ui/window.py | 2 +- .../tools/launcher/ui/workfiles_page.py | 178 ++++++++++++++++++ 3 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 client/ayon_core/tools/launcher/ui/workfiles_page.py diff --git a/client/ayon_core/tools/launcher/ui/hierarchy_page.py b/client/ayon_core/tools/launcher/ui/hierarchy_page.py index 65efdc27ac..47388d9685 100644 --- a/client/ayon_core/tools/launcher/ui/hierarchy_page.py +++ b/client/ayon_core/tools/launcher/ui/hierarchy_page.py @@ -12,6 +12,8 @@ from ayon_core.tools.utils import ( ) from ayon_core.tools.utils.lib import checkstate_int_to_enum +from .workfiles_page import WorkfilesPage + class HierarchyPage(QtWidgets.QWidget): def __init__(self, controller, parent): @@ -73,10 +75,15 @@ class HierarchyPage(QtWidgets.QWidget): # - Tasks widget tasks_widget = TasksWidget(controller, content_body) + # - Third page - Workfiles + workfiles_page = WorkfilesPage(controller, content_body) + content_body.addWidget(folders_widget) content_body.addWidget(tasks_widget) - content_body.setStretchFactor(0, 100) - content_body.setStretchFactor(1, 65) + content_body.addWidget(workfiles_page) + content_body.setStretchFactor(0, 120) + content_body.setStretchFactor(1, 85) + content_body.setStretchFactor(2, 220) main_layout = QtWidgets.QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) @@ -99,6 +106,7 @@ class HierarchyPage(QtWidgets.QWidget): self._my_tasks_checkbox = my_tasks_checkbox self._folders_widget = folders_widget self._tasks_widget = tasks_widget + self._workfiles_page = workfiles_page self._project_name = None @@ -117,6 +125,7 @@ class HierarchyPage(QtWidgets.QWidget): def refresh(self): self._folders_widget.refresh() self._tasks_widget.refresh() + self._workfiles_page.refresh() self._on_my_tasks_checkbox_state_changed( self._my_tasks_checkbox.checkState() ) diff --git a/client/ayon_core/tools/launcher/ui/window.py b/client/ayon_core/tools/launcher/ui/window.py index 819e141d59..ad2fd2d3c2 100644 --- a/client/ayon_core/tools/launcher/ui/window.py +++ b/client/ayon_core/tools/launcher/ui/window.py @@ -177,7 +177,7 @@ class LauncherWindow(QtWidgets.QWidget): self._page_slide_anim = page_slide_anim hierarchy_page.setVisible(not self._is_on_projects_page) - self.resize(520, 740) + self.resize(920, 740) def showEvent(self, event): super().showEvent(event) diff --git a/client/ayon_core/tools/launcher/ui/workfiles_page.py b/client/ayon_core/tools/launcher/ui/workfiles_page.py new file mode 100644 index 0000000000..2f390f1bee --- /dev/null +++ b/client/ayon_core/tools/launcher/ui/workfiles_page.py @@ -0,0 +1,178 @@ +from typing import Optional + +import ayon_api +from qtpy import QtCore, QtWidgets, QtGui + +from ayon_core.tools.utils import get_qt_icon +from ayon_core.tools.launcher.abstract import AbstractLauncherFrontEnd + +VERSION_ROLE = QtCore.Qt.UserRole + 1 + + +class WorkfilesModel(QtGui.QStandardItemModel): + refreshed = QtCore.Signal() + + def __init__(self, controller: AbstractLauncherFrontEnd) -> None: + super().__init__() + + self.setColumnCount(1) + self.setHeaderData(0, QtCore.Qt.Horizontal, "Workfiles") + + controller.register_event_callback( + "selection.project.changed", + self._on_selection_project_changed, + ) + controller.register_event_callback( + "selection.folder.changed", + self._on_selection_folder_changed, + ) + controller.register_event_callback( + "selection.task.changed", + self._on_selection_task_changed, + ) + + self._controller = controller + self._selected_project_name = None + self._selected_folder_id = None + self._selected_task_id = None + + self._transparent_icon = None + + self._cached_icons = {} + + def refresh(self) -> None: + root_item = self.invisibleRootItem() + root_item.removeRows(0, root_item.rowCount()) + + workfile_items = self._controller.get_workfile_items( + self._selected_project_name, self._selected_task_id + ) + new_items = [] + for workfile_item in workfile_items: + icon = self._get_icon(workfile_item.icon) + item = QtGui.QStandardItem(workfile_item.filename) + item.setData(icon, QtCore.Qt.DecorationRole) + item.setData(workfile_item.version, VERSION_ROLE) + flags = QtCore.Qt.NoItemFlags + if workfile_item.exists: + flags = QtCore.Qt.ItemIsEnabled + item.setFlags(flags) + new_items.append(item) + + if not new_items: + title = "< No workfiles >" + if not self._selected_project_name: + title = "< Select a project >" + elif not self._selected_folder_id: + title = "< Select a folder >" + elif not self._selected_task_id: + title = "< Select a task >" + item = QtGui.QStandardItem(title) + item.setFlags(QtCore.Qt.NoItemFlags) + new_items.append(item) + root_item.appendRows(new_items) + + self.refreshed.emit() + + def _on_selection_project_changed(self, event) -> None: + self._selected_project_name = event["project_name"] + self._selected_folder_id = None + self._selected_task_id = None + self.refresh() + + def _on_selection_folder_changed(self, event) -> None: + self._selected_project_name = event["project_name"] + self._selected_folder_id = event["folder_id"] + self._selected_task_id = None + self.refresh() + + def _on_selection_task_changed(self, event) -> None: + self._selected_project_name = event["project_name"] + self._selected_folder_id = event["folder_id"] + self._selected_task_id = event["task_id"] + self.refresh() + + def _get_transparent_icon(self) -> QtGui.QIcon: + if self._transparent_icon is None: + self._transparent_icon = get_qt_icon({ + "type": "transparent", "size": 256 + }) + return self._transparent_icon + + def _get_icon(self, icon_url: Optional[str]) -> QtGui.QIcon: + if icon_url is None: + return self._get_transparent_icon() + icon = self._cached_icons.get(icon_url) + if icon is not None: + return icon + + base_url = ayon_api.get_base_url() + if icon_url.startswith(base_url): + icon_def = { + "type": "ayon_url", + "url": icon_url[len(base_url) + 1:], + } + else: + icon_def = { + "type": "url", + "url": icon_url, + } + + icon = get_qt_icon(icon_def) + if icon is None: + icon = self._get_transparent_icon() + self._cached_icons[icon_url] = icon + return icon + + +class WorkfilesProxyModel(QtCore.QSortFilterProxyModel): + def lessThan(self, left, right) -> bool: + # left_version = left.data(VERSION_ROLE) + # right_version = right.data(VERSION_ROLE) + # if left_version != right_version: + # if left_version is None: + # return False + # if right_version is None: + # return True + # + # return left_version > right_version + return not super().lessThan(left, right) + + +class WorkfilesView(QtWidgets.QTreeView): + def drawBranches(self, painter, rect, index): + return + + +class WorkfilesPage(QtWidgets.QWidget): + def __init__( + self, + controller: AbstractLauncherFrontEnd, + parent: QtWidgets.QWidget, + ) -> None: + super().__init__(parent) + + workfiles_view = WorkfilesView(self) + workfiles_view.setIndentation(0) + workfiles_model = WorkfilesModel(controller) + workfiles_proxy = WorkfilesProxyModel() + workfiles_proxy.setSourceModel(workfiles_model) + + workfiles_view.setModel(workfiles_proxy) + + layout = QtWidgets.QVBoxLayout(self) + layout.setContentsMargins(0, 0, 0, 0) + layout.addWidget(workfiles_view, 1) + + workfiles_model.refreshed.connect(self._on_refresh) + + self._controller = controller + self._workfiles_view = workfiles_view + self._workfiles_model = workfiles_model + self._workfiles_proxy = workfiles_proxy + + def refresh(self) -> None: + self._workfiles_model.refresh() + + def _on_refresh(self) -> None: + self._workfiles_proxy.sort(0) From f19c6d0ad8f75fda4854e2343665de8405396bb3 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Sep 2025 15:30:53 +0200 Subject: [PATCH 277/319] use standard proxy model --- .../tools/launcher/ui/workfiles_page.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/client/ayon_core/tools/launcher/ui/workfiles_page.py b/client/ayon_core/tools/launcher/ui/workfiles_page.py index 2f390f1bee..9bfd474764 100644 --- a/client/ayon_core/tools/launcher/ui/workfiles_page.py +++ b/client/ayon_core/tools/launcher/ui/workfiles_page.py @@ -125,20 +125,6 @@ class WorkfilesModel(QtGui.QStandardItemModel): return icon -class WorkfilesProxyModel(QtCore.QSortFilterProxyModel): - def lessThan(self, left, right) -> bool: - # left_version = left.data(VERSION_ROLE) - # right_version = right.data(VERSION_ROLE) - # if left_version != right_version: - # if left_version is None: - # return False - # if right_version is None: - # return True - # - # return left_version > right_version - return not super().lessThan(left, right) - - class WorkfilesView(QtWidgets.QTreeView): def drawBranches(self, painter, rect, index): return @@ -155,7 +141,7 @@ class WorkfilesPage(QtWidgets.QWidget): workfiles_view = WorkfilesView(self) workfiles_view.setIndentation(0) workfiles_model = WorkfilesModel(controller) - workfiles_proxy = WorkfilesProxyModel() + workfiles_proxy = QtCore.QSortFilterProxyModel() workfiles_proxy.setSourceModel(workfiles_model) workfiles_view.setModel(workfiles_proxy) @@ -175,4 +161,4 @@ class WorkfilesPage(QtWidgets.QWidget): self._workfiles_model.refresh() def _on_refresh(self) -> None: - self._workfiles_proxy.sort(0) + self._workfiles_proxy.sort(0, QtCore.Qt.DescendingOrder ) From afe70c0f55d3d567ddf578a13a03f7172093522f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Sep 2025 15:37:50 +0200 Subject: [PATCH 278/319] formatting fixes --- client/ayon_core/tools/launcher/abstract.py | 2 +- client/ayon_core/tools/launcher/ui/workfiles_page.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/launcher/abstract.py b/client/ayon_core/tools/launcher/abstract.py index b0a7a8b213..f312504d31 100644 --- a/client/ayon_core/tools/launcher/abstract.py +++ b/client/ayon_core/tools/launcher/abstract.py @@ -59,7 +59,7 @@ class ActionItem: @dataclass class WorkfileItem: - filename : str + filename: str exists: bool icon: Optional[str] version: Optional[int] diff --git a/client/ayon_core/tools/launcher/ui/workfiles_page.py b/client/ayon_core/tools/launcher/ui/workfiles_page.py index 9bfd474764..0401183080 100644 --- a/client/ayon_core/tools/launcher/ui/workfiles_page.py +++ b/client/ayon_core/tools/launcher/ui/workfiles_page.py @@ -161,4 +161,4 @@ class WorkfilesPage(QtWidgets.QWidget): self._workfiles_model.refresh() def _on_refresh(self) -> None: - self._workfiles_proxy.sort(0, QtCore.Qt.DescendingOrder ) + self._workfiles_proxy.sort(0, QtCore.Qt.DescendingOrder) From 8f2f10bce1efca04f6f0a22f663d98a99cce95c6 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:20:43 +0200 Subject: [PATCH 279/319] added 'get_project_entity' to controller --- client/ayon_core/tools/loader/abstract.py | 6 ++++++ client/ayon_core/tools/loader/control.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/client/ayon_core/tools/loader/abstract.py b/client/ayon_core/tools/loader/abstract.py index 5ab7e78212..42e88c15d7 100644 --- a/client/ayon_core/tools/loader/abstract.py +++ b/client/ayon_core/tools/loader/abstract.py @@ -513,6 +513,12 @@ class BackendLoaderController(_BaseLoaderController): pass + @abstractmethod + def get_project_entity( + self, project_name: Optional[str] + ) -> Optional[dict[str, Any]]: + pass + class FrontendLoaderController(_BaseLoaderController): @abstractmethod diff --git a/client/ayon_core/tools/loader/control.py b/client/ayon_core/tools/loader/control.py index 7ba42a0981..492a05e82f 100644 --- a/client/ayon_core/tools/loader/control.py +++ b/client/ayon_core/tools/loader/control.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging import uuid +from typing import Optional, Any import ayon_api @@ -188,6 +189,11 @@ class LoaderController(BackendLoaderController, FrontendLoaderController): def get_project_items(self, sender=None): return self._projects_model.get_project_items(sender) + def get_project_entity( + self, project_name: Optional[str] + ) -> Optional[dict[str, Any]]: + return self._projects_model.get_project_entity(project_name) + def get_folder_type_items(self, project_name, sender=None): return self._projects_model.get_folder_type_items( project_name, sender From 7f8e62e8efc2efa016fe66cabc305d1a215fd5bf Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:29:55 +0200 Subject: [PATCH 280/319] add icons mapping to products --- client/ayon_core/tools/loader/abstract.py | 7 - .../ayon_core/tools/loader/models/products.py | 205 +++++++++--------- .../tools/loader/ui/products_model.py | 8 +- 3 files changed, 103 insertions(+), 117 deletions(-) diff --git a/client/ayon_core/tools/loader/abstract.py b/client/ayon_core/tools/loader/abstract.py index 42e88c15d7..87cfb1f3f2 100644 --- a/client/ayon_core/tools/loader/abstract.py +++ b/client/ayon_core/tools/loader/abstract.py @@ -78,7 +78,6 @@ class ProductItem: product_type (str): Product type. product_name (str): Product name. product_icon (dict[str, Any]): Product icon definition. - product_type_icon (dict[str, Any]): Product type icon definition. product_in_scene (bool): Is product in scene (only when used in DCC). group_name (str): Group name. folder_id (str): Folder id. @@ -93,8 +92,6 @@ class ProductItem: product_base_type: str, product_name: str, product_icon: dict[str, Any], - product_type_icon: dict[str, Any], - product_base_type_icon: dict[str, Any], group_name: str, folder_id: str, folder_label: str, @@ -106,8 +103,6 @@ class ProductItem: self.product_base_type = product_base_type self.product_name = product_name self.product_icon = product_icon - self.product_type_icon = product_type_icon - self.product_base_type_icon = product_base_type_icon self.product_in_scene = product_in_scene self.group_name = group_name self.folder_id = folder_id @@ -121,8 +116,6 @@ class ProductItem: "product_base_type": self.product_base_type, "product_name": self.product_name, "product_icon": self.product_icon, - "product_type_icon": self.product_type_icon, - "product_base_type_icon": self.product_base_type_icon, "product_in_scene": self.product_in_scene, "group_name": self.group_name, "folder_id": self.folder_id, diff --git a/client/ayon_core/tools/loader/models/products.py b/client/ayon_core/tools/loader/models/products.py index 87e2406c81..f5e0b2fa80 100644 --- a/client/ayon_core/tools/loader/models/products.py +++ b/client/ayon_core/tools/loader/models/products.py @@ -9,7 +9,6 @@ import arrow import ayon_api from ayon_api.operations import OperationsSession - from ayon_core.lib import NestedCacheItem from ayon_core.style import get_default_entity_icon_color from ayon_core.tools.loader.abstract import ( @@ -21,12 +20,63 @@ from ayon_core.tools.loader.abstract import ( ) if TYPE_CHECKING: - from ayon_api.typing import ProductBaseTypeDict, ProductDict, VersionDict - + from ayon_api.typing import ( + ProductBaseTypeDict, + ProductDict, + VersionDict, + ) PRODUCTS_MODEL_SENDER = "products.model" +class ProductBaseTypeIconMapping: + def __init__( + self, + default: Optional[dict[str, str]] = None, + definitions: Optional[list[dict[str, str]]] = None, + ): + self._default = default or {} + self._definitions = definitions or [] + + self._default_def = None + self._definitions_by_name = None + + def get_icon( + self, + product_base_type: Optional[str] = None, + product_type: Optional[str] = None, + ) -> dict[str, str]: + defs = self._get_defs_by_name() + icon = defs.get(product_type) + if icon is None: + icon = defs.get(product_base_type) + if icon is None: + icon = self._get_default_def() + return icon.copy() + + def _get_default_def(self) -> dict[str, str]: + if self._default_def is None: + self._default_def = { + "type": "material-symbols", + "name": self._default.get("icon", "inventory_2"), + "color": self._default.get("color", "#cccccc"), + } + + return self._default_def + + def _get_defs_by_name(self) -> dict[str, dict[str, str]]: + if self._definitions_by_name is None: + self._definitions_by_name = { + product_base_type_def["name"]: { + "type": "material-symbols", + "name": product_base_type_def.get("icon", "inventory_2"), + "color": product_base_type_def.get("color", "#cccccc"), + } + for product_base_type_def in self._definitions + } + return self._definitions_by_name + + def version_item_from_entity(version): version_attribs = version["attrib"] tags = version["tags"] @@ -84,42 +134,18 @@ def version_item_from_entity(version): def product_item_from_entity( product_entity: ProductDict, version_entities, - product_type_items_by_name: dict[str, ProductTypeItem], - product_base_type_items_by_name: dict[str, ProductBaseTypeItem], folder_label, + icons_mapping, product_in_scene, ): product_attribs = product_entity["attrib"] group = product_attribs.get("productGroup") product_type = product_entity["productType"] - product_type_item = product_type_items_by_name.get(product_type) - # NOTE This is needed for cases when products were not created on server - # using api functions. In that case product type item may not be - # available and we need to create a default. - if product_type_item is None: - product_type_item = create_default_product_type_item(product_type) - # Cache the item for future use - product_type_items_by_name[product_type] = product_type_item - product_base_type = product_entity.get("productBaseType") - product_base_type_item = product_base_type_items_by_name.get( - product_base_type) - # Same as for product type item above. Not sure if this is still needed - # though. - if product_base_type_item is None: - product_base_type_item = create_default_product_base_type_item( - product_base_type) - # Cache the item for future use - product_base_type_items_by_name[product_base_type] = ( - product_base_type_item) - product_type_icon = product_type_item.icon - product_base_type_icon = product_base_type_item.icon - product_icon = { - "type": "awesome-font", - "name": "fa.file-o", - "color": get_default_entity_icon_color(), - } + product_icon = icons_mapping.get_icon( + product_base_type, product_type + ) version_items = { version_entity["id"]: version_item_from_entity(version_entity) for version_entity in version_entities @@ -131,8 +157,6 @@ def product_item_from_entity( product_base_type=product_base_type, product_name=product_entity["name"], product_icon=product_icon, - product_type_icon=product_type_icon, - product_base_type_icon=product_base_type_icon, product_in_scene=product_in_scene, group_name=group, folder_id=product_entity["folderId"], @@ -141,22 +165,8 @@ def product_item_from_entity( ) -def product_type_item_from_data( - product_type_data: ProductDict) -> ProductTypeItem: - # TODO implement icon implementation - # icon = product_type_data["icon"] - # color = product_type_data["color"] - icon = { - "type": "awesome-font", - "name": "fa.folder", - "color": "#0091B2", - } - # TODO implement checked logic - return ProductTypeItem(product_type_data["name"], icon) - - def product_base_type_item_from_data( - product_base_type_data: ProductBaseTypeDict + product_base_type_data: ProductBaseTypeDict ) -> ProductBaseTypeItem: """Create product base type item from data. @@ -174,34 +184,8 @@ def product_base_type_item_from_data( } return ProductBaseTypeItem( name=product_base_type_data["name"], - icon=icon) - - -def create_default_product_type_item(product_type: str) -> ProductTypeItem: - icon = { - "type": "awesome-font", - "name": "fa.folder", - "color": "#0091B2", - } - return ProductTypeItem(product_type, icon) - - -def create_default_product_base_type_item( - product_base_type: str) -> ProductBaseTypeItem: - """Create default product base type item. - - Args: - product_base_type (str): Product base type name. - - Returns: - ProductBaseTypeItem: Default product base type item. - """ - icon = { - "type": "awesome-font", - "name": "fa.folder", - "color": "#0091B2", - } - return ProductBaseTypeItem(product_base_type, icon) + icon=icon + ) class ProductsModel: @@ -227,6 +211,8 @@ class ProductsModel: self._product_folder_ids_mapping = collections.defaultdict(dict) # Cache helpers + self._product_type_icons_mapping = NestedCacheItem( + levels=1, default_factory=list, lifetime=self.lifetime) self._product_type_items_cache = NestedCacheItem( levels=1, default_factory=list, lifetime=self.lifetime) self._product_base_type_items_cache = NestedCacheItem( @@ -243,11 +229,14 @@ class ProductsModel: self._version_item_by_id.clear() self._product_folder_ids_mapping.clear() + self._product_type_icons_mapping.reset() self._product_type_items_cache.reset() self._product_items_cache.reset() self._repre_items_cache.reset() - def get_product_type_items(self, project_name): + def get_product_type_items( + self, project_name: Optional[str] + ) -> list[ProductTypeItem]: """Product type items for project. Args: @@ -255,23 +244,27 @@ class ProductsModel: Returns: list[ProductTypeItem]: Product type items. - """ + """ if not project_name: return [] cache = self._product_type_items_cache[project_name] if not cache.is_valid: + icons_mapping = self._get_product_type_icons(project_name) product_types = ayon_api.get_project_product_types(project_name) cache.update_data([ - product_type_item_from_data(product_type) + ProductTypeItem( + product_type["name"], + icons_mapping.get_icon(product_type=product_type["name"]), + ) for product_type in product_types ]) return cache.get_data() def get_product_base_type_items( - self, - project_name: Optional[str]) -> list[ProductBaseTypeItem]: + self, project_name: Optional[str] + ) -> list[ProductBaseTypeItem]: """Product base type items for the project. Args: @@ -286,6 +279,7 @@ class ProductsModel: cache = self._product_base_type_items_cache[project_name] if not cache.is_valid: + icons_mapping = self._get_product_type_icons(project_name) product_base_types = [] # TODO add temp implementation here when it is actually # implemented and available on server. @@ -294,7 +288,10 @@ class ProductsModel: project_name ) cache.update_data([ - product_base_type_item_from_data(product_base_type) + ProductBaseTypeItem( + product_base_type["name"], + icons_mapping.get_icon(product_base_type["name"]), + ) for product_base_type in product_base_types ]) return cache.get_data() @@ -511,6 +508,27 @@ class ProductsModel: PRODUCTS_MODEL_SENDER ) + def _get_product_type_icons( + self, project_name: Optional[str] + ) -> ProductBaseTypeIconMapping: + cache = self._product_type_icons_mapping[project_name] + if cache.is_valid: + return cache.get_data() + + project_entity = self._controller.get_project_entity(project_name) + icons_mapping = ProductBaseTypeIconMapping() + if project_entity: + product_base_types = ( + project_entity["config"].get("productBaseTypes", {}) + ) + icons_mapping = ProductBaseTypeIconMapping( + product_base_types.get("default"), + product_base_types.get("definitions") + ) + + cache.update_data(icons_mapping) + return icons_mapping + def _get_product_items_by_id(self, project_name, product_ids): product_item_by_id = self._product_item_by_id[project_name] missing_product_ids = set() @@ -553,36 +571,18 @@ class ProductsModel: products: Iterable[ProductDict], versions: Iterable[VersionDict], folder_items=None, - product_type_items=None, - product_base_type_items: Optional[Iterable[ProductBaseTypeItem]] = None ): if folder_items is None: folder_items = self._controller.get_folder_items(project_name) - if product_type_items is None: - product_type_items = self.get_product_type_items(project_name) - - if product_base_type_items is None: - product_base_type_items = self.get_product_base_type_items( - project_name - ) - loaded_product_ids = self._controller.get_loaded_product_ids() versions_by_product_id = collections.defaultdict(list) for version in versions: versions_by_product_id[version["productId"]].append(version) - product_type_items_by_name = { - product_type_item.name: product_type_item - for product_type_item in product_type_items - } - - product_base_type_items_by_name: dict[str, ProductBaseTypeItem] = { - product_base_type_item.name: product_base_type_item - for product_base_type_item in product_base_type_items - } output: dict[str, ProductItem] = {} + icons_mapping = self._get_product_type_icons(project_name) for product in products: product_id = product["id"] folder_id = product["folderId"] @@ -595,9 +595,8 @@ class ProductsModel: product_item = product_item_from_entity( product, versions, - product_type_items_by_name, - product_base_type_items_by_name, folder_item.label, + icons_mapping, product_id in loaded_product_ids, ) output[product_id] = product_item diff --git a/client/ayon_core/tools/loader/ui/products_model.py b/client/ayon_core/tools/loader/ui/products_model.py index f3e5271f51..79ed197d83 100644 --- a/client/ayon_core/tools/loader/ui/products_model.py +++ b/client/ayon_core/tools/loader/ui/products_model.py @@ -17,7 +17,6 @@ PRODUCT_ID_ROLE = QtCore.Qt.UserRole + 6 PRODUCT_NAME_ROLE = QtCore.Qt.UserRole + 7 PRODUCT_TYPE_ROLE = QtCore.Qt.UserRole + 8 PRODUCT_BASE_TYPE_ROLE = QtCore.Qt.UserRole + 9 -PRODUCT_TYPE_ICON_ROLE = QtCore.Qt.UserRole + 10 PRODUCT_IN_SCENE_ROLE = QtCore.Qt.UserRole + 11 VERSION_ID_ROLE = QtCore.Qt.UserRole + 12 VERSION_HERO_ROLE = QtCore.Qt.UserRole + 13 @@ -228,10 +227,7 @@ class ProductsModel(QtGui.QStandardItemModel): return super().data(index, role) if role == QtCore.Qt.DecorationRole: - if col == 1: - role = PRODUCT_TYPE_ICON_ROLE - else: - return None + return None if ( role == VERSION_NAME_EDIT_ROLE @@ -455,7 +451,6 @@ class ProductsModel(QtGui.QStandardItemModel): model_item = QtGui.QStandardItem(product_item.product_name) model_item.setEditable(False) icon = get_qt_icon(product_item.product_icon) - product_type_icon = get_qt_icon(product_item.product_type_icon) model_item.setColumnCount(self.columnCount()) model_item.setData(icon, QtCore.Qt.DecorationRole) model_item.setData(product_id, PRODUCT_ID_ROLE) @@ -464,7 +459,6 @@ class ProductsModel(QtGui.QStandardItemModel): product_item.product_base_type, PRODUCT_BASE_TYPE_ROLE ) model_item.setData(product_item.product_type, PRODUCT_TYPE_ROLE) - model_item.setData(product_type_icon, PRODUCT_TYPE_ICON_ROLE) model_item.setData(product_item.folder_id, FOLDER_ID_ROLE) self._product_items_by_id[product_id] = product_item From d8045df9a7f6d82941f280d4ae9783b58557a7f7 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:33:03 +0200 Subject: [PATCH 281/319] use same deafult as backend has --- client/ayon_core/tools/loader/models/products.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/loader/models/products.py b/client/ayon_core/tools/loader/models/products.py index f5e0b2fa80..11468e4db0 100644 --- a/client/ayon_core/tools/loader/models/products.py +++ b/client/ayon_core/tools/loader/models/products.py @@ -58,7 +58,7 @@ class ProductBaseTypeIconMapping: if self._default_def is None: self._default_def = { "type": "material-symbols", - "name": self._default.get("icon", "inventory_2"), + "name": self._default.get("icon", "deployed_code"), "color": self._default.get("color", "#cccccc"), } @@ -69,7 +69,7 @@ class ProductBaseTypeIconMapping: self._definitions_by_name = { product_base_type_def["name"]: { "type": "material-symbols", - "name": product_base_type_def.get("icon", "inventory_2"), + "name": product_base_type_def.get("icon", "deployed_code"), "color": product_base_type_def.get("color", "#cccccc"), } for product_base_type_def in self._definitions From 7b92047a6bea0e10e3e3e8cb34d97129a75d72c7 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 15 Sep 2025 11:38:58 +0200 Subject: [PATCH 282/319] move 'ProductTypeIconMapping' to common project model --- .../ayon_core/tools/common_models/__init__.py | 2 + .../ayon_core/tools/common_models/projects.py | 77 +++++++++++++++++- client/ayon_core/tools/loader/abstract.py | 20 +++-- client/ayon_core/tools/loader/control.py | 13 ++-- .../ayon_core/tools/loader/models/products.py | 78 ++----------------- 5 files changed, 108 insertions(+), 82 deletions(-) diff --git a/client/ayon_core/tools/common_models/__init__.py b/client/ayon_core/tools/common_models/__init__.py index ec69e20b64..77cc2dfb0f 100644 --- a/client/ayon_core/tools/common_models/__init__.py +++ b/client/ayon_core/tools/common_models/__init__.py @@ -10,6 +10,7 @@ from .projects import ( PROJECTS_MODEL_SENDER, FolderTypeItem, TaskTypeItem, + ProductTypeIconMapping, ) from .hierarchy import ( FolderItem, @@ -34,6 +35,7 @@ __all__ = ( "PROJECTS_MODEL_SENDER", "FolderTypeItem", "TaskTypeItem", + "ProductTypeIconMapping", "FolderItem", "TaskItem", diff --git a/client/ayon_core/tools/common_models/projects.py b/client/ayon_core/tools/common_models/projects.py index 034947de3a..710482a871 100644 --- a/client/ayon_core/tools/common_models/projects.py +++ b/client/ayon_core/tools/common_models/projects.py @@ -2,7 +2,7 @@ from __future__ import annotations import contextlib from abc import ABC, abstractmethod -from typing import Dict, Any +from typing import Any, Optional from dataclasses import dataclass import ayon_api @@ -51,7 +51,7 @@ class StatusItem: self.icon: str = icon self.state: str = state - def to_data(self) -> Dict[str, Any]: + def to_data(self) -> dict[str, Any]: return { "name": self.name, "color": self.color, @@ -218,6 +218,54 @@ class ProjectItem: return cls(**data) +class ProductTypeIconMapping: + def __init__( + self, + default: Optional[dict[str, str]] = None, + definitions: Optional[list[dict[str, str]]] = None, + ): + self._default = default or {} + self._definitions = definitions or [] + + self._default_def = None + self._definitions_by_name = None + + def get_icon( + self, + product_base_type: Optional[str] = None, + product_type: Optional[str] = None, + ) -> dict[str, str]: + defs = self._get_defs_by_name() + icon = defs.get(product_type) + if icon is None: + icon = defs.get(product_base_type) + if icon is None: + icon = self._get_default_def() + return icon.copy() + + def _get_default_def(self) -> dict[str, str]: + if self._default_def is None: + self._default_def = { + "type": "material-symbols", + "name": self._default.get("icon", "deployed_code"), + "color": self._default.get("color", "#cccccc"), + } + + return self._default_def + + def _get_defs_by_name(self) -> dict[str, dict[str, str]]: + if self._definitions_by_name is None: + self._definitions_by_name = { + product_base_type_def["name"]: { + "type": "material-symbols", + "name": product_base_type_def.get("icon", "deployed_code"), + "color": product_base_type_def.get("color", "#cccccc"), + } + for product_base_type_def in self._definitions + } + return self._definitions_by_name + + def _get_project_items_from_entitiy( projects: list[dict[str, Any]] ) -> list[ProjectItem]: @@ -242,6 +290,9 @@ class ProjectsModel(object): self._projects_by_name = NestedCacheItem( levels=1, default_factory=list ) + self._product_type_icons_mapping = NestedCacheItem( + levels=1, default_factory=ProductTypeIconMapping + ) self._project_statuses_cache = {} self._folder_types_cache = {} self._task_types_cache = {} @@ -255,6 +306,7 @@ class ProjectsModel(object): self._task_types_cache = {} self._projects_cache.reset() self._projects_by_name.reset() + self._product_type_icons_mapping.reset() def refresh(self): """Refresh project items. @@ -390,6 +442,27 @@ class ProjectsModel(object): self._task_type_items_getter, ) + def get_product_type_icons_mapping( + self, project_name: Optional[str] + ) -> ProductTypeIconMapping: + cache = self._product_type_icons_mapping[project_name] + if cache.is_valid: + return cache.get_data() + + project_entity = self.get_project_entity(project_name) + icons_mapping = ProductTypeIconMapping() + if project_entity: + product_base_types = ( + project_entity["config"].get("productBaseTypes", {}) + ) + icons_mapping = ProductTypeIconMapping( + product_base_types.get("default"), + product_base_types.get("definitions") + ) + + cache.update_data(icons_mapping) + return icons_mapping + def _get_project_items( self, project_name, sender, item_type, cache_obj, getter ): diff --git a/client/ayon_core/tools/loader/abstract.py b/client/ayon_core/tools/loader/abstract.py index 87cfb1f3f2..9c7934d2db 100644 --- a/client/ayon_core/tools/loader/abstract.py +++ b/client/ayon_core/tools/loader/abstract.py @@ -9,7 +9,11 @@ from ayon_core.lib.attribute_definitions import ( deserialize_attr_defs, serialize_attr_defs, ) -from ayon_core.tools.common_models import TaskItem, TagItem +from ayon_core.tools.common_models import ( + TaskItem, + TagItem, + ProductTypeIconMapping, +) class ProductTypeItem: @@ -492,8 +496,8 @@ class BackendLoaderController(_BaseLoaderController): topic (str): Event topic name. data (Optional[dict[str, Any]]): Event data. source (Optional[str]): Event source. - """ + """ pass @abstractmethod @@ -502,14 +506,20 @@ class BackendLoaderController(_BaseLoaderController): Returns: set[str]: Set of loaded product ids. - """ + """ pass @abstractmethod - def get_project_entity( + def get_product_type_icons_mapping( self, project_name: Optional[str] - ) -> Optional[dict[str, Any]]: + ) -> ProductTypeIconMapping: + """Product type icons mapping. + + Returns: + ProductTypeIconMapping: Product type icons mapping. + + """ pass diff --git a/client/ayon_core/tools/loader/control.py b/client/ayon_core/tools/loader/control.py index 492a05e82f..c7c182b192 100644 --- a/client/ayon_core/tools/loader/control.py +++ b/client/ayon_core/tools/loader/control.py @@ -17,6 +17,7 @@ from ayon_core.tools.common_models import ( HierarchyModel, ThumbnailsModel, TagItem, + ProductTypeIconMapping, ) from .abstract import ( @@ -189,11 +190,6 @@ class LoaderController(BackendLoaderController, FrontendLoaderController): def get_project_items(self, sender=None): return self._projects_model.get_project_items(sender) - def get_project_entity( - self, project_name: Optional[str] - ) -> Optional[dict[str, Any]]: - return self._projects_model.get_project_entity(project_name) - def get_folder_type_items(self, project_name, sender=None): return self._projects_model.get_folder_type_items( project_name, sender @@ -204,6 +200,13 @@ class LoaderController(BackendLoaderController, FrontendLoaderController): project_name, sender ) + def get_product_type_icons_mapping( + self, project_name: Optional[str] + ) -> ProductTypeIconMapping: + return self._projects_model.get_product_type_icons_mapping( + project_name + ) + def get_folder_items(self, project_name, sender=None): return self._hierarchy_model.get_folder_items(project_name, sender) diff --git a/client/ayon_core/tools/loader/models/products.py b/client/ayon_core/tools/loader/models/products.py index 11468e4db0..7915a75bcf 100644 --- a/client/ayon_core/tools/loader/models/products.py +++ b/client/ayon_core/tools/loader/models/products.py @@ -11,6 +11,7 @@ from ayon_api.operations import OperationsSession from ayon_core.lib import NestedCacheItem from ayon_core.style import get_default_entity_icon_color +from ayon_core.tools.common_models import ProductTypeIconMapping from ayon_core.tools.loader.abstract import ( ProductTypeItem, ProductBaseTypeItem, @@ -29,54 +30,6 @@ if TYPE_CHECKING: PRODUCTS_MODEL_SENDER = "products.model" -class ProductBaseTypeIconMapping: - def __init__( - self, - default: Optional[dict[str, str]] = None, - definitions: Optional[list[dict[str, str]]] = None, - ): - self._default = default or {} - self._definitions = definitions or [] - - self._default_def = None - self._definitions_by_name = None - - def get_icon( - self, - product_base_type: Optional[str] = None, - product_type: Optional[str] = None, - ) -> dict[str, str]: - defs = self._get_defs_by_name() - icon = defs.get(product_type) - if icon is None: - icon = defs.get(product_base_type) - if icon is None: - icon = self._get_default_def() - return icon.copy() - - def _get_default_def(self) -> dict[str, str]: - if self._default_def is None: - self._default_def = { - "type": "material-symbols", - "name": self._default.get("icon", "deployed_code"), - "color": self._default.get("color", "#cccccc"), - } - - return self._default_def - - def _get_defs_by_name(self) -> dict[str, dict[str, str]]: - if self._definitions_by_name is None: - self._definitions_by_name = { - product_base_type_def["name"]: { - "type": "material-symbols", - "name": product_base_type_def.get("icon", "deployed_code"), - "color": product_base_type_def.get("color", "#cccccc"), - } - for product_base_type_def in self._definitions - } - return self._definitions_by_name - - def version_item_from_entity(version): version_attribs = version["attrib"] tags = version["tags"] @@ -211,8 +164,6 @@ class ProductsModel: self._product_folder_ids_mapping = collections.defaultdict(dict) # Cache helpers - self._product_type_icons_mapping = NestedCacheItem( - levels=1, default_factory=list, lifetime=self.lifetime) self._product_type_items_cache = NestedCacheItem( levels=1, default_factory=list, lifetime=self.lifetime) self._product_base_type_items_cache = NestedCacheItem( @@ -229,7 +180,6 @@ class ProductsModel: self._version_item_by_id.clear() self._product_folder_ids_mapping.clear() - self._product_type_icons_mapping.reset() self._product_type_items_cache.reset() self._product_items_cache.reset() self._repre_items_cache.reset() @@ -267,6 +217,10 @@ class ProductsModel: ) -> list[ProductBaseTypeItem]: """Product base type items for the project. + Notes: + This will be used for filtering product types in UI when + product base types are fully implemented. + Args: project_name (optional, str): Project name. @@ -510,24 +464,8 @@ class ProductsModel: def _get_product_type_icons( self, project_name: Optional[str] - ) -> ProductBaseTypeIconMapping: - cache = self._product_type_icons_mapping[project_name] - if cache.is_valid: - return cache.get_data() - - project_entity = self._controller.get_project_entity(project_name) - icons_mapping = ProductBaseTypeIconMapping() - if project_entity: - product_base_types = ( - project_entity["config"].get("productBaseTypes", {}) - ) - icons_mapping = ProductBaseTypeIconMapping( - product_base_types.get("default"), - product_base_types.get("definitions") - ) - - cache.update_data(icons_mapping) - return icons_mapping + ) -> ProductTypeIconMapping: + return self._controller.get_product_type_icons_mapping(project_name) def _get_product_items_by_id(self, project_name, product_ids): product_item_by_id = self._product_item_by_id[project_name] @@ -542,7 +480,7 @@ class ProductsModel: output.update( self._query_product_items_by_ids( - project_name, missing_product_ids + project_name, product_ids=missing_product_ids ) ) return output From cf874e8f0a274b8a38ff8221d7f3d1a567095286 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 15 Sep 2025 11:46:28 +0200 Subject: [PATCH 283/319] use product type icon in scene inventory --- .../ayon_core/tools/sceneinventory/control.py | 15 ++++++++++- .../ayon_core/tools/sceneinventory/model.py | 5 +--- .../tools/sceneinventory/models/containers.py | 25 ++++++++++++++++++- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/tools/sceneinventory/control.py b/client/ayon_core/tools/sceneinventory/control.py index 45f76a54ac..606c9e7298 100644 --- a/client/ayon_core/tools/sceneinventory/control.py +++ b/client/ayon_core/tools/sceneinventory/control.py @@ -1,3 +1,5 @@ +from typing import Optional + import ayon_api from ayon_core.lib.events import QueuedEventSystem @@ -6,7 +8,11 @@ from ayon_core.pipeline import ( registered_host, get_current_context, ) -from ayon_core.tools.common_models import HierarchyModel, ProjectsModel +from ayon_core.tools.common_models import ( + HierarchyModel, + ProjectsModel, + ProductTypeIconMapping, +) from .models import SiteSyncModel, ContainersModel @@ -93,6 +99,13 @@ class SceneInventoryController: project_name, None ) + def get_product_type_icons_mapping( + self, project_name: Optional[str] + ) -> ProductTypeIconMapping: + return self._projects_model.get_product_type_icons_mapping( + project_name + ) + # Containers methods def get_containers(self): return self._containers_model.get_containers() diff --git a/client/ayon_core/tools/sceneinventory/model.py b/client/ayon_core/tools/sceneinventory/model.py index 885553acaf..9977acea21 100644 --- a/client/ayon_core/tools/sceneinventory/model.py +++ b/client/ayon_core/tools/sceneinventory/model.py @@ -214,9 +214,6 @@ class InventoryModel(QtGui.QStandardItemModel): group_icon = qtawesome.icon( "fa.object-group", color=self._default_icon_color ) - product_type_icon = qtawesome.icon( - "fa.folder", color="#0091B2" - ) group_item_font = QtGui.QFont() group_item_font.setBold(True) @@ -303,7 +300,7 @@ class InventoryModel(QtGui.QStandardItemModel): remote_site_progress = "{}%".format( max(progress["remote_site"], 0) * 100 ) - + product_type_icon = get_qt_icon(repre_info.product_type_icon) group_item = QtGui.QStandardItem() group_item.setColumnCount(root_item.columnCount()) group_item.setData(group_name, QtCore.Qt.DisplayRole) diff --git a/client/ayon_core/tools/sceneinventory/models/containers.py b/client/ayon_core/tools/sceneinventory/models/containers.py index f841f87c8e..47f74476de 100644 --- a/client/ayon_core/tools/sceneinventory/models/containers.py +++ b/client/ayon_core/tools/sceneinventory/models/containers.py @@ -126,6 +126,7 @@ class RepresentationInfo: product_id, product_name, product_type, + product_type_icon, product_group, version_id, representation_name, @@ -135,6 +136,7 @@ class RepresentationInfo: self.product_id = product_id self.product_name = product_name self.product_type = product_type + self.product_type_icon = product_type_icon self.product_group = product_group self.version_id = version_id self.representation_name = representation_name @@ -153,7 +155,17 @@ class RepresentationInfo: @classmethod def new_invalid(cls): - return cls(None, None, None, None, None, None, None, None) + return cls( + None, + None, + None, + None, + None, + None, + None, + None, + None, + ) class VersionItem: @@ -229,6 +241,9 @@ class ContainersModel: def get_representation_info_items(self, project_name, representation_ids): output = {} missing_repre_ids = set() + icons_mapping = self._controller.get_product_type_icons_mapping( + project_name + ) for repre_id in representation_ids: try: uuid.UUID(repre_id) @@ -253,6 +268,7 @@ class ContainersModel: "product_id": None, "product_name": None, "product_type": None, + "product_type_icon": None, "product_group": None, "version_id": None, "representation_name": None, @@ -265,10 +281,17 @@ class ContainersModel: kwargs["folder_id"] = folder["id"] kwargs["folder_path"] = folder["path"] if product: + product_type = product["productType"] + product_base_type = product.get("productBaseType") + icon = icons_mapping.get_icon( + product_base_type=product_base_type, + product_type=product_type, + ) group = product["attrib"]["productGroup"] kwargs["product_id"] = product["id"] kwargs["product_name"] = product["name"] kwargs["product_type"] = product["productType"] + kwargs["product_type_icon"] = icon kwargs["product_group"] = group if version: kwargs["version_id"] = version["id"] From 31469bfd9a0b7d29b88ce9162cfb297fc1c4aef5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 15 Sep 2025 11:52:37 +0200 Subject: [PATCH 284/319] remove unused import --- client/ayon_core/tools/loader/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/loader/control.py b/client/ayon_core/tools/loader/control.py index c7c182b192..9f159bfb21 100644 --- a/client/ayon_core/tools/loader/control.py +++ b/client/ayon_core/tools/loader/control.py @@ -2,7 +2,7 @@ from __future__ import annotations import logging import uuid -from typing import Optional, Any +from typing import Optional import ayon_api From 7082905e5e25524c16d0bd5a7376eb010d025975 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 15 Sep 2025 12:04:45 +0200 Subject: [PATCH 285/319] use icon color from project anatomy for tasks --- client/ayon_core/tools/common_models/projects.py | 15 ++++++++++++--- client/ayon_core/tools/utils/tasks_widget.py | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/tools/common_models/projects.py b/client/ayon_core/tools/common_models/projects.py index 034947de3a..7a5620b033 100644 --- a/client/ayon_core/tools/common_models/projects.py +++ b/client/ayon_core/tools/common_models/projects.py @@ -2,7 +2,7 @@ from __future__ import annotations import contextlib from abc import ABC, abstractmethod -from typing import Dict, Any +from typing import Any, Optional from dataclasses import dataclass import ayon_api @@ -51,7 +51,7 @@ class StatusItem: self.icon: str = icon self.state: str = state - def to_data(self) -> Dict[str, Any]: + def to_data(self) -> dict[str, Any]: return { "name": self.name, "color": self.color, @@ -125,16 +125,24 @@ class TaskTypeItem: icon (str): Icon name in MaterialIcons ("fiber_new"). """ - def __init__(self, name, short, icon): + def __init__( + self, + name: str, + short: str, + icon: str, + color: Optional[str], + ): self.name = name self.short = short self.icon = icon + self.color = color def to_data(self): return { "name": self.name, "short": self.short, "icon": self.icon, + "color": self.color, } @classmethod @@ -147,6 +155,7 @@ class TaskTypeItem: name=task_type_data["name"], short=task_type_data["shortName"], icon=task_type_data["icon"], + color=task_type_data.get("color"), ) diff --git a/client/ayon_core/tools/utils/tasks_widget.py b/client/ayon_core/tools/utils/tasks_widget.py index 744eb6060a..d77ce1e1f4 100644 --- a/client/ayon_core/tools/utils/tasks_widget.py +++ b/client/ayon_core/tools/utils/tasks_widget.py @@ -234,10 +234,11 @@ class TasksQtModel(QtGui.QStandardItemModel): ) icon = None if task_type_item is not None: + color = task_type_item.color or get_default_entity_icon_color() icon = get_qt_icon({ "type": "material-symbols", "name": task_type_item.icon, - "color": get_default_entity_icon_color() + "color": color, }) if icon is None: From 8979fc7608b81db11740738c17c6f581ae1dca1e Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 15 Sep 2025 13:54:22 +0200 Subject: [PATCH 286/319] elite status name --- client/ayon_core/tools/utils/delegates.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/utils/delegates.py b/client/ayon_core/tools/utils/delegates.py index 1cc18b5722..059fc1da0e 100644 --- a/client/ayon_core/tools/utils/delegates.py +++ b/client/ayon_core/tools/utils/delegates.py @@ -186,8 +186,15 @@ class StatusDelegate(QtWidgets.QStyledItemDelegate): ) fm = QtGui.QFontMetrics(option.font) if text_rect.width() < fm.width(text): - text = self._get_status_short_name(index) - if text_rect.width() < fm.width(text): + short_text = self._get_status_short_name(index) + if short_text: + text = short_text + + text = fm.elidedText( + text, QtCore.Qt.ElideRight, text_rect.width() + ) + # Allow at least one character + if len(text) < 2: text = "" fg_color = self._get_status_color(index) From 00603d05a4014c1871e742d8dee5c12dae1f7166 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 15 Sep 2025 15:17:27 +0200 Subject: [PATCH 287/319] fill task type color in publisher's tasks enum --- .../tools/publisher/widgets/tasks_model.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/tools/publisher/widgets/tasks_model.py b/client/ayon_core/tools/publisher/widgets/tasks_model.py index 8bfa81116a..1803e46c5f 100644 --- a/client/ayon_core/tools/publisher/widgets/tasks_model.py +++ b/client/ayon_core/tools/publisher/widgets/tasks_model.py @@ -146,19 +146,19 @@ class TasksModel(QtGui.QStandardItemModel): self._controller.get_current_project_name() ) } - icon_name_by_task_name = {} + type_item_by_task_name = {} for task_items in task_items_by_folder_path.values(): for task_item in task_items: task_name = task_item.name if ( task_name not in new_task_names - or task_name in icon_name_by_task_name + or task_name in type_item_by_task_name ): continue task_type_name = task_item.task_type task_type_item = task_type_items.get(task_type_name) if task_type_item: - icon_name_by_task_name[task_name] = task_type_item.icon + type_item_by_task_name[task_name] = task_type_item for task_name in new_task_names: item = self._items_by_name.get(task_name) @@ -171,13 +171,18 @@ class TasksModel(QtGui.QStandardItemModel): if not task_name: continue - icon_name = icon_name_by_task_name.get(task_name) - icon = None + icon = icon_name = icon_color = None + task_type_item = type_item_by_task_name.get(task_name) + if task_type_item is not None: + icon_name = task_type_item.icon + icon_color = task_type_item.color if icon_name: + if not icon_color: + icon_color = get_default_entity_icon_color() icon = get_qt_icon({ "type": "material-symbols", "name": icon_name, - "color": get_default_entity_icon_color(), + "color": icon_color, }) if icon is None: icon = default_icon From 216c06437fe2ea50d58a56f5d917f6d962818f28 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Mon, 15 Sep 2025 19:20:10 +0300 Subject: [PATCH 288/319] MK Docs: Update light/dark modes icons --- mkdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 8e4c2663bc..a3b89b5455 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -11,12 +11,12 @@ theme: - media: "(prefers-color-scheme: dark)" scheme: slate toggle: - icon: material/toggle-switch-off-outline + icon: material/weather-sunny name: Switch to light mode - media: "(prefers-color-scheme: light)" scheme: default toggle: - icon: material/toggle-switch + icon: material/weather-night name: Switch to dark mode logo: img/ay-symbol-blackw-full.png favicon: img/favicon.ico From 99c50c3a14a96a5b227a1f27c17191ce8ade0d73 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 16 Sep 2025 11:54:01 +0300 Subject: [PATCH 289/319] move mkdocs_requirements to root location. --- docs/mkdocs_requirements.txt => mkdocs_requirements.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/mkdocs_requirements.txt => mkdocs_requirements.txt (100%) diff --git a/docs/mkdocs_requirements.txt b/mkdocs_requirements.txt similarity index 100% rename from docs/mkdocs_requirements.txt rename to mkdocs_requirements.txt From eaa6727a9d0ae5289961b5b46d9fdf9245e6c93a Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 16 Sep 2025 11:56:00 +0300 Subject: [PATCH 290/319] CI: Re-use `deploy_mkdocs` from ynput/ops-repo-automation --- .github/workflows/deploy_mkdocs.yml | 69 ++++------------------------- 1 file changed, 8 insertions(+), 61 deletions(-) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index 2f46bdc6ad..1e02643a3d 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -1,70 +1,17 @@ name: Deploy MkDocs on: - pull_request: + push: + tags: + - "*" workflow_dispatch: - workflow_call: - inputs: - repo: - type: string - required: true - branch_name: - type: string - required: true - default: "main" - secrets: - token: - required: true - user: - required: true - email: - required: true - -env: - GH_TOKEN: ${{ secrets.token || secrets.YNPUT_BOT_TOKEN }} - GH_USER: ${{ secrets.user || secrets.CI_USER }} - GH_EMAIL: ${{ secrets.email || secrets.CI_EMAIL }} jobs: - verify-repo-secrets: - uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@main + build-mk-docs: + uses: ynput/ops-repo-automation/.github/workflows/deploy_mkdocs.yml@feature/34-add-mk-docs-reusable-workflow with: repo: ${{ github.repository }} secrets: - gh_token: ${{ secrets.token }} - gh_user: ${{ secrets.user }} - gh_email: ${{ secrets.email }} - - deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout ${{ inputs.branch_name}} - uses: actions/checkout@v4 - with: - ref: ${{ inputs.branch_name}} - fetch-depth: 0 - submodules: true - - - name: 🔑 Set Authentication - run: | - git config --global user.name "${{ secrets.user || secrets.CI_USER }}" - git config --global user.email "${{ secrets.email || secrets.CI_EMAIL }}" - - - name: Get current tag - id: git_tag - uses: devops-actions/action-get-tag@v1.0.3 - with: - default: 1.0.0 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.x" - - - name: Install dependencies - run: | - python3 -m pip install -r ./docs/mkdocs_requirements.txt - - - name: Mike deploy ${{ steps.git_tag.outputs.tag }} - run: mike deploy --update-aliases ${{ steps.git_tag.outputs.tag }} latest + YNPUT_BOT_TOKEN: ${{ secrets.YNPUT_BOT_TOKEN }} + CI_USER: ${{ secrets.CI_USER }} + CI_EMAIL: ${{ secrets.CI_EMAIL }} From a46a9e3143998c93d04824d3aa795e8f53b580d8 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 16 Sep 2025 13:04:54 +0300 Subject: [PATCH 291/319] CI: Update Deploy MkDocs to use action from develop branch from ynput/ops-repo-automation --- .github/workflows/deploy_mkdocs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index 1e02643a3d..deafc7b850 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -8,7 +8,8 @@ on: jobs: build-mk-docs: - uses: ynput/ops-repo-automation/.github/workflows/deploy_mkdocs.yml@feature/34-add-mk-docs-reusable-workflow + # FIXME: Update @develop to @main after `ops-repo-automation` release. + uses: ynput/ops-repo-automation/.github/workflows/deploy_mkdocs.yml@develop with: repo: ${{ github.repository }} secrets: From e9e9461415e21c4e87729df3a45d011c408179f2 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:36:51 +0200 Subject: [PATCH 292/319] allow explicit workfile path to be defined --- .../hooks/pre_add_last_workfile_arg.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/client/ayon_core/hooks/pre_add_last_workfile_arg.py b/client/ayon_core/hooks/pre_add_last_workfile_arg.py index c6afaaa083..752302bb20 100644 --- a/client/ayon_core/hooks/pre_add_last_workfile_arg.py +++ b/client/ayon_core/hooks/pre_add_last_workfile_arg.py @@ -38,18 +38,20 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook): launch_types = {LaunchTypes.local} def execute(self): - if not self.data.get("start_last_workfile"): - self.log.info("It is set to not start last workfile on start.") - return + workfile_path = self.data.get("workfile_path") + if not workfile_path: + if not self.data.get("start_last_workfile"): + self.log.info("It is set to not start last workfile on start.") + return - last_workfile = self.data.get("last_workfile_path") - if not last_workfile: - self.log.warning("Last workfile was not collected.") - return + workfile_path = self.data.get("last_workfile_path") + if not workfile_path: + self.log.warning("Last workfile was not collected.") + return - if not os.path.exists(last_workfile): + if not os.path.exists(workfile_path): self.log.info("Current context does not have any workfile yet.") return # Add path to workfile to arguments - self.launch_context.launch_args.append(last_workfile) + self.launch_context.launch_args.append(workfile_path) From 12bf78b3cb20fb35eb4d1c61441896d13dd994d0 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 16 Sep 2025 13:45:35 +0200 Subject: [PATCH 293/319] added workfile selection and actions --- client/ayon_core/pipeline/actions.py | 43 +++++++++++++++ client/ayon_core/tools/launcher/abstract.py | 50 +++++++++++------ client/ayon_core/tools/launcher/control.py | 12 +++- .../tools/launcher/models/actions.py | 55 +++++++++++++++---- .../tools/launcher/models/selection.py | 51 ++++++++++++++--- .../tools/launcher/models/workfiles.py | 5 +- .../tools/launcher/ui/actions_widget.py | 43 +++++++++++---- .../tools/launcher/ui/workfiles_page.py | 13 ++++- 8 files changed, 218 insertions(+), 54 deletions(-) diff --git a/client/ayon_core/pipeline/actions.py b/client/ayon_core/pipeline/actions.py index 860fed5e8b..6892af4252 100644 --- a/client/ayon_core/pipeline/actions.py +++ b/client/ayon_core/pipeline/actions.py @@ -37,16 +37,19 @@ class LauncherActionSelection: project_name, folder_id, task_id, + workfile_id, folder_path=None, task_name=None, project_entity=None, folder_entity=None, task_entity=None, + workfile_entity=None, project_settings=None, ): self._project_name = project_name self._folder_id = folder_id self._task_id = task_id + self._workfile_id = workfile_id self._folder_path = folder_path self._task_name = task_name @@ -54,6 +57,7 @@ class LauncherActionSelection: self._project_entity = project_entity self._folder_entity = folder_entity self._task_entity = task_entity + self._workfile_entity = workfile_entity self._project_settings = project_settings @@ -213,6 +217,15 @@ class LauncherActionSelection: self._task_name = self.task_entity["name"] return self._task_name + def get_workfile_id(self): + """Selected workfile id. + + Returns: + Union[str, None]: Selected workfile id. + + """ + return self._workfile_id + def get_project_entity(self): """Project entity for the selection. @@ -259,6 +272,24 @@ class LauncherActionSelection: ) return self._task_entity + def get_workfile_entity(self): + """Workfile entity for the selection. + + Returns: + Union[dict[str, Any], None]: Workfile entity. + + """ + if ( + self._project_name is None + or self._workfile_id is None + ): + return None + if self._workfile_entity is None: + self._workfile_entity = ayon_api.get_workfile_info_by_id( + self._project_name, self._workfile_id + ) + return self._workfile_entity + def get_project_settings(self): """Project settings for the selection. @@ -305,15 +336,27 @@ class LauncherActionSelection: """ return self._task_id is not None + @property + def is_workfile_selected(self): + """Return whether a task is selected. + + Returns: + bool: Whether a task is selected. + + """ + return self._workfile_id is not None + project_name = property(get_project_name) folder_id = property(get_folder_id) task_id = property(get_task_id) + workfile_id = property(get_workfile_id) folder_path = property(get_folder_path) task_name = property(get_task_name) project_entity = property(get_project_entity) folder_entity = property(get_folder_entity) task_entity = property(get_task_entity) + workfile_entity = property(get_workfile_entity) class LauncherAction(object): diff --git a/client/ayon_core/tools/launcher/abstract.py b/client/ayon_core/tools/launcher/abstract.py index f312504d31..a94500116b 100644 --- a/client/ayon_core/tools/launcher/abstract.py +++ b/client/ayon_core/tools/launcher/abstract.py @@ -21,6 +21,7 @@ class WebactionContext: project_name: str folder_id: str task_id: str + workfile_id: str addon_name: str addon_version: str @@ -34,7 +35,7 @@ class ActionItem: identifier (str): Unique identifier of action item. order (int): Action ordering. label (str): Action label. - variant_label (Union[str, None]): Variant label, full label is + variant_label (Optional[str]): Variant label, full label is concatenated with space. Actions are grouped under single action if it has same 'label' and have set 'variant_label'. full_label (str): Full label, if not set it is generated @@ -59,6 +60,7 @@ class ActionItem: @dataclass class WorkfileItem: + workfile_id: str filename: str exists: bool icon: Optional[str] @@ -103,7 +105,7 @@ class AbstractLauncherBackend(AbstractLauncherCommon): """Project settings for current project. Args: - project_name (Union[str, None]): Project name. + project_name (Optional[str]): Project name. Returns: dict[str, Any]: Project settings. @@ -267,7 +269,7 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): """Selected project name. Returns: - Union[str, None]: Selected project name. + Optional[str]: Selected project name. """ pass @@ -277,7 +279,7 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): """Selected folder id. Returns: - Union[str, None]: Selected folder id. + Optional[str]: Selected folder id. """ pass @@ -287,7 +289,7 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): """Selected task id. Returns: - Union[str, None]: Selected task id. + Optional[str]: Selected task id. """ pass @@ -297,7 +299,7 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): """Selected task name. Returns: - Union[str, None]: Selected task name. + Optional[str]: Selected task name. """ pass @@ -315,7 +317,7 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): } Returns: - dict[str, Union[str, None]]: Selected context. + dict[str, Optional[str]]: Selected context. """ pass @@ -325,7 +327,7 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): """Change selected folder. Args: - project_name (Union[str, None]): Project nameor None if no project + project_name (Optional[str]): Project nameor None if no project is selected. """ @@ -336,7 +338,7 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): """Change selected folder. Args: - folder_id (Union[str, None]): Folder id or None if no folder + folder_id (Optional[str]): Folder id or None if no folder is selected. """ @@ -349,14 +351,24 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): """Change selected task. Args: - task_id (Union[str, None]): Task id or None if no task + task_id (Optional[str]): Task id or None if no task is selected. - task_name (Union[str, None]): Task name or None if no task + task_name (Optional[str]): Task name or None if no task is selected. """ pass + @abstractmethod + def set_selected_workfile(self, workfile_id: Optional[str]): + """Change selected workfile. + + Args: + workfile_id (Optional[str]): Workfile id or None. + + """ + pass + # Actions @abstractmethod def get_action_items( @@ -364,13 +376,15 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): project_name: Optional[str], folder_id: Optional[str], task_id: Optional[str], + workfile_id: Optional[str], ) -> list[ActionItem]: """Get action items for given context. Args: - project_name (Union[str, None]): Project name. - folder_id (Union[str, None]): Folder id. - task_id (Union[str, None]): Task id. + project_name (Optional[str]): Project name. + folder_id (Optional[str]): Folder id. + task_id (Optional[str]): Task id. + workfile_id (Optional[str]): Workfile id. Returns: list[ActionItem]: List of action items that should be shown @@ -386,14 +400,16 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon): project_name: Optional[str], folder_id: Optional[str], task_id: Optional[str], + workfile_id: Optional[str], ): """Trigger action on given context. Args: action_id (str): Action identifier. - project_name (Union[str, None]): Project name. - folder_id (Union[str, None]): Folder id. - task_id (Union[str, None]): Task id. + project_name (Optional[str]): Project name. + folder_id (Optional[str]): Folder id. + task_id (Optional[str]): Task id. + workfile_id (Optional[str]): Task id. """ pass diff --git a/client/ayon_core/tools/launcher/control.py b/client/ayon_core/tools/launcher/control.py index 66afebc247..85b362f9d7 100644 --- a/client/ayon_core/tools/launcher/control.py +++ b/client/ayon_core/tools/launcher/control.py @@ -144,6 +144,9 @@ class BaseLauncherController( def set_selected_task(self, task_id, task_name): self._selection_model.set_selected_task(task_id, task_name) + def set_selected_workfile(self, workfile_id): + self._selection_model.set_selected_workfile(workfile_id) + def get_selected_context(self): return { "project_name": self.get_selected_project_name(), @@ -164,9 +167,12 @@ class BaseLauncherController( ) # Actions - def get_action_items(self, project_name, folder_id, task_id): + def get_action_items( + self, project_name, folder_id, task_id, workfile_id + ): return self._actions_model.get_action_items( - project_name, folder_id, task_id) + project_name, folder_id, task_id, workfile_id + ) def trigger_action( self, @@ -174,12 +180,14 @@ class BaseLauncherController( project_name, folder_id, task_id, + workfile_id, ): self._actions_model.trigger_action( identifier, project_name, folder_id, task_id, + workfile_id, ) def trigger_webaction(self, context, action_label, form_data=None): diff --git a/client/ayon_core/tools/launcher/models/actions.py b/client/ayon_core/tools/launcher/models/actions.py index 5f888effb5..709ae2e9a8 100644 --- a/client/ayon_core/tools/launcher/models/actions.py +++ b/client/ayon_core/tools/launcher/models/actions.py @@ -128,19 +128,28 @@ class ActionsModel: self._get_action_objects() self._controller.emit_event("actions.refresh.finished") - def get_action_items(self, project_name, folder_id, task_id): + def get_action_items( + self, + project_name: Optional[str], + folder_id: Optional[str], + task_id: Optional[str], + workfile_id: Optional[str], + ) -> list[ActionItem]: """Get actions for project. Args: - project_name (Union[str, None]): Project name. - folder_id (Union[str, None]): Folder id. - task_id (Union[str, None]): Task id. + project_name (Optional[str]): Project name. + folder_id (Optional[str]): Folder id. + task_id (Optional[str]): Task id. + workfile_id (Optional[str]): Workfile id. Returns: list[ActionItem]: List of actions. """ - selection = self._prepare_selection(project_name, folder_id, task_id) + selection = self._prepare_selection( + project_name, folder_id, task_id, workfile_id + ) output = [] action_items = self._get_action_items(project_name) for identifier, action in self._get_action_objects().items(): @@ -156,8 +165,11 @@ class ActionsModel: project_name, folder_id, task_id, + workfile_id, ): - selection = self._prepare_selection(project_name, folder_id, task_id) + selection = self._prepare_selection( + project_name, folder_id, task_id, workfile_id + ) failed = False error_message = None action_label = identifier @@ -199,11 +211,15 @@ class ActionsModel: identifier = context.identifier folder_id = context.folder_id task_id = context.task_id + workfile_id = context.workfile_id project_name = context.project_name addon_name = context.addon_name addon_version = context.addon_version - if task_id: + if workfile_id: + entity_type = "workfile" + entity_ids.append(workfile_id) + elif task_id: entity_type = "task" entity_ids.append(task_id) elif folder_id: @@ -269,6 +285,7 @@ class ActionsModel: "project_name": project_name, "folder_id": folder_id, "task_id": task_id, + "workfile_id": workfile_id, "addon_name": addon_name, "addon_version": addon_version, }) @@ -279,7 +296,10 @@ class ActionsModel: def get_action_config_values(self, context: WebactionContext): selection = self._prepare_selection( - context.project_name, context.folder_id, context.task_id + context.project_name, + context.folder_id, + context.task_id, + context.workfile_id, ) if not selection.is_project_selected: return {} @@ -306,7 +326,10 @@ class ActionsModel: def set_action_config_values(self, context, values): selection = self._prepare_selection( - context.project_name, context.folder_id, context.task_id + context.project_name, + context.folder_id, + context.task_id, + context.workfile_id, ) if not selection.is_project_selected: return {} @@ -330,7 +353,9 @@ class ActionsModel: exc_info=True ) - def _prepare_selection(self, project_name, folder_id, task_id): + def _prepare_selection( + self, project_name, folder_id, task_id, workfile_id + ): project_entity = None if project_name: project_entity = self._controller.get_project_entity(project_name) @@ -339,6 +364,7 @@ class ActionsModel: project_name, folder_id, task_id, + workfile_id, project_entity=project_entity, project_settings=project_settings, ) @@ -347,7 +373,12 @@ class ActionsModel: entity_type = None entity_id = None entity_subtypes = [] - if selection.is_task_selected: + if selection.is_workfile_selected: + entity_type = "workfile" + entity_id = selection.workfile_id + entity_subtypes = [] + + elif selection.is_task_selected: entity_type = "task" entity_id = selection.task_entity["id"] entity_subtypes = [selection.task_entity["taskType"]] @@ -392,7 +423,7 @@ class ActionsModel: try: # 'variant' query is supported since AYON backend 1.10.4 - query = urlencode({"variant": self._variant}) + query = urlencode({"variant": self._variant, "mode": "all"}) response = ayon_api.post( f"actions/list?{query}", **request_data ) diff --git a/client/ayon_core/tools/launcher/models/selection.py b/client/ayon_core/tools/launcher/models/selection.py index b156d2084c..9d5ad47d89 100644 --- a/client/ayon_core/tools/launcher/models/selection.py +++ b/client/ayon_core/tools/launcher/models/selection.py @@ -1,26 +1,37 @@ -class LauncherSelectionModel(object): +from __future__ import annotations + +import typing +from typing import Optional + +if typing.TYPE_CHECKING: + from ayon_core.tools.launcher.abstract import AbstractLauncherBackend + + +class LauncherSelectionModel: """Model handling selection changes. Triggering events: - "selection.project.changed" - "selection.folder.changed" - "selection.task.changed" + - "selection.workfile.changed" """ event_source = "launcher.selection.model" - def __init__(self, controller): + def __init__(self, controller: AbstractLauncherBackend) -> None: self._controller = controller self._project_name = None self._folder_id = None self._task_name = None self._task_id = None + self._workfile_id = None - def get_selected_project_name(self): + def get_selected_project_name(self) -> Optional[str]: return self._project_name - def set_selected_project(self, project_name): + def set_selected_project(self, project_name: Optional[str]) -> None: if project_name == self._project_name: return @@ -31,10 +42,10 @@ class LauncherSelectionModel(object): self.event_source ) - def get_selected_folder_id(self): + def get_selected_folder_id(self) -> Optional[str]: return self._folder_id - def set_selected_folder(self, folder_id): + def set_selected_folder(self, folder_id: Optional[str]) -> None: if folder_id == self._folder_id: return @@ -48,13 +59,15 @@ class LauncherSelectionModel(object): self.event_source ) - def get_selected_task_name(self): + def get_selected_task_name(self) -> Optional[str]: return self._task_name - def get_selected_task_id(self): + def get_selected_task_id(self) -> Optional[str]: return self._task_id - def set_selected_task(self, task_id, task_name): + def set_selected_task( + self, task_id: Optional[str], task_name: Optional[str] + ) -> None: if task_id == self._task_id: return @@ -70,3 +83,23 @@ class LauncherSelectionModel(object): }, self.event_source ) + + def get_selected_workfile(self) -> Optional[str]: + return self._workfile_id + + def set_selected_workfile(self, workfile_id: Optional[str]) -> None: + if workfile_id == self._workfile_id: + return + + self._workfile_id = workfile_id + self._controller.emit_event( + "selection.workfile.changed", + { + "project_name": self._project_name, + "folder_id": self._folder_id, + "task_name": self._task_name, + "task_id": self._task_id, + "workfile_id": workfile_id, + }, + self.event_source + ) diff --git a/client/ayon_core/tools/launcher/models/workfiles.py b/client/ayon_core/tools/launcher/models/workfiles.py index 2ba15c1800..649a87353c 100644 --- a/client/ayon_core/tools/launcher/models/workfiles.py +++ b/client/ayon_core/tools/launcher/models/workfiles.py @@ -44,7 +44,7 @@ class WorkfilesModel: anatomy = Anatomy(project_name, project_entity=project_entity) items = [] for workfile_entity in ayon_api.get_workfiles_info( - project_name, task_ids={task_id}, fields={"path", "data"} + project_name, task_ids={task_id}, fields={"id", "path", "data"} ): rootless_path = workfile_entity["path"] exists = False @@ -61,7 +61,8 @@ class WorkfilesModel: version = workfile_data.get("version") items.append(WorkfileItem( - os.path.basename(rootless_path), + workfile_id=workfile_entity["id"], + filename=os.path.basename(rootless_path), exists=exists, icon=self._get_host_icon(host_name), version=version, diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 51cb8e73bc..67a8bca787 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -136,6 +136,10 @@ class ActionsQtModel(QtGui.QStandardItemModel): "selection.task.changed", self._on_selection_task_changed, ) + controller.register_event_callback( + "selection.workfile.changed", + self._on_selection_workfile_changed, + ) self._controller = controller @@ -146,6 +150,7 @@ class ActionsQtModel(QtGui.QStandardItemModel): self._selected_project_name = None self._selected_folder_id = None self._selected_task_id = None + self._selected_workfile_id = None def get_selected_project_name(self): return self._selected_project_name @@ -156,6 +161,9 @@ class ActionsQtModel(QtGui.QStandardItemModel): def get_selected_task_id(self): return self._selected_task_id + def get_selected_workfile_id(self): + return self._selected_workfile_id + def get_group_items(self, action_id): return self._groups_by_id[action_id] @@ -194,6 +202,7 @@ class ActionsQtModel(QtGui.QStandardItemModel): self._selected_project_name, self._selected_folder_id, self._selected_task_id, + self._selected_workfile_id, ) if not items: self._clear_items() @@ -286,18 +295,28 @@ class ActionsQtModel(QtGui.QStandardItemModel): self._selected_project_name = event["project_name"] self._selected_folder_id = None self._selected_task_id = None + self._selected_workfile_id = None self.refresh() def _on_selection_folder_changed(self, event): self._selected_project_name = event["project_name"] self._selected_folder_id = event["folder_id"] self._selected_task_id = None + self._selected_workfile_id = None self.refresh() def _on_selection_task_changed(self, event): self._selected_project_name = event["project_name"] self._selected_folder_id = event["folder_id"] self._selected_task_id = event["task_id"] + self._selected_workfile_id = None + self.refresh() + + def _on_selection_workfile_changed(self, event): + self._selected_project_name = event["project_name"] + self._selected_folder_id = event["folder_id"] + self._selected_task_id = event["task_id"] + self._selected_workfile_id = event["workfile_id"] self.refresh() @@ -578,9 +597,6 @@ class ActionMenuPopup(QtWidgets.QWidget): if not index or not index.isValid(): return - if not index.data(ACTION_HAS_CONFIGS_ROLE): - return - action_id = index.data(ACTION_ID_ROLE) self.action_triggered.emit(action_id) @@ -970,6 +986,7 @@ class ActionsWidget(QtWidgets.QWidget): event["project_name"], event["folder_id"], event["task_id"], + event["workfile_id"], event["addon_name"], event["addon_version"], ), @@ -1050,24 +1067,26 @@ class ActionsWidget(QtWidgets.QWidget): project_name = self._model.get_selected_project_name() folder_id = self._model.get_selected_folder_id() task_id = self._model.get_selected_task_id() + workfile_id = self._model.get_selected_workfile_id() action_item = self._model.get_action_item_by_id(action_id) if action_item.action_type == "webaction": action_item = self._model.get_action_item_by_id(action_id) context = WebactionContext( - action_id, - project_name, - folder_id, - task_id, - action_item.addon_name, - action_item.addon_version + identifier=action_id, + project_name=project_name, + folder_id=folder_id, + task_id=task_id, + workfile_id=workfile_id, + addon_name=action_item.addon_name, + addon_version=action_item.addon_version, ) self._controller.trigger_webaction( context, action_item.full_label ) else: self._controller.trigger_action( - action_id, project_name, folder_id, task_id + action_id, project_name, folder_id, task_id, workfile_id ) if index is None: @@ -1087,11 +1106,13 @@ class ActionsWidget(QtWidgets.QWidget): project_name = self._model.get_selected_project_name() folder_id = self._model.get_selected_folder_id() task_id = self._model.get_selected_task_id() + workfile_id = self._model.get_selected_workfile_id() context = WebactionContext( - action_id, + identifier=action_id, project_name=project_name, folder_id=folder_id, task_id=task_id, + workfile_id=workfile_id, addon_name=action_item.addon_name, addon_version=action_item.addon_version, ) diff --git a/client/ayon_core/tools/launcher/ui/workfiles_page.py b/client/ayon_core/tools/launcher/ui/workfiles_page.py index 0401183080..1ea223031e 100644 --- a/client/ayon_core/tools/launcher/ui/workfiles_page.py +++ b/client/ayon_core/tools/launcher/ui/workfiles_page.py @@ -7,6 +7,7 @@ from ayon_core.tools.utils import get_qt_icon from ayon_core.tools.launcher.abstract import AbstractLauncherFrontEnd VERSION_ROLE = QtCore.Qt.UserRole + 1 +WORKFILE_ID_ROLE = QtCore.Qt.UserRole + 2 class WorkfilesModel(QtGui.QStandardItemModel): @@ -53,9 +54,10 @@ class WorkfilesModel(QtGui.QStandardItemModel): item = QtGui.QStandardItem(workfile_item.filename) item.setData(icon, QtCore.Qt.DecorationRole) item.setData(workfile_item.version, VERSION_ROLE) + item.setData(workfile_item.workfile_id, WORKFILE_ID_ROLE) flags = QtCore.Qt.NoItemFlags if workfile_item.exists: - flags = QtCore.Qt.ItemIsEnabled + flags = QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable item.setFlags(flags) new_items.append(item) @@ -150,6 +152,9 @@ class WorkfilesPage(QtWidgets.QWidget): layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(workfiles_view, 1) + workfiles_view.selectionModel().selectionChanged.connect( + self._on_selection_changed + ) workfiles_model.refreshed.connect(self._on_refresh) self._controller = controller @@ -162,3 +167,9 @@ class WorkfilesPage(QtWidgets.QWidget): def _on_refresh(self) -> None: self._workfiles_proxy.sort(0, QtCore.Qt.DescendingOrder) + + def _on_selection_changed(self, selected, _deselected) -> None: + workfile_id = None + for index in selected.indexes(): + workfile_id = index.data(WORKFILE_ID_ROLE) + self._controller.set_selected_workfile(workfile_id) From 5f68e8107e729eafabf111b5d04873b21af869d0 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 17 Sep 2025 17:26:06 +0200 Subject: [PATCH 294/319] allow to implement 'get_app_information' by host --- client/ayon_core/host/__init__.py | 3 ++- client/ayon_core/host/abstract.py | 24 ++++++++++++++++++++++++ client/ayon_core/host/host.py | 14 +++++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/host/__init__.py b/client/ayon_core/host/__init__.py index 950c14564e..7d5918b0ac 100644 --- a/client/ayon_core/host/__init__.py +++ b/client/ayon_core/host/__init__.py @@ -1,5 +1,5 @@ from .constants import ContextChangeReason -from .abstract import AbstractHost +from .abstract import AbstractHost, ApplicationInformation from .host import ( HostBase, ContextChangeData, @@ -21,6 +21,7 @@ __all__ = ( "ContextChangeReason", "AbstractHost", + "ApplicationInformation", "HostBase", "ContextChangeData", diff --git a/client/ayon_core/host/abstract.py b/client/ayon_core/host/abstract.py index 26771aaffa..7b4bb5b791 100644 --- a/client/ayon_core/host/abstract.py +++ b/client/ayon_core/host/abstract.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging from abc import ABC, abstractmethod +from dataclasses import dataclass import typing from typing import Optional, Any @@ -13,6 +14,19 @@ if typing.TYPE_CHECKING: from .typing import HostContextData +@dataclass +class ApplicationInformation: + """Application information. + + Attributes: + app_name (Optional[str]): Application name. e.g. Maya, NukeX, Nuke + app_version (Optional[str]): Application version. e.g. 15.2.1 + + """ + app_name: Optional[str] = None + app_version: Optional[str] = None + + class AbstractHost(ABC): """Abstract definition of host implementation.""" @property @@ -26,6 +40,16 @@ class AbstractHost(ABC): """Host name.""" pass + @abstractmethod + def get_app_information(self) -> ApplicationInformation: + """Information about the application where host is running. + + Returns: + ApplicationInformation: Application information. + + """ + pass + @abstractmethod def get_current_context(self) -> HostContextData: """Get the current context of the host. diff --git a/client/ayon_core/host/host.py b/client/ayon_core/host/host.py index 28cb6b0a09..7d6d3ddbe4 100644 --- a/client/ayon_core/host/host.py +++ b/client/ayon_core/host/host.py @@ -12,7 +12,7 @@ import ayon_api from ayon_core.lib import emit_event from .constants import ContextChangeReason -from .abstract import AbstractHost +from .abstract import AbstractHost, ApplicationInformation if typing.TYPE_CHECKING: from ayon_core.pipeline import Anatomy @@ -96,6 +96,18 @@ class HostBase(AbstractHost): pass + def get_app_information(self) -> ApplicationInformation: + """Running application information. + + Host integration should override this method and return correct + information. + + Returns: + ApplicationInformation: Application information. + + """ + return ApplicationInformation() + def install(self): """Install host specific functionality. From 154d8fd0876e1e0e6669c3a3a761ca966ef563a1 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 17 Sep 2025 17:30:17 +0200 Subject: [PATCH 295/319] allow to pass 'data' to save workfile info --- client/ayon_core/pipeline/workfile/utils.py | 72 ++++++++++++--------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index 6666853998..d22b7a1635 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -10,6 +10,7 @@ from ayon_api.operations import OperationsSession from ayon_core.lib import filter_profiles, get_ayon_username from ayon_core.settings import get_project_settings +from ayon_core.host import ApplicationInformation from ayon_core.host.interfaces import ( SaveWorkfileOptionalData, ListWorkfilesOptionalData, @@ -207,6 +208,7 @@ def save_workfile_info( comment: Optional[str] = None, description: Optional[str] = None, username: Optional[str] = None, + data: Optional[dict[str, Any]] = None, workfile_entities: Optional[list[dict[str, Any]]] = None, ) -> dict[str, Any]: """Save workfile info entity for a workfile path. @@ -221,6 +223,8 @@ def save_workfile_info( description (Optional[str]): Workfile description. username (Optional[str]): Username of user who saves the workfile. If not provided, current user is used. + app_info (Optional[ApplicationInformation]): Application information. + data (Optional[dict[str, Any]]): Additional workfile entity data. workfile_entities (Optional[list[dict[str, Any]]]): Pre-fetched workfile entities related to task. @@ -246,6 +250,18 @@ def save_workfile_info( if username is None: username = get_ayon_username() + attrib = {} + extension = os.path.splitext(rootless_path)[1] + for key, value in ( + ("extension", extension), + ("description", description), + ): + if value is not None: + attrib[key] = value + + if data is None: + data = {} + if not workfile_entity: return _create_workfile_info_entity( project_name, @@ -255,34 +271,38 @@ def save_workfile_info( username, version, comment, - description, + attrib, + data, ) - data = { - key: value - for key, value in ( - ("host_name", host_name), - ("version", version), - ("comment", comment), - ) - if value is not None - } - - old_data = workfile_entity["data"] + for key, value in ( + ("host_name", host_name), + ("version", version), + ("comment", comment), + ): + if value is not None: + data[key] = value changed_data = {} + old_data = workfile_entity["data"] for key, value in data.items(): if key not in old_data or old_data[key] != value: changed_data[key] = value + workfile_entity["data"][key] = value + + changed_attrib = {} + old_attrib = workfile_entity["attrib"] + for key, value in attrib.items(): + if key not in old_attrib or old_attrib[key] != value: + changed_attrib[key] = value + workfile_entity["attrib"][key] = value update_data = {} if changed_data: update_data["data"] = changed_data - old_description = workfile_entity["attrib"].get("description") - if description is not None and old_description != description: - update_data["attrib"] = {"description": description} - workfile_entity["attrib"]["description"] = description + if changed_attrib: + update_data["attrib"] = changed_attrib # Automatically fix 'createdBy' and 'updatedBy' fields # NOTE both fields were not automatically filled by server @@ -749,7 +769,8 @@ def _create_workfile_info_entity( username: str, version: Optional[int], comment: Optional[str], - description: Optional[str], + attrib: dict[str, Any], + data: dict[str, Any], ) -> dict[str, Any]: """Create workfile entity data. @@ -761,27 +782,18 @@ def _create_workfile_info_entity( username (str): Username. version (Optional[int]): Workfile version. comment (Optional[str]): Workfile comment. - description (Optional[str]): Workfile description. + attrib (dict[str, Any]): Workfile entity attributes. + data (dict[str, Any]): Workfile entity data. Returns: dict[str, Any]: Created workfile entity data. """ - extension = os.path.splitext(rootless_path)[1] - - attrib = {} - for key, value in ( - ("extension", extension), - ("description", description), - ): - if value is not None: - attrib[key] = value - - data = { + data.update({ "host_name": host_name, "version": version, "comment": comment, - } + }) workfile_info = { "id": uuid.uuid4().hex, From 27c1c30f2e94830e68b8f044fb23a1ff8fe4e424 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 17 Sep 2025 17:30:35 +0200 Subject: [PATCH 296/319] add app information to workfile data --- client/ayon_core/host/interfaces/workfiles.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index 93aad4c117..69b902c9e2 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -1554,6 +1554,22 @@ class IWorkfileHost(AbstractHost): if platform.system().lower() == "windows": rootless_path = rootless_path.replace("\\", "/") + # Get application information + app_info = self.get_app_information() + data = {} + if app_info.app_name: + data["app_name"] = app_info.app_name + if app_info.app_version: + data["app_version"] = app_info.app_version + + # Use app group and app variant from applications addon (if available) + app_addon_name = os.environ.get("AYON_APP_NAME") or "" + app_addon_name_parts = app_addon_name.split("/") + if len(app_addon_name_parts) == 2: + app_group, app_variant = app_addon_name_parts + data["app_group"] = app_group + data["app_variant"] = app_variant + workfile_info = save_workfile_info( project_name, save_workfile_context.task_entity["id"], @@ -1562,6 +1578,7 @@ class IWorkfileHost(AbstractHost): version, comment, description, + data=data, workfile_entities=save_workfile_context.workfile_entities, ) return workfile_info From eb3428e37169c20f8af8d9ae53cb75ab40f6a918 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 17 Sep 2025 18:27:49 +0200 Subject: [PATCH 297/319] remove unused import --- client/ayon_core/pipeline/workfile/utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index d22b7a1635..c2b6fad660 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -10,7 +10,6 @@ from ayon_api.operations import OperationsSession from ayon_core.lib import filter_profiles, get_ayon_username from ayon_core.settings import get_project_settings -from ayon_core.host import ApplicationInformation from ayon_core.host.interfaces import ( SaveWorkfileOptionalData, ListWorkfilesOptionalData, @@ -223,7 +222,6 @@ def save_workfile_info( description (Optional[str]): Workfile description. username (Optional[str]): Username of user who saves the workfile. If not provided, current user is used. - app_info (Optional[ApplicationInformation]): Application information. data (Optional[dict[str, Any]]): Additional workfile entity data. workfile_entities (Optional[list[dict[str, Any]]]): Pre-fetched workfile entities related to task. From e416e3218968ea876202bb8ddd196d24f465aa50 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 18 Sep 2025 10:13:43 +0200 Subject: [PATCH 298/319] use f-string --- client/ayon_core/host/interfaces/workfiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index 69b902c9e2..b908e7167e 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -55,7 +55,7 @@ class _WorkfileOptionalData: ): if kwargs: cls_name = self.__class__.__name__ - keys = ", ".join(['"{}"'.format(k) for k in kwargs.keys()]) + keys = ", ".join([f'"{k}"' for k in kwargs.keys()]) warnings.warn( f"Unknown keywords passed to {cls_name}: {keys}", ) From 9d55c1e9021e36ff32f8305dc4a196fb37d2a906 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 18 Sep 2025 11:44:18 +0200 Subject: [PATCH 299/319] keep ayon application full name as is --- client/ayon_core/host/interfaces/workfiles.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index b908e7167e..4f7926e239 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -1563,12 +1563,13 @@ class IWorkfileHost(AbstractHost): data["app_version"] = app_info.app_version # Use app group and app variant from applications addon (if available) - app_addon_name = os.environ.get("AYON_APP_NAME") or "" - app_addon_name_parts = app_addon_name.split("/") - if len(app_addon_name_parts) == 2: - app_group, app_variant = app_addon_name_parts - data["app_group"] = app_group - data["app_variant"] = app_variant + app_addon_name = os.environ.get("AYON_APP_NAME") + if app_addon_name: + data["app_addon_name"] = app_addon_name + + app_addon_tools = os.environ.get("AYON_APP_TOOLS") + if app_addon_tools: + data["app_addon_tools"] = app_addon_tools.split(";") workfile_info = save_workfile_info( project_name, From a1b863e6a67f222948108ed54383b4872a76946d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 22 Sep 2025 11:58:05 +0200 Subject: [PATCH 300/319] use ayon prefix for ayon app name and tools --- client/ayon_core/host/interfaces/workfiles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index 4f7926e239..587962351d 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -1565,11 +1565,11 @@ class IWorkfileHost(AbstractHost): # Use app group and app variant from applications addon (if available) app_addon_name = os.environ.get("AYON_APP_NAME") if app_addon_name: - data["app_addon_name"] = app_addon_name + data["ayon_app_name"] = app_addon_name app_addon_tools = os.environ.get("AYON_APP_TOOLS") if app_addon_tools: - data["app_addon_tools"] = app_addon_tools.split(";") + data["ayon_app_tools"] = app_addon_tools.split(";") workfile_info = save_workfile_info( project_name, From ff269b7bd056de13b42db6d2b2b279244244dd0a Mon Sep 17 00:00:00 2001 From: Ynbot Date: Mon, 22 Sep 2025 12:23:41 +0000 Subject: [PATCH 301/319] [Automated] Add generated package files from main --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 9ca5e1bc30..9224326169 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.6.0+dev" +__version__ = "1.6.1" diff --git a/package.py b/package.py index e430524dd5..91e56f0838 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.6.0+dev" +version = "1.6.1" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 9a62a408ba..6ba1dcb8f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.6.0+dev" +version = "1.6.1" description = "" authors = ["Ynput Team "] readme = "README.md" From c0e6772097040224e79e01c88f126c3f6a0a5f7d Mon Sep 17 00:00:00 2001 From: Ynbot Date: Mon, 22 Sep 2025 12:24:14 +0000 Subject: [PATCH 302/319] [Automated] Update version in package.py for develop --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 9224326169..c7a72e0b43 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.6.1" +__version__ = "1.6.1+dev" diff --git a/package.py b/package.py index 91e56f0838..f6853d8816 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.6.1" +version = "1.6.1+dev" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 6ba1dcb8f3..18f2047a92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.6.1" +version = "1.6.1+dev" description = "" authors = ["Ynput Team "] readme = "README.md" From c5037123481fa9949f543cb6f6a14a5e8c456656 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 22 Sep 2025 12:25:06 +0000 Subject: [PATCH 303/319] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 24c2b568b3..6b75179e7b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to AYON Tray options: + - 1.6.1 - 1.6.0 - 1.5.3 - 1.5.2 From eabd6b601f3ce8e980a053714548d9f9d3466bc5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:11:02 +0200 Subject: [PATCH 304/319] small changes or logic order --- client/ayon_core/pipeline/load/utils.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/client/ayon_core/pipeline/load/utils.py b/client/ayon_core/pipeline/load/utils.py index 836fc5e096..de79ad4d52 100644 --- a/client/ayon_core/pipeline/load/utils.py +++ b/client/ayon_core/pipeline/load/utils.py @@ -1042,13 +1042,13 @@ def filter_containers(containers, project_name): hero=True, fields={"id", "productId", "version"} ) - verisons_by_id = {} + versions_by_id = {} versions_by_product_id = collections.defaultdict(list) hero_version_ids = set() for version_entity in version_entities: version_id = version_entity["id"] # Store versions by their ids - verisons_by_id[version_id] = version_entity + versions_by_id[version_id] = version_entity # There's no need to query products for hero versions # - they are considered as latest? if version_entity["version"] < 0: @@ -1083,24 +1083,23 @@ def filter_containers(containers, project_name): repre_entity = repre_entities_by_id.get(repre_id) if not repre_entity: - log.debug(( - "Container '{}' has an invalid representation." + log.debug( + f"Container '{container_name}' has an invalid representation." " It is missing in the database." - ).format(container_name)) + ) not_found_containers.append(container) continue version_id = repre_entity["versionId"] - if version_id in outdated_version_ids: - outdated_containers.append(container) - - elif version_id not in verisons_by_id: - log.debug(( - "Representation on container '{}' has an invalid version." - " It is missing in the database." - ).format(container_name)) + if version_id not in versions_by_id: + log.debug( + f"Representation on container '{container_name}' has an" + " invalid version. It is missing in the database." + ) not_found_containers.append(container) + elif version_id in outdated_version_ids: + outdated_containers.append(container) else: uptodate_containers.append(container) From 0748d659d71291f5ec326086201891640c4ec265 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:11:33 +0200 Subject: [PATCH 305/319] do not consider locked containers in 'get_outdated_containers' as outdated --- client/ayon_core/pipeline/load/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/load/utils.py b/client/ayon_core/pipeline/load/utils.py index de79ad4d52..7dab889ec5 100644 --- a/client/ayon_core/pipeline/load/utils.py +++ b/client/ayon_core/pipeline/load/utils.py @@ -964,7 +964,12 @@ def get_outdated_containers(host=None, project_name=None): containers = host.get_containers() else: containers = host.ls() - return filter_containers(containers, project_name).outdated + outdated_containers = [] + for container in filter_containers(containers, project_name).outdated: + if container.get("locked_version") is True: + continue + outdated_containers.append(container) + return outdated_containers def _is_valid_representation_id(repre_id: Any) -> bool: From ace6a84f5e9759f83a7f915fafb0f5ee1830b4a1 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:12:03 +0200 Subject: [PATCH 306/319] look for locked version in container --- client/ayon_core/tools/sceneinventory/models/containers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/sceneinventory/models/containers.py b/client/ayon_core/tools/sceneinventory/models/containers.py index 47f74476de..0e19f381cd 100644 --- a/client/ayon_core/tools/sceneinventory/models/containers.py +++ b/client/ayon_core/tools/sceneinventory/models/containers.py @@ -95,7 +95,8 @@ class ContainerItem: namespace, object_name, item_id, - project_name + project_name, + version_locked, ): self.representation_id = representation_id self.loader_name = loader_name @@ -103,6 +104,7 @@ class ContainerItem: self.namespace = namespace self.item_id = item_id self.project_name = project_name + self.version_locked = version_locked @classmethod def from_container_data(cls, current_project_name, container): @@ -114,7 +116,8 @@ class ContainerItem: item_id=uuid.uuid4().hex, project_name=container.get( "project_name", current_project_name - ) + ), + version_locked=container.get("version_locked", False), ) From 1f41e03fe00c57fcb341d6c82677184e8e80a1a4 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:12:26 +0200 Subject: [PATCH 307/319] store the information to the model item --- client/ayon_core/tools/sceneinventory/model.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/ayon_core/tools/sceneinventory/model.py b/client/ayon_core/tools/sceneinventory/model.py index 9977acea21..27211165bf 100644 --- a/client/ayon_core/tools/sceneinventory/model.py +++ b/client/ayon_core/tools/sceneinventory/model.py @@ -37,6 +37,7 @@ REMOTE_SITE_ICON_ROLE = QtCore.Qt.UserRole + 23 # containers inbetween refresh. ITEM_UNIQUE_NAME_ROLE = QtCore.Qt.UserRole + 24 PROJECT_NAME_ROLE = QtCore.Qt.UserRole + 25 +CONTAINER_VERSION_LOCKED_ROLE = QtCore.Qt.UserRole + 26 class InventoryModel(QtGui.QStandardItemModel): @@ -291,6 +292,10 @@ class InventoryModel(QtGui.QStandardItemModel): item.setData(container_item.object_name, OBJECT_NAME_ROLE) item.setData(True, IS_CONTAINER_ITEM_ROLE) item.setData(unique_name, ITEM_UNIQUE_NAME_ROLE) + item.setData( + container_item.version_locked, + CONTAINER_VERSION_LOCKED_ROLE + ) container_model_items.append(item) progress = progress_by_id[repre_id] From 2fbb6c279be98a6d7c8c110db53d0c53a8f51b04 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:13:11 +0200 Subject: [PATCH 308/319] allow more options for icons --- client/ayon_core/tools/sceneinventory/view.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/sceneinventory/view.py b/client/ayon_core/tools/sceneinventory/view.py index fdd1bdbe75..ead10f9e62 100644 --- a/client/ayon_core/tools/sceneinventory/view.py +++ b/client/ayon_core/tools/sceneinventory/view.py @@ -524,7 +524,15 @@ class SceneInventoryView(QtWidgets.QTreeView): submenu = QtWidgets.QMenu("Actions", self) for action in custom_actions: color = action.color or DEFAULT_COLOR - icon = qtawesome.icon("fa.%s" % action.icon, color=color) + icon_def = action.icon + if not isinstance(action.icon, dict): + icon_def = { + "type": "awesome-font", + "name": icon_def, + "color": color, + } + icon = get_qt_icon(icon_def) + # icon = qtawesome.icon("fa.%s" % action.icon, color=color) action_item = QtWidgets.QAction(icon, action.label, submenu) action_item.triggered.connect( partial( From d96e8087ec63676be751b8618d79c3ea7a5c2a03 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:13:22 +0200 Subject: [PATCH 309/319] draw a lock next to version if is locked --- .../tools/sceneinventory/delegates.py | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/sceneinventory/delegates.py b/client/ayon_core/tools/sceneinventory/delegates.py index 6f91587613..9bc4294fda 100644 --- a/client/ayon_core/tools/sceneinventory/delegates.py +++ b/client/ayon_core/tools/sceneinventory/delegates.py @@ -1,10 +1,14 @@ from qtpy import QtWidgets, QtCore, QtGui -from .model import VERSION_LABEL_ROLE +from ayon_core.tools.utils import get_qt_icon + +from .model import VERSION_LABEL_ROLE, CONTAINER_VERSION_LOCKED_ROLE class VersionDelegate(QtWidgets.QStyledItemDelegate): """A delegate that display version integer formatted as version string.""" + _locked_icon = None + def paint(self, painter, option, index): fg_color = index.data(QtCore.Qt.ForegroundRole) if fg_color: @@ -45,10 +49,35 @@ class VersionDelegate(QtWidgets.QStyledItemDelegate): QtWidgets.QStyle.PM_FocusFrameHMargin, option, option.widget ) + 1 + text_rect_f = text_rect.adjusted( + text_margin, 0, - text_margin, 0 + ) + painter.drawText( - text_rect.adjusted(text_margin, 0, - text_margin, 0), + text_rect_f, option.displayAlignment, text ) + if index.data(CONTAINER_VERSION_LOCKED_ROLE) is True: + icon = self._get_locked_icon() + size = max(text_rect_f.height() // 2, 16) + margin = (text_rect_f.height() - size) // 2 + + icon_rect = QtCore.QRect( + text_rect_f.right() - size, + text_rect_f.top() + margin, + size, + size + ) + icon.paint(painter, icon_rect) painter.restore() + + def _get_locked_icon(cls): + if cls._locked_icon is None: + cls._locked_icon = get_qt_icon({ + "type": "material-symbols", + "name": "lock", + "color": "white", + }) + return cls._locked_icon From bb64f3c2a5e9e2f36111d722b4e677334c388e26 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:13:41 +0200 Subject: [PATCH 310/319] make sure 'data_changed' is triggered --- client/ayon_core/tools/sceneinventory/view.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/tools/sceneinventory/view.py b/client/ayon_core/tools/sceneinventory/view.py index ead10f9e62..b1e378f343 100644 --- a/client/ayon_core/tools/sceneinventory/view.py +++ b/client/ayon_core/tools/sceneinventory/view.py @@ -17,6 +17,7 @@ from ayon_core.tools.utils.lib import ( format_version, preserve_expanded_rows, preserve_selection, + get_qt_icon, ) from ayon_core.tools.utils.delegates import StatusDelegate @@ -46,7 +47,7 @@ class SceneInventoryView(QtWidgets.QTreeView): hierarchy_view_changed = QtCore.Signal(bool) def __init__(self, controller, parent): - super(SceneInventoryView, self).__init__(parent=parent) + super().__init__(parent=parent) # view settings self.setIndentation(12) @@ -623,17 +624,20 @@ class SceneInventoryView(QtWidgets.QTreeView): containers_by_id = self._controller.get_containers_by_item_ids( item_ids ) - result = action.process(list(containers_by_id.values())) - if result: - self.data_changed.emit() + try: + result = action.process(list(containers_by_id.values())) + if not result: + pass - if isinstance(result, (list, set)): + elif isinstance(result, (list, set)): self._select_items_by_action(result) - if isinstance(result, dict): + elif isinstance(result, dict): self._select_items_by_action( result["objectNames"], result["options"] ) + finally: + self.data_changed.emit() def _select_items_by_action(self, object_names, options=None): """Select view items by the result of action From b6feefa19a7ebc50963d09637f57adf79d8fedbe Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 23 Sep 2025 11:54:29 +0200 Subject: [PATCH 311/319] use Logger as log attribute for loader plugin --- client/ayon_core/pipeline/load/plugins.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/pipeline/load/plugins.py b/client/ayon_core/pipeline/load/plugins.py index 48e860e834..ed963110c6 100644 --- a/client/ayon_core/pipeline/load/plugins.py +++ b/client/ayon_core/pipeline/load/plugins.py @@ -2,10 +2,10 @@ from __future__ import annotations from abc import abstractmethod -import logging import os from typing import Any, Optional, Type +from ayon_core.lib import Logger from ayon_core.pipeline.plugin_discover import ( deregister_plugin, deregister_plugin_path, @@ -31,8 +31,7 @@ class LoaderPlugin(list): options = [] - log = logging.getLogger("ProductLoader") - log.propagate = True + log = Logger.get_logger("ProductLoader") @classmethod def apply_settings(cls, project_settings): From 2656e0c7d860a1468900c5bf2a528e39a11fbe90 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 23 Sep 2025 12:11:41 +0200 Subject: [PATCH 312/319] remove commented line Co-authored-by: Roy Nieterau --- client/ayon_core/tools/sceneinventory/view.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/sceneinventory/view.py b/client/ayon_core/tools/sceneinventory/view.py index b1e378f343..6a825a2ca4 100644 --- a/client/ayon_core/tools/sceneinventory/view.py +++ b/client/ayon_core/tools/sceneinventory/view.py @@ -533,7 +533,6 @@ class SceneInventoryView(QtWidgets.QTreeView): "color": color, } icon = get_qt_icon(icon_def) - # icon = qtawesome.icon("fa.%s" % action.icon, color=color) action_item = QtWidgets.QAction(icon, action.label, submenu) action_item.triggered.connect( partial( From 0122686522aad4dfa8baf144bb8e06bc83fcf7be Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 23 Sep 2025 12:39:32 +0200 Subject: [PATCH 313/319] allow to ignore locked versions --- client/ayon_core/pipeline/load/utils.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/load/utils.py b/client/ayon_core/pipeline/load/utils.py index 7dab889ec5..6b751dec30 100644 --- a/client/ayon_core/pipeline/load/utils.py +++ b/client/ayon_core/pipeline/load/utils.py @@ -942,7 +942,11 @@ def any_outdated_containers(host=None, project_name=None): return False -def get_outdated_containers(host=None, project_name=None): +def get_outdated_containers( + host=None, + project_name=None, + ignore_locked_versions: bool = False, +): """Collect outdated containers from host scene. Currently registered host and project in global session are used if @@ -951,6 +955,8 @@ def get_outdated_containers(host=None, project_name=None): Args: host (ModuleType): Host implementation with 'ls' function available. project_name (str): Name of project in which context we are. + ignore_locked_versions (bool): Locked versions are ignored. + """ from ayon_core.pipeline import registered_host, get_current_project_name @@ -964,9 +970,13 @@ def get_outdated_containers(host=None, project_name=None): containers = host.get_containers() else: containers = host.ls() + outdated_containers = [] for container in filter_containers(containers, project_name).outdated: - if container.get("locked_version") is True: + if ( + not ignore_locked_versions + and container.get("locked_version") is True + ): continue outdated_containers.append(container) return outdated_containers From 88db0b46e83bbddb1a112af2947715172986d45a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 23 Sep 2025 12:39:48 +0200 Subject: [PATCH 314/319] added typehints --- client/ayon_core/pipeline/load/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/pipeline/load/utils.py b/client/ayon_core/pipeline/load/utils.py index 6b751dec30..0cfe004572 100644 --- a/client/ayon_core/pipeline/load/utils.py +++ b/client/ayon_core/pipeline/load/utils.py @@ -9,7 +9,7 @@ from typing import Optional, Union, Any import ayon_api -from ayon_core.host import ILoadHost +from ayon_core.host import ILoadHost, AbstractHost from ayon_core.lib import ( StringTemplate, TemplateUnsolved, @@ -943,8 +943,8 @@ def any_outdated_containers(host=None, project_name=None): def get_outdated_containers( - host=None, - project_name=None, + host: Optional[AbstractHost] = None, + project_name: Optional[str] = None, ignore_locked_versions: bool = False, ): """Collect outdated containers from host scene. @@ -953,8 +953,8 @@ def get_outdated_containers( arguments are not passed. Args: - host (ModuleType): Host implementation with 'ls' function available. - project_name (str): Name of project in which context we are. + host (Optional[AbstractHost]): Host implementation. + project_name (Optional[str]): Name of project in which context we are. ignore_locked_versions (bool): Locked versions are ignored. """ @@ -1008,8 +1008,8 @@ def filter_containers(containers, project_name): Returns: ContainersFilterResult: Named tuple with 'latest', 'outdated', 'invalid' and 'not_found' containers. - """ + """ # Make sure containers is list that won't change containers = list(containers) From 740f0276e25b3ec9130ad3346c04d3cb4bda54c9 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 23 Sep 2025 12:39:59 +0200 Subject: [PATCH 315/319] add a todo to 'filter_containers' --- client/ayon_core/pipeline/load/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/ayon_core/pipeline/load/utils.py b/client/ayon_core/pipeline/load/utils.py index 0cfe004572..a111444d48 100644 --- a/client/ayon_core/pipeline/load/utils.py +++ b/client/ayon_core/pipeline/load/utils.py @@ -1000,6 +1000,9 @@ def filter_containers(containers, project_name): 'invalid' are invalid containers (invalid content) and 'not_found' has some missing entity in database. + Todos: + Respect 'project_name' on containers if is available. + Args: containers (Iterable[dict]): List of containers referenced into scene. project_name (str): Name of project in which context shoud look for From 3a524844609d375656e5eed3e2fe71a9ce565203 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 23 Sep 2025 12:42:06 +0200 Subject: [PATCH 316/319] revert back output handling --- client/ayon_core/tools/sceneinventory/view.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/client/ayon_core/tools/sceneinventory/view.py b/client/ayon_core/tools/sceneinventory/view.py index 6a825a2ca4..22bc170230 100644 --- a/client/ayon_core/tools/sceneinventory/view.py +++ b/client/ayon_core/tools/sceneinventory/view.py @@ -623,20 +623,17 @@ class SceneInventoryView(QtWidgets.QTreeView): containers_by_id = self._controller.get_containers_by_item_ids( item_ids ) - try: - result = action.process(list(containers_by_id.values())) - if not result: - pass + result = action.process(list(containers_by_id.values())) + if result: + self.data_changed.emit() - elif isinstance(result, (list, set)): + if isinstance(result, (list, set)): self._select_items_by_action(result) elif isinstance(result, dict): self._select_items_by_action( result["objectNames"], result["options"] ) - finally: - self.data_changed.emit() def _select_items_by_action(self, object_names, options=None): """Select view items by the result of action From 0b6e171558ee3846b72f2e182de93a94d41aeaa8 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 23 Sep 2025 13:27:21 +0200 Subject: [PATCH 317/319] Fix wrong key --- client/ayon_core/pipeline/load/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/load/utils.py b/client/ayon_core/pipeline/load/utils.py index a111444d48..d1731d4cf9 100644 --- a/client/ayon_core/pipeline/load/utils.py +++ b/client/ayon_core/pipeline/load/utils.py @@ -975,7 +975,7 @@ def get_outdated_containers( for container in filter_containers(containers, project_name).outdated: if ( not ignore_locked_versions - and container.get("locked_version") is True + and container.get("version_locked") is True ): continue outdated_containers.append(container) From 73641b5055e0e5b692f7691c82ca0fdf182dc625 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 23 Sep 2025 14:09:38 +0200 Subject: [PATCH 318/319] always fill ayon app name and tools --- client/ayon_core/host/interfaces/workfiles.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index 587962351d..5dbf29bd7b 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -1564,12 +1564,16 @@ class IWorkfileHost(AbstractHost): # Use app group and app variant from applications addon (if available) app_addon_name = os.environ.get("AYON_APP_NAME") - if app_addon_name: - data["ayon_app_name"] = app_addon_name + if not app_addon_name: + app_addon_name = None - app_addon_tools = os.environ.get("AYON_APP_TOOLS") - if app_addon_tools: - data["ayon_app_tools"] = app_addon_tools.split(";") + app_addon_tools_s = os.environ.get("AYON_APP_TOOLS") + app_addon_tools = [] + if app_addon_tools_s: + app_addon_tools = app_addon_tools_s.split(";") + + data["ayon_app_name"] = app_addon_name + data["ayon_app_tools"] = app_addon_tools workfile_info = save_workfile_info( project_name, From a0d97701c9ddab0ab9977976cb8b0363f41d0798 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 24 Sep 2025 12:25:36 +0200 Subject: [PATCH 319/319] use correct key to get action label --- client/ayon_core/tools/launcher/ui/actions_widget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 67a8bca787..31b303ca2b 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -990,7 +990,7 @@ class ActionsWidget(QtWidgets.QWidget): event["addon_name"], event["addon_version"], ), - event["action_label"], + event["full_label"], form_data, )