Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

#180 - Changed tasks to dictionaries #196

Merged
merged 2 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions avalon/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

DEFAULTS = {
"config": {
"schema": "avalon-core:config-1.0",
"schema": "avalon-core:config-1.1",
"apps": [
{
"name": "shell",
Expand Down Expand Up @@ -98,7 +98,7 @@ def create_project(name):
raise RuntimeError("%s already exists" % name)

return io.insert_one({
"schema": "avalon-core:project-2.0",
"schema": "avalon-core:project-2.1",
"type": "project",
"name": name,
"data": dict(),
Expand Down
88 changes: 88 additions & 0 deletions avalon/schema/config-1.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",

"title": "avalon-core:config-1.1",
"description": "A project configuration.",

"type": "object",

"additionalProperties": false,
"required": [
"template",
"tasks",
"apps"
],

"properties": {
"schema": {
"description": "Schema identifier for payload",
"type": "string"
},
"template": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^.*$": {
"type": "string"
}
}
},
"tasks": {
"type": "object",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"icon": {"type": "string"},
"group": {"type": "string"},
"label": {"type": "string"}
},
"required": [
"short_name"
]
}
},
"apps": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"icon": {"type": "string"},
"group": {"type": "string"},
"label": {"type": "string"}
},
"required": ["name"]
}
},
"families": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"icon": {"type": "string"},
"label": {"type": "string"},
"hideFilter": {"type": "boolean"}
},
"required": ["name"]
}
},
"groups": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"icon": {"type": "string"},
"color": {"type": "string"},
"order": {"type": ["integer", "number"]}
},
"required": ["name"]
}
},
"copy": {
"type": "object"
}
}
}
10 changes: 10 additions & 0 deletions avalon/schema/inventory-1.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",

"title": "avalon-core:config-1.1",
"description": "A project configuration.",

"type": "object",

"additionalProperties": true
}
86 changes: 86 additions & 0 deletions avalon/schema/project-2.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",

"title": "avalon-core:project-2.1",
"description": "A unit of data",

"type": "object",

"additionalProperties": true,

"required": [
"schema",
"type",
"name",
"data",
"config"
],

"properties": {
"schema": {
"description": "Schema identifier for payload",
"type": "string",
"enum": ["avalon-core:project-2.1"],
"example": "avalon-core:project-2.1"
},
"type": {
"description": "The type of document",
"type": "string",
"enum": ["project"],
"example": "project"
},
"parent": {
"description": "Unique identifier to parent document",
"example": "592c33475f8c1b064c4d1696"
},
"name": {
"description": "Name of directory",
"type": "string",
"pattern": "^[a-zA-Z0-9_.]*$",
"example": "hulk"
},
"data": {
"description": "Document metadata",
"type": "object",
"example": {
"fps": 24,
"width": 1920,
"height": 1080
}
},
"config": {
"type": "object",
"description": "Document metadata",
"example": {
"schema": "avalon-core:config-1.1",
"apps": [
{
"name": "maya2016",
"label": "Autodesk Maya 2016"
},
{
"name": "nuke10",
"label": "The Foundry Nuke 10.0"
}
],
"tasks": {
"Model": {"short_name": "mdl"},
"Render": {"short_name": "rnd"},
"Animate": {"short_name": "anim"},
"Rig": {"short_name": "rig"},
"Lookdev": {"short_name": "look"},
"Layout": {"short_name": "lay"}
},
"template": {
"work":
"{root}/{project}/{silo}/{asset}/work/{task}/{app}",
"publish":
"{root}/{project}/{silo}/{asset}/publish/{subset}/v{version:0>3}/{subset}.{representation}"
}
},
"$ref": "config-1.1.json"
}
},

"definitions": {}
}
20 changes: 10 additions & 10 deletions avalon/tests/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

self = sys.modules[__name__]
self._project = {
"schema": "avalon-core:project-2.0",
"schema": "avalon-core:project-2.1",
"type": "project",
"name": PROJECT_NAME,
"config": {
"template": {},
"tasks": [],
"tasks": {},
"apps": [],
"copy": {}
},
Expand All @@ -36,10 +36,10 @@
{"name": "app1"},
{"name": "app2"},
],
"tasks": [
{"name": "task1"},
{"name": "task2"},
],
"tasks": {
{"Animation": {"short_name": "anim"}},
{"Modeling": {"short_name": "mdl"}},
},
"template": {
"work":
"{root}/{project}/{silo}/{asset}/work/"
Expand Down Expand Up @@ -122,10 +122,10 @@ def test_save():
{"name": "app1"},
{"name": "app2"},
],
"tasks": [
{"name": "task1"},
{"name": "task2"},
],
"tasks": {
{"Animation": {"short_name": "anim"}},
{"Modeling": {"short_name": "mdl"}},
},
"template": {
"work":
"{root}/{project}/{silo}/{asset}/work/"
Expand Down
10 changes: 5 additions & 5 deletions avalon/tools/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ def __init__(self, parent=None):
def _get_task_icons(self):
# Get the project configured icons from database
project = io.find_one({"type": "project"})
tasks = project["config"].get("tasks", [])
for task in tasks:
tasks = project["config"].get("tasks", {})
for task_name, task in tasks.items():
icon_name = task.get("icon", None)
if icon_name:
icon = qtawesome.icon("fa.{}".format(icon_name),
color=style.colors.default)
self._icons[task["name"]] = icon
self._icons[task_name] = icon

def set_assets(self, asset_ids=None, asset_docs=None):
"""Set assets to track by their database id
Expand Down Expand Up @@ -257,8 +257,8 @@ def set_assets(self, asset_ids=None, asset_docs=None):

tasks = collections.Counter()
for asset_doc in asset_docs:
asset_tasks = asset_doc.get("data", {}).get("tasks", [])
tasks.update(asset_tasks)
asset_tasks = asset_doc.get("data", {}).get("tasks", {})
tasks.update(asset_tasks.keys())

self.clear()
self.beginResetModel()
Expand Down