Hi,
I was wondering, is it possible to create template/schema based on ‘task’ with ‘step’, as opposed to default implementation that uses solely just a ‘step’ .
(working proof needed, available documentation does not provide any answers)
Specifically, we are interested in a method that would give us complete context from the path without our magic.
example filepaths:
shots/{Shot}/{Step}/work/nuke/{Shot}.{Task}.{name}.v{version}.{user}.nk
shots/{Shot}/{Step}/work/nuke/{Task}/{Shot}.{Task}.{name}.v{version}.{user}.nk
Task = entity(Task), field(‘content’)
#(example nuke13)
import sgtk
from pprint import pprint
from upp_tools import database #magic
path = nuke.root().name()
# context unpickled from enviroment
engine = sgtk.platform.current_engine()
env_context = engine.context
pprint( env_context.to_dict()) #complete context, but supports only current context, not arbitrary path
# context generated from path
path_context = engine.sgtk.context_from_path( path )
pprint( path_context.to_dict() ) #incomplete context, has step, missing task
# cumbersome workaround
template = engine.sgtk.template_from_path( path )
fields = template.validate_and_get_fields( path )
task_name = fields['Task']
db = database.DB() # magic
task_ett = db.get_task_from_entity_and_value(
project_id = path_context.project['id'],
entity = ( path_context.entity['type'], path_context.entity['id'] ),
content = task_name ) # magic
complete_context_from_path = engine.sgtk.context_from_entity( 'Task', task_ett['id'] )
pprint( complete_context_from_path.to_dict() ) #complete context
#------------------
issue:
Using schema with just a step “entity” is not symmetrical. There is no perfect way to detect ‘task’ from a path, so we limit ourselves to information availability.
limitations:
I know, it is possible to create ‘task’ without ‘step’, but in our pipeline, this is strictly prohibited.
Task has no ‘code’ and ‘name’ field (an oversight on shotgrid side maybe ?)
From our testing of several iterations of schema,
we could only get at most ‘step’ (sometimes not even that),
but never resolve both ‘step’ and ‘task’
We already tried adding ‘task.yml’ under ‘shot’ (or under ‘shot/step’) in the schema.
Is it wrong maybe ??
type: "shotgun_entity"
name: "content"
entity_type: "Task"
filters:
- { "path": "project", "relation": "is", "values": [ "$project" ] }
- { "path": "entity", "relation": "is", "values": [ "$shot" ] }