Skip to content

Commit

Permalink
Merge branch 'develop' into enhancement/AY-6086_adding-parents-to-tem…
Browse files Browse the repository at this point in the history
…plate-keys

# Conflicts:
#	client/ayon_core/plugins/publish/collect_anatomy_instance_data.py
  • Loading branch information
iLLiCiTiT committed Nov 29, 2024
2 parents d15148f + 2842c90 commit 7d00144
Show file tree
Hide file tree
Showing 37 changed files with 284 additions and 132 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/assign_pr_to_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 🔸Auto assign pr
on:
workflow_dispatch:
inputs:
pr_number:
type: number
description: "Run workflow for this PR number"
required: true
project_id:
type: number
description: "Github Project Number"
required: true
default: 16
pull_request:
types:
- opened

jobs:
auto-assign-pr:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
uses: ynput/ops-repo-automation/.github/workflows/pr_to_project.yml@main
with:
repo: "${{ github.repository }}"
project_id: "${{ inputs.project_id }}"
pull_request_number: "${{ github.event.pull_request.number || inputs.pr_number }}"
secrets:
token: ${{ secrets.YNPUT_BOT_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/validate_pr_labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 🔎 Validate PR Labels
on:
pull_request:
types:
- opened
- edited
- labeled
- unlabeled

jobs:
validate-type-label:
uses: ynput/ops-repo-automation/.github/workflows/validate_pr_labels.yml@main
with:
repo: "${{ github.repository }}"
pull_request_number: ${{ github.event.pull_request.number }}
query_prefix: "type: "
secrets:
token: ${{ secrets.YNPUT_BOT_TOKEN }}
4 changes: 2 additions & 2 deletions client/ayon_core/addon/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ def ensure_is_process_ready(
Implementation of this method is optional.
Note:
The logic can be similar to logic in tray, but tray does not require
to be logged in.
The logic can be similar to logic in tray, but tray does not
require to be logged in.
Args:
process_context (ProcessContext): Context of child
Expand Down
3 changes: 2 additions & 1 deletion client/ayon_core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def publish_report_viewer():
@main_cli.command()
@click.argument("output_path")
@click.option("--project", help="Define project context")
@click.option("--folder", help="Define folder in project (project must be set)")
@click.option(
"--folder", help="Define folder in project (project must be set)")
@click.option(
"--strict",
is_flag=True,
Expand Down
4 changes: 3 additions & 1 deletion client/ayon_core/lib/attribute_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,9 @@ def serialize(self):
return data

@staticmethod
def prepare_enum_items(items: "EnumItemsInputType") -> List["EnumItemDict"]:
def prepare_enum_items(
items: "EnumItemsInputType"
) -> List["EnumItemDict"]:
"""Convert items to unified structure.
Output is a list where each item is dictionary with 'value'
Expand Down
14 changes: 2 additions & 12 deletions client/ayon_core/lib/local_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,7 @@ def delete_item(self, name):
@abstractmethod
def _delete_item(self, name):
# type: (str) -> None
"""Delete item from settings.
Note:
see :meth:`ayon_core.lib.user_settings.ARegistrySettings.delete_item`
"""
"""Delete item from settings."""
pass

def __delitem__(self, name):
Expand Down Expand Up @@ -433,12 +428,7 @@ def delete_item_from_section(self, section, name):
config.write(cfg)

def _delete_item(self, name):
"""Delete item from default section.
Note:
See :meth:`~ayon_core.lib.IniSettingsRegistry.delete_item_from_section`
"""
"""Delete item from default section."""
self.delete_item_from_section("MAIN", name)


Expand Down
14 changes: 9 additions & 5 deletions client/ayon_core/pipeline/create/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,12 +1283,16 @@ def bulk_value_changes(self, sender=None):

@contextmanager
def bulk_pre_create_attr_defs_change(self, sender=None):
with self._bulk_context("pre_create_attrs_change", sender) as bulk_info:
with self._bulk_context(
"pre_create_attrs_change", sender
) as bulk_info:
yield bulk_info

@contextmanager
def bulk_create_attr_defs_change(self, sender=None):
with self._bulk_context("create_attrs_change", sender) as bulk_info:
with self._bulk_context(
"create_attrs_change", sender
) as bulk_info:
yield bulk_info

@contextmanager
Expand Down Expand Up @@ -1946,9 +1950,9 @@ def remove_instances(self, instances, sender=None):
creator are just removed from context.
Args:
instances (List[CreatedInstance]): Instances that should be removed.
Remove logic is done using creator, which may require to
do other cleanup than just remove instance from context.
instances (List[CreatedInstance]): Instances that should be
removed. Remove logic is done using creator, which may require
to do other cleanup than just remove instance from context.
sender (Optional[str]): Sender of the event.
"""
Expand Down
6 changes: 5 additions & 1 deletion client/ayon_core/pipeline/create/product_name.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import ayon_api
from ayon_core.lib import StringTemplate, filter_profiles, prepare_template_data
from ayon_core.lib import (
StringTemplate,
filter_profiles,
prepare_template_data,
)
from ayon_core.settings import get_project_settings

from .constants import DEFAULT_PRODUCT_TEMPLATE
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def get_representations_delivery_template_data(
# convert representation entity. Fixed in 'ayon_api' 1.0.10.
if isinstance(template_data, str):
con = ayon_api.get_server_api_connection()
repre_entity = con._representation_conversion(repre_entity)
con._representation_conversion(repre_entity)
template_data = repre_entity["context"]

template_data.update(copy.deepcopy(general_template_data))
Expand Down
13 changes: 10 additions & 3 deletions client/ayon_core/pipeline/editorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def remap_range_on_file_sequence(otio_clip, in_out_range):
source_range = otio_clip.source_range
available_range_rate = available_range.start_time.rate
media_in = available_range.start_time.value
available_range_start_frame = (
available_range.start_time.to_frames()
)

# Temporary.
# Some AYON custom OTIO exporter were implemented with relative
Expand All @@ -230,7 +233,7 @@ def remap_range_on_file_sequence(otio_clip, in_out_range):
# while we are updating those.
if (
is_clip_from_media_sequence(otio_clip)
and otio_clip.available_range().start_time.to_frames() == media_ref.start_frame
and available_range_start_frame == media_ref.start_frame
and source_range.start_time.to_frames() < media_ref.start_frame
):
media_in = 0
Expand Down Expand Up @@ -303,8 +306,12 @@ def get_media_range_with_retimes(otio_clip, handle_start, handle_end):
rounded_av_rate = round(available_range_rate, 2)
rounded_src_rate = round(source_range.start_time.rate, 2)
if rounded_av_rate != rounded_src_rate:
conformed_src_in = source_range.start_time.rescaled_to(available_range_rate)
conformed_src_duration = source_range.duration.rescaled_to(available_range_rate)
conformed_src_in = source_range.start_time.rescaled_to(
available_range_rate
)
conformed_src_duration = source_range.duration.rescaled_to(
available_range_rate
)
conformed_source_range = otio.opentime.TimeRange(
start_time=conformed_src_in,
duration=conformed_src_duration
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/pipeline/entity_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def parse_ayon_entity_uri(uri: str) -> Optional[dict]:
Example:
>>> parse_ayon_entity_uri(
>>> "ayon://test/char/villain?product=modelMain&version=2&representation=usd" # noqa: E501
>>> "ayon://test/char/villain?product=modelMain&version=2&representation=usd"
>>> )
{'project': 'test', 'folderPath': '/char/villain',
'product': 'modelMain', 'version': 1,
'representation': 'usd'}
>>> parse_ayon_entity_uri(
>>> "ayon+entity://project/folder?product=renderMain&version=3&representation=exr" # noqa: E501
>>> "ayon+entity://project/folder?product=renderMain&version=3&representation=exr"
>>> )
{'project': 'project', 'folderPath': '/folder',
'product': 'renderMain', 'version': 3,
Expand All @@ -34,7 +34,7 @@ def parse_ayon_entity_uri(uri: str) -> Optional[dict]:
dict[str, Union[str, int]]: The individual key with their values as
found in the ayon entity URI.
"""
""" # noqa: E501

if not (uri.startswith("ayon+entity://") or uri.startswith("ayon://")):
return {}
Expand Down
20 changes: 15 additions & 5 deletions client/ayon_core/pipeline/farm/pyblish_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import ayon_api
import clique
from ayon_core.lib import Logger, collect_frames
from ayon_core.pipeline import get_current_project_name, get_representation_path
from ayon_core.pipeline import (
get_current_project_name,
get_representation_path,
)
from ayon_core.pipeline.create import get_product_name
from ayon_core.pipeline.farm.patterning import match_aov_pattern
from ayon_core.pipeline.publish import KnownPublishError
Expand Down Expand Up @@ -771,9 +774,14 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data,

project_settings = instance.context.data.get("project_settings")

use_legacy_product_name = True
try:
use_legacy_product_name = project_settings["core"]["tools"]["creator"]["use_legacy_product_names_for_renders"] # noqa: E501
use_legacy_product_name = (
project_settings
["core"]
["tools"]
["creator"]
["use_legacy_product_names_for_renders"]
)
except KeyError:
warnings.warn(
("use_legacy_for_renders not found in project settings. "
Expand All @@ -789,7 +797,9 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data,
dynamic_data=dynamic_data)

else:
product_name, group_name = get_product_name_and_group_from_template(
(
product_name, group_name
) = get_product_name_and_group_from_template(
task_entity=instance.data["taskEntity"],
project_name=instance.context.data["projectName"],
host_name=instance.context.data["hostName"],
Expand Down Expand Up @@ -932,7 +942,7 @@ def _collect_expected_files_for_aov(files):
# but we really expect only one collection.
# Nothing else make sense.
if len(cols) != 1:
raise ValueError("Only one image sequence type is expected.") # noqa: E501
raise ValueError("Only one image sequence type is expected.")
return list(cols[0])


Expand Down
2 changes: 2 additions & 0 deletions client/ayon_core/pipeline/publish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ValidateContentsOrder,
ValidateSceneOrder,
ValidateMeshOrder,
FARM_JOB_ENV_DATA_KEY,
)

from .publish_plugins import (
Expand Down Expand Up @@ -59,6 +60,7 @@
"ValidateContentsOrder",
"ValidateSceneOrder",
"ValidateMeshOrder",
"FARM_JOB_ENV_DATA_KEY",

"AbstractMetaInstancePlugin",
"AbstractMetaContextPlugin",
Expand Down
2 changes: 2 additions & 0 deletions client/ayon_core/pipeline/publish/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
DEFAULT_PUBLISH_TEMPLATE = "default"
DEFAULT_HERO_PUBLISH_TEMPLATE = "default"
TRANSIENT_DIR_TEMPLATE = "default"

FARM_JOB_ENV_DATA_KEY: str = "farmJobEnv"
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,16 @@ def _fill_folder_data(self, instance, project_entity, anatomy_data):
# Backwards compatible (Deprecated since 24/06/06)
or instance.data.get("newAssetPublishing")
):
hierarchy = instance.data["hierarchy"]
anatomy_data["hierarchy"] = hierarchy
folder_path = instance.data["folderPath"]
parents = folder_path.lstrip("/").split("/")
folder_name = parents.pop(-1)

parent_name = project_entity["name"]
parents = []
if hierarchy:
parents = hierarchy.split("/")
hierarchy = ""
if parents:
parent_name = parents[-1]
hierarchy = "/".join(parents)

folder_name = instance.data["folderPath"].split("/")[-1]
anatomy_data.update({
"asset": folder_name,
"hierarchy": hierarchy,
Expand Down
36 changes: 36 additions & 0 deletions client/ayon_core/plugins/publish/collect_farm_env_variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os

import pyblish.api

from ayon_core.pipeline.publish import FARM_JOB_ENV_DATA_KEY


class CollectCoreJobEnvVars(pyblish.api.ContextPlugin):
"""Collect set of environment variables to submit with deadline jobs"""
order = pyblish.api.CollectorOrder - 0.45
label = "AYON core Farm Environment Variables"
targets = ["local"]

def process(self, context):
env = context.data.setdefault(FARM_JOB_ENV_DATA_KEY, {})

# Disable colored logs on farm
env["AYON_LOG_NO_COLORS"] = "1"

for key in [
"AYON_BUNDLE_NAME",
"AYON_DEFAULT_SETTINGS_VARIANT",
"AYON_USERNAME",
"AYON_PROJECT_NAME",
"AYON_FOLDER_PATH",
"AYON_TASK_NAME",
"AYON_LOG_NO_COLORS",
"AYON_IN_TESTS",
# NOTE Not sure why workdir is needed?
"AYON_WORKDIR",
]:
value = os.getenv(key)
if value:
self.log.debug(f"Setting job env: {key}: {value}")
env[key] = value

3 changes: 2 additions & 1 deletion client/ayon_core/plugins/publish/collect_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def process(self, context):

shot_data = {
"entity_type": "folder",
# WARNING unless overwritten, default folder type is hardcoded to shot
# WARNING unless overwritten, default folder type is hardcoded
# to shot
"folder_type": instance.data.get("folder_type") or "Shot",
"tasks": instance.data.get("tasks") or {},
"comments": instance.data.get("comments", []),
Expand Down
Loading

0 comments on commit 7d00144

Please sign in to comment.