diff --git a/avalon/pipeline.py b/avalon/pipeline.py index 3c0a74970..af5271db0 100644 --- a/avalon/pipeline.py +++ b/avalon/pipeline.py @@ -1294,7 +1294,11 @@ def is_compatible_loader(Loader, context): bool """ - families = context["version"]["data"]["families"] + if context["subset"]["schema"] == "avalon-core:subset-3.0": + families = context["subset"]["data"]["families"] + else: + families = context["version"]["data"].get("families", []) + representation = context["representation"] has_family = ("*" in Loader.families or any(family in Loader.families for family in families)) diff --git a/avalon/schema/subset-3.0.json b/avalon/schema/subset-3.0.json new file mode 100644 index 000000000..26054e8d4 --- /dev/null +++ b/avalon/schema/subset-3.0.json @@ -0,0 +1,62 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + + "title": "avalon-core:subset-3.0", + "description": "A container of instances", + + "type": "object", + + "additionalProperties": true, + + "required": [ + "schema", + "type", + "parent", + "name", + "data" + ], + + "properties": { + "schema": { + "description": "The schema associated with this document", + "type": "string", + "enum": ["avalon-core:subset-3.0"], + "example": "avalon-core:subset-3.0" + }, + "type": { + "description": "The type of document", + "type": "string", + "enum": ["subset"], + "example": "subset" + }, + "parent": { + "description": "Unique identifier to parent document", + "example": "592c33475f8c1b064c4d1696" + }, + "name": { + "description": "Name of directory", + "type": "string", + "pattern": "^[a-zA-Z0-9_.]*$", + "example": "shot01" + }, + "data": { + "description": "Document metadata", + "type": "object", + "required": ["families"], + "properties": { + "families": { + "type": "array", + "items": {"type": "string"}, + "description": "One or more families associated with this subset" + } + }, + "example": { + "families" : [ + "avalon.camera" + ], + "frameStart": 1000, + "frameEnd": 1201 + } + } + } +} diff --git a/avalon/schema/version-3.0.json b/avalon/schema/version-3.0.json new file mode 100644 index 000000000..e7f15cae0 --- /dev/null +++ b/avalon/schema/version-3.0.json @@ -0,0 +1,84 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + + "title": "avalon-core:version-3.0", + "description": "An individual version", + + "type": "object", + + "additionalProperties": true, + + "required": [ + "schema", + "type", + "parent", + "name", + "data" + ], + + "properties": { + "schema": { + "description": "The schema associated with this document", + "type": "string", + "enum": ["avalon-core:version-3.0"], + "example": "avalon-core:version-3.0" + }, + "type": { + "description": "The type of document", + "type": "string", + "enum": ["version"], + "example": "version" + }, + "parent": { + "description": "Unique identifier to parent document", + "example": "592c33475f8c1b064c4d1696" + }, + "name": { + "description": "Number of version", + "type": "number", + "example": 12 + }, + "locations": { + "description": "Where on the planet this version can be found.", + "type": "array", + "items": {"type": "string"}, + "example": ["data.avalon.com"] + }, + "data": { + "description": "Document metadata", + "type": "object", + "required": ["author", "source", "time"], + "properties": { + "time": { + "description": "ISO formatted, file-system compatible time", + "type": "string" + }, + "timeFormat": { + "description": "ISO format of time", + "type": "string" + }, + "author": { + "description": "User logged on to the machine at time of publish", + "type": "string" + }, + "version": { + "description": "Number of this version", + "type": "number" + }, + "path": { + "description": "Unformatted path, e.g. '{root}/assets/Bruce/publish/lookdevDefault/v001", + "type": "string" + }, + "source": { + "description": "Original file from which this version was made.", + "type": "string" + } + }, + "example": { + "source" : "{root}/f02_prod/assets/BubbleWitch/work/modeling/marcus/maya/scenes/model_v001.ma", + "author" : "marcus", + "time" : "20170510T090203Z" + } + } + } +} diff --git a/avalon/tools/loader/model.py b/avalon/tools/loader/model.py index 564746ff4..79f4f0582 100644 --- a/avalon/tools/loader/model.py +++ b/avalon/tools/loader/model.py @@ -110,7 +110,11 @@ def set_version(self, index, version): frames = None duration = None - families = version_data.get("families", [None]) + if item["schema"] == "avalon-core:subset-3.0": + families = item["data"]["families"] + else: + families = version_data.get("families", [None]) + family = families[0] family_config = lib.get_family_cached_config(family) diff --git a/avalon/tools/sceneinventory/model.py b/avalon/tools/sceneinventory/model.py index d7a1276e1..6010b9225 100644 --- a/avalon/tools/sceneinventory/model.py +++ b/avalon/tools/sceneinventory/model.py @@ -226,15 +226,19 @@ def add_items(self, items, parent=None): asset = io.find_one({"_id": subset["parent"]}) # Get the primary family - family = version["data"].get("family", "") - if not family: - families = version["data"].get("families", []) - if families: - family = families[0] + no_family = "" + if subset["schema"] == "avalon-core:subset-3.0": + families = subset["data"]["families"] + prim_family = families[0] if families else no_family + else: + prim_family = version["data"].get("family") + if not prim_family: + families = version["data"].get("families") + prim_family = families[0] if families else no_family # Get the label and icon for the family if in configuration - family_config = tools_lib.get_family_cached_config(family) - family = family_config.get("label", family) + family_config = tools_lib.get_family_cached_config(prim_family) + family = family_config.get("label", prim_family) family_icon = family_config.get("icon", None) # Store the highest available version so the model can know