Option to start versioning from 0 (#5262)

* Initial version, replaced all hard 1 with 0

* ftrack v0 works only with version cast as str

* workfile tools can set 0

* fixed hound stuff

* fix for auto versioning not working anymore

* fix for not incrementing version

* hound fix

* Settings determined versioning start

* Code cosmetics

* Better failsafe for collecting settings.

* Initial profiles commit

* Hound

* Working profiles

* Update openpype/hosts/webpublisher/plugins/publish/collect_published_files.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/hosts/webpublisher/plugins/publish/collect_published_files.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/plugins/publish/collect_anatomy_instance_data.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/settings/entities/schemas/projects_schema/schema_project_global.json

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Illicitit feedback

* Update openpype/pipeline/context_tools.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Fix collect_published_files

* Working version

* Hound

* Update openpype/pipeline/version_start.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/pipeline/version_start.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/tools/push_to_project/control_integrate.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/hosts/photoshop/plugins/publish/collect_published_version.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/hosts/photoshop/plugins/publish/collect_published_version.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/hosts/webpublisher/plugins/publish/collect_published_files.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/hosts/webpublisher/plugins/publish/collect_published_files.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/hosts/webpublisher/plugins/publish/collect_published_files.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/pipeline/workfile/path_resolving.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Update openpype/settings/__init__.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Hound

* Illicitit feedback

* Replace host.name

* Update openpype/plugins/publish/collect_anatomy_instance_data.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* reuse 'task_name' and 'task_type'

* skip hero integration when source version in 0

---------

Co-authored-by: maxpareschi <max.pareschi@gmail.com>
Co-authored-by: Jakub Ježek <jakubjezek001@gmail.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <jakub.trllo@gmail.com>
This commit is contained in:
Toke Jepsen 2023-08-10 12:31:49 +01:00 committed by GitHub
parent d81926bb88
commit 7973354fef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 239 additions and 44 deletions

View file

@ -18,6 +18,7 @@ Provides:
import pyblish.api
from openpype.client import get_last_version_by_subset_name
from openpype.pipeline.version_start import get_versioning_start
class CollectPublishedVersion(pyblish.api.ContextPlugin):
@ -47,9 +48,17 @@ class CollectPublishedVersion(pyblish.api.ContextPlugin):
version_doc = get_last_version_by_subset_name(project_name,
workfile_subset_name,
asset_id)
version_int = 1
if version_doc:
version_int += int(version_doc["name"])
version_int = int(version_doc["name"]) + 1
else:
version_int = get_versioning_start(
project_name,
"photoshop",
task_name=context.data["task"],
task_type=context.data["taskType"],
project_settings=context.data["project_settings"]
)
self.log.debug(f"Setting {version_int} to context.")
context.data["version"] = version_int

View file

@ -18,6 +18,7 @@ from openpype.hosts.tvpaint.api.lib import (
from openpype.hosts.tvpaint.api.pipeline import (
get_current_workfile_context,
)
from openpype.pipeline.version_start import get_versioning_start
class LoadWorkfile(plugin.Loader):
@ -95,7 +96,13 @@ class LoadWorkfile(plugin.Loader):
)[1]
if version is None:
version = 1
version = get_versioning_start(
project_name,
"tvpaint",
task_name=task_name,
task_type=data["task"]["type"],
family="workfile"
)
else:
version += 1

View file

@ -25,6 +25,7 @@ from openpype.lib import (
)
from openpype.pipeline.create import get_subset_name
from openpype_modules.webpublisher.lib import parse_json
from openpype.pipeline.version_start import get_versioning_start
class CollectPublishedFiles(pyblish.api.ContextPlugin):
@ -103,7 +104,13 @@ class CollectPublishedFiles(pyblish.api.ContextPlugin):
project_settings=context.data["project_settings"]
)
version = self._get_next_version(
project_name, asset_doc, subset_name
project_name,
asset_doc,
task_name,
task_type,
family,
subset_name,
context
)
next_versions.append(version)
@ -141,8 +148,9 @@ class CollectPublishedFiles(pyblish.api.ContextPlugin):
try:
no_of_frames = self._get_number_of_frames(file_url)
if no_of_frames:
frame_end = int(frame_start) + \
math.ceil(no_of_frames)
frame_end = (
int(frame_start) + math.ceil(no_of_frames)
)
frame_end = math.ceil(frame_end) - 1
instance.data["frameEnd"] = frame_end
self.log.debug("frameEnd:: {}".format(
@ -270,7 +278,16 @@ class CollectPublishedFiles(pyblish.api.ContextPlugin):
config["families"],
config["tags"])
def _get_next_version(self, project_name, asset_doc, subset_name):
def _get_next_version(
self,
project_name,
asset_doc,
task_name,
task_type,
family,
subset_name,
context
):
"""Returns version number or 1 for 'asset' and 'subset'"""
version_doc = get_last_version_by_subset_name(
@ -279,9 +296,19 @@ class CollectPublishedFiles(pyblish.api.ContextPlugin):
asset_doc["_id"],
fields=["name"]
)
version = 1
if version_doc:
version += int(version_doc["name"])
version = int(version_doc["name"]) + 1
else:
version = get_versioning_start(
project_name,
"webpublisher",
task_name=task_name,
task_type=task_type,
family=family,
subset=subset_name,
project_settings=context.data["project_settings"]
)
return version
def _get_number_of_frames(self, file_url):

View file

@ -3,7 +3,7 @@
import os
import json
import re
from copy import copy, deepcopy
from copy import deepcopy
import requests
import clique
@ -16,6 +16,7 @@ from openpype.client import (
from openpype.pipeline import publish, legacy_io
from openpype.lib import EnumDef, is_running_from_build
from openpype.tests.lib import is_in_tests
from openpype.pipeline.version_start import get_versioning_start
from openpype.pipeline.farm.pyblish_functions import (
create_skeleton_instance,
@ -566,7 +567,15 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin,
if version:
version = int(version["name"]) + 1
else:
version = 1
version = get_versioning_start(
project_name,
template_data["app"],
task_name=template_data["task"]["name"],
task_type=template_data["task"]["type"],
family="render",
subset=subset,
project_settings=context.data["project_settings"]
)
host_name = context.data["hostName"]
task_info = template_data.get("task") or {}

View file

@ -11,10 +11,8 @@ Provides:
"""
import os
import sys
import collections
import six
import pyblish.api
import clique

View file

@ -94,7 +94,7 @@ from .context_tools import (
get_current_host_name,
get_current_project_name,
get_current_asset_name,
get_current_task_name,
get_current_task_name
)
install = install_host
uninstall = uninstall_host

View file

@ -35,7 +35,7 @@ from . import (
register_inventory_action_path,
register_creator_plugin_path,
deregister_loader_plugin_path,
deregister_inventory_action_path,
deregister_inventory_action_path
)

View file

@ -0,0 +1,37 @@
from openpype.lib.profiles_filtering import filter_profiles
from openpype.settings import get_project_settings
def get_versioning_start(
project_name,
host_name,
task_name=None,
task_type=None,
family=None,
subset=None,
project_settings=None,
):
"""Get anatomy versioning start"""
if not project_settings:
project_settings = get_project_settings(project_name)
version_start = 1
settings = project_settings["global"]
profiles = settings.get("version_start_category", {}).get("profiles", [])
if not profiles:
return version_start
filtering_criteria = {
"host_names": host_name,
"families": family,
"task_names": task_name,
"task_types": task_type,
"subsets": subset
}
profile = filter_profiles(profiles, filtering_criteria)
if profile is None:
return version_start
return profile["version_start"]

View file

@ -10,7 +10,7 @@ from openpype.lib import (
Logger,
StringTemplate,
)
from openpype.pipeline import Anatomy
from openpype.pipeline import version_start, Anatomy
from openpype.pipeline.template_data import get_template_data
@ -316,7 +316,13 @@ def get_last_workfile(
)
if filename is None:
data = copy.deepcopy(fill_data)
data["version"] = 1
data["version"] = version_start.get_versioning_start(
data["project"]["name"],
data["app"],
task_name=data["task"]["name"],
task_type=data["task"]["type"],
family="workfile"
)
data.pop("comment", None)
if not data.get("ext"):
data["ext"] = extensions[0]

View file

@ -32,6 +32,7 @@ from openpype.client import (
get_subsets,
get_last_versions
)
from openpype.pipeline.version_start import get_versioning_start
class CollectAnatomyInstanceData(pyblish.api.ContextPlugin):
@ -191,15 +192,6 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin):
version_number = context.data('version')
else:
version_number = instance.data.get("version")
# If version is not specified for instance or context
if version_number is None:
# TODO we should be able to change default version by studio
# preferences (like start with version number `0`)
version_number = 1
# use latest version (+1) if already any exist
latest_version = instance.data["latestVersion"]
if latest_version is not None:
version_number += int(latest_version)
anatomy_updates = {
"asset": instance.data["asset"],
@ -225,6 +217,7 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin):
anatomy_updates["parent"] = parent_name
# Task
task_type = None
task_name = instance.data.get("task")
if task_name:
asset_tasks = asset_doc["data"]["tasks"]
@ -240,6 +233,24 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin):
"short": task_code
}
# Define version
# use latest version (+1) if already any exist
if version_number is None:
latest_version = instance.data["latestVersion"]
if latest_version is not None:
version_number = int(latest_version) + 1
# If version is not specified for instance or context
if version_number is None:
version_number = get_versioning_start(
context.data["projectName"],
instance.context.data["hostName"],
task_name=task_name,
task_type=task_type,
family=instance.data["family"],
subset=instance.data["subset"]
)
# Additional data
resolution_width = instance.data.get("resolutionWidth")
if resolution_width:

View file

@ -142,6 +142,12 @@ class IntegrateHeroVersion(pyblish.api.InstancePlugin):
))
return
if AYON_SERVER_ENABLED and src_version_entity["name"] == 0:
self.log.debug(
"Version 0 cannot have hero version. Skipping."
)
return
all_copied_files = []
transfers = instance.data.get("transfers", list())
for _src, dst in transfers:

View file

@ -19,6 +19,7 @@ from openpype.pipeline import (
)
from openpype.pipeline.context_tools import get_workdir_from_session
from openpype.pipeline.version_start import get_versioning_start
log = logging.getLogger("Update Slap Comp")
@ -26,9 +27,6 @@ log = logging.getLogger("Update Slap Comp")
def _format_version_folder(folder):
"""Format a version folder based on the filepath
Assumption here is made that, if the path does not exists the folder
will be "v001"
Args:
folder: file path to a folder
@ -36,9 +34,13 @@ def _format_version_folder(folder):
str: new version folder name
"""
new_version = 1
new_version = get_versioning_start(
get_current_project_name(),
"fusion",
family="workfile"
)
if os.path.isdir(folder):
re_version = re.compile("v\d+$")
re_version = re.compile(r"v\d+$")
versions = [i for i in os.listdir(folder) if os.path.isdir(i)
and re_version.match(i)]
if versions:

View file

@ -1,4 +1,7 @@
{
"version_start_category": {
"profiles": []
},
"imageio": {
"activate_global_color_management": false,
"ocio_config": {

View file

@ -5,6 +5,61 @@
"label": "Global",
"is_file": true,
"children": [
{
"type": "dict",
"key": "version_start_category",
"label": "Version Start",
"collapsible": true,
"collapsible_key": true,
"children": [
{
"type": "list",
"collapsible": true,
"key": "profiles",
"label": "Profiles",
"object_type": {
"type": "dict",
"children": [
{
"key": "host_names",
"label": "Host names",
"type": "hosts-enum",
"multiselection": true
},
{
"key": "task_types",
"label": "Task types",
"type": "task-types-enum"
},
{
"key": "task_names",
"label": "Task names",
"type": "list",
"object_type": "text"
},
{
"key": "families",
"label": "Families",
"type": "list",
"object_type": "text"
},
{
"key": "subsets",
"label": "Subset names",
"type": "list",
"object_type": "text"
},
{
"key": "version_start",
"label": "Version Start",
"type": "number",
"minimum": 0
}
]
}
}
]
},
{
"key": "imageio",
"type": "dict",

View file

@ -40,6 +40,7 @@ from openpype.lib import (
from openpype.lib.file_transaction import FileTransaction
from openpype.settings import get_project_settings
from openpype.pipeline import Anatomy
from openpype.pipeline.version_start import get_versioning_start
from openpype.pipeline.template_data import get_template_data
from openpype.pipeline.publish import get_publish_template_name
from openpype.pipeline.create import get_subset_name
@ -940,9 +941,17 @@ class ProjectPushItemProcess:
last_version_doc = get_last_version_by_subset_id(
project_name, subset_id
)
version = 1
if last_version_doc:
version += int(last_version_doc["name"])
version = int(last_version_doc["name"]) + 1
else:
version = get_versioning_start(
project_name,
self.host_name,
task_name=self.task_info["name"],
task_type=self.task_info["type"],
family=families[0],
subset=subset_doc["name"]
)
existing_version_doc = get_version_by_name(
project_name, version, subset_id
@ -966,14 +975,6 @@ class ProjectPushItemProcess:
return
if version is None:
last_version_doc = get_last_version_by_subset_id(
project_name, subset_id
)
version = 1
if last_version_doc:
version += int(last_version_doc["name"])
version_doc = new_version_doc(
version, subset_id, version_data
)

View file

@ -10,6 +10,7 @@ from openpype.client import (
)
from openpype.settings import get_project_settings
from openpype.pipeline import LegacyCreator
from openpype.pipeline.version_start import get_versioning_start
from openpype.pipeline.create import (
SUBSET_NAME_ALLOWED_SYMBOLS,
TaskNotSetError,
@ -299,7 +300,15 @@ class FamilyWidget(QtWidgets.QWidget):
project_name = self.dbcon.active_project()
asset_name = self.asset_name
subset_name = self.input_result.text()
version = 1
plugin = self.list_families.currentItem().data(PluginRole)
family = plugin.family.rsplit(".", 1)[-1]
version = get_versioning_start(
project_name,
"standalonepublisher",
task_name=self.dbcon.Session["AVALON_TASK"],
family=family,
subset=subset_name
)
asset_doc = None
subset_doc = None

View file

@ -12,6 +12,7 @@ from openpype.pipeline import (
from openpype.pipeline.workfile import get_last_workfile_with_version
from openpype.pipeline.template_data import get_template_data_with_names
from openpype.tools.utils import PlaceholderLineEdit
from openpype.pipeline import version_start, get_current_host_name
log = logging.getLogger(__name__)
@ -218,7 +219,15 @@ class SaveAsDialog(QtWidgets.QDialog):
# Version number input
version_input = QtWidgets.QSpinBox(version_widget)
version_input.setMinimum(1)
version_input.setMinimum(
version_start.get_versioning_start(
self.data["project"]["name"],
get_current_host_name(),
task_name=self.data["task"]["name"],
task_type=self.data["task"]["type"],
family="workfile"
)
)
version_input.setMaximum(9999)
# Last version checkbox
@ -420,7 +429,13 @@ class SaveAsDialog(QtWidgets.QDialog):
)[1]
if version is None:
version = 1
version = version_start.get_versioning_start(
data["project"]["name"],
get_current_host_name(),
task_name=self.data["task"]["name"],
task_type=self.data["task"]["type"],
family="workfile"
)
else:
version += 1