Bootstrap engine via python without the default site config

Hey everyone,

I am currently working on running the shotgrid publisher on the farm.

It involves starting the software, in this case maya, and bootstrapping the tk-maya engine with the right context.

Currently I have the issue that shotgrid complains that it does not find the engine instance in the env/site.yml file when I try to start it.

I then went ahead and added a tk-maya entry in the site.yml file under engines.

includes:
- ./includes/frameworks.yml
- ./includes/settings/tk-desktop.yml
- ./includes/settings/tk-desktop2.yml
- ./includes/settings/tk-maya.yml

################################################################################
# configuration for all engines to load in a project context
engines:
  tk-desktop: '@settings.tk-desktop.site'
  tk-desktop2: '@settings.tk-desktop2.site'
  tk-maya: '@settings.tk-maya.site'

I also added the “site” section in the env/includes/settings/tk-maya.yml file.

settings.tk-maya.site:
  apps:
    tk-multi-publish2: "@settings.tk-multi-publish2.maya.shot_step"
  location: "@engines.tk-maya.location"

In the apps section I added the tk-multi-publish2 entry and set it up to use the shot_step settings as I am running a shot publish on the farm.


Now this feels very dirty to me because I would like to bootstrap the tk-maya engine in my python script with the already defined settings.tk-maya.shot_step settings.

I don’t want to use the default site config that I have to then adjust in the yml files to work with my specific shot case.

But I didn’t find a way how to do that. When bootstrapping it seems to always use the site config as default?

Can I somehow control that? This is how I currently do the bootstrap:

# Set up logging.
sgtk.LogManager().initialize_base_file_handler("tk-batch-rendering")

user = sgtk.authentication.ShotgunAuthenticator().create_script_user(
    os.environ["SHOTGUN_SCRIPT_NAME"],
    os.environ["SHOTGUN_SCRIPT_KEY"],
    os.environ["SHOTGUN_HOST"]
)

# Set the right pipeline configuration.
tk_manager = sgtk.bootstrap.ToolkitManager(user)
tk_manager.plugin_id = "basic.batch"
tk_manager.pipeline_configuration = configuration_id

# Sync the path cache before the engine starts. The engine validates the templates
# when it starts so path cache has to be already synced.
tk_manager.pre_engine_start_callback = lambda ctx: ctx.sgtk.synchronize_filesystem_structure()

# Start the engine, we're done!
tk_manager.bootstrap_engine(engine_instance_name, context)

Would love to get some tips!

Remove the site sections you added.
You could try defining the context your bootstrapping in to. This could be supplied to the deadline job as key/info fields. You will need the entity type and id.
If you don’t supply a context, sg will only bootstrap to the site context.

1 Like

Hey @Patrick

Thanks for the quick reply.

Yeah the weird thing is I am bootstrapping with a pre defined context with:

tk_manager.bootstrap_engine(engine_instance_name, context)

And in my case the context is dictionary of a task entity.
{'id': 39148, 'name': 'animation', 'type': 'Task'}

This should be sufficient right?

hmm it should be yes.
Did you make any breakthroughs?