This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
[QUAD] Bug: Sometime the latest version number cannot be retrieved from instance data, use tracked versions #6343
Open
ccaillot
wants to merge
1
commit into
ynput:develop
Choose a base branch
from
quadproduction:bug/sometime_the_latest_version_number_cannot_be_retrieved_from_instance_data_use_tracked_versions
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import logging | ||
|
||
from openpype.pipeline.context_tools import _get_modules_manager as get_modules_manager | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (87 > 79 characters) |
||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def get_latest_tracked_version_number(instance, task_name): | ||
"""Get the latest version of the instance on the active tracker else None. | ||
Args: | ||
instance (dict): The instance whose version is to be retrieved. | ||
task_name (str): Name of the instance's task. | ||
""" | ||
version_number = None | ||
modules_manager = get_modules_manager() | ||
|
||
# Tracker modules | ||
ftrack_module = modules_manager.modules_by_name.get("ftrack") | ||
kitsu_module = modules_manager.modules_by_name.get("kitsu") | ||
|
||
if ftrack_module and ftrack_module.enabled: | ||
asset_name = instance.data["subset"] | ||
asset_ftrack_id = instance.data["assetEntity"]["data"].get("ftrackId") | ||
version_number = ( | ||
ftrack_module.get_asset_latest_version_number( | ||
asset_ftrack_id, | ||
task_name, | ||
asset_name | ||
) | ||
) | ||
elif kitsu_module and kitsu_module.enabled: | ||
# TODO: add support for Kitsu | ||
pass | ||
# Add additional tracker support here | ||
|
||
return version_number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
get_asset_name_identifier, | ||
) | ||
from openpype.pipeline.version_start import get_versioning_start | ||
from openpype.pipeline.latest_tracked_version_number import get_latest_tracked_version_number | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (93 > 79 characters) |
||
|
||
|
||
class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): | ||
|
@@ -211,10 +212,29 @@ def fill_anatomy_data(self, context): | |
if version_number is None: | ||
version_number = instance.data.get("version") | ||
|
||
# use latest version (+1) if already any exist | ||
if version_number is None: | ||
# Try using the latest version data | ||
latest_version = instance.data["latestVersion"] | ||
|
||
if version_number is None: | ||
# Last attempt to get the correct version number | ||
# using the data on the tracker | ||
|
||
# Firstly, get the task name | ||
task_name = instance.data.get("task") | ||
if not task_name: | ||
task_data = anatomy_data.get("task") or {} | ||
task_name = task_data.get("name") | ||
|
||
# Try getting the latest version | ||
version_number = get_latest_tracked_version_number( | ||
instance, | ||
task_name | ||
) | ||
|
||
if latest_version is not None: | ||
# We found the latest version | ||
# Increment the value | ||
version_number = int(latest_version) + 1 | ||
|
||
# If version is not specified for instance or context | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (86 > 79 characters)