### Setup Project with Flow Production Tracking Toolkit Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pg_integrations_admin_guides_advanced_toolkit_administration_html The `setup_project` command initializes a new project with the Flow Production Tracking Toolkit. It guides the user through configuration selection and project association. The `--force` flag allows re-running the setup on already configured projects. ```bash > tank setup_project --force Welcome to SGTK! For documentation, see https://help.autodesk.com/view/SGDEV/ENU/ - Running setup_project... force mode: Projects already set up with Toolkit can be set up again. Welcome to SGTK Project Setup! Connecting to Flow Production Tracking... Connecting to the App Store... ------------------------------------------------------------------ Which configuration would you like to associate with this project? You can use the configuration from an existing project as a template for this new project. All settings, apps and folder configuration settings will be copied over to your new project. The following configurations were found: big_buck_bunny: '/mnt/software/sgtk/big_buck_bunny' ghosts: '/mnt/software/sgtk/ghosts' chasing_perfection: '/mnt/software/sgtk/chasing_perfection' If you want to use any of the configs listed about for your new project, just type in its path when prompted below. You can use the Default Configuration for your new project. The default configuration is a good sample config, demonstrating a typical basic setup of the Flow Production Tracking Pipeline Toolkit using the latest apps and engines. This will be used by default if you just hit enter below. If you have a configuration stored somewhere on disk, you can just enter the path to this config it will be used for the new project. [tk-config-default]: Downloading Config tk-config-default v0.4.15 from the App Store... This is the 'Default Config' config. Below are all active projects, including ones that have been set up: -------------------------------------------------------------------- [ 4] Demo Project Fubar is an epic story of an on-going political wa... [ 5] Big Buck Bunny Note: This project has already been set up. A killer bunny movie [ 6] The Ghosts of Pere Lachaise Note: This project has already been set up. De Films en Aiguille and ChezEddy present this year... [ 7] Chasing Perfection Note: This project has already been set up. You've seen the car commercials, the car races, and... [ 8] What Happened to My Headphones? The Ryan Mayeda story Please type in the id of the project to connect to or ENTER to exit: ``` -------------------------------- ### View Project Configurations Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pg_integrations_admin_guides_advanced_toolkit_administration_html The `configurations` command provides an overview of all configurations associated with a specific project. This is useful for understanding the current setup and activity within a project managed by the Toolkit. ```bash > tank Project Bunny configurations Welcome to Sgtk! Will search across all Flow Production Tracking Projects. - Found Project Big Buck Bunny - Starting Sgtk v0.13.22 using configuration /mnt/software/sgtk/big_buck_bunny. - Setting the Context to Big Buck Bunny. - Running configurations... Fetching data from Flow Production Tracking... ``` -------------------------------- ### Nuke Integration Setup and Bootstrap Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pc_nuke_write_node_html This section details how to bootstrap ShotGrid Toolkit in Nuke, especially for render farm environments. It covers environment variable setup, authentication using script users, and starting the Nuke engine. ```APIDOC ## Nuke Integration Setup and Bootstrap This script demonstrates a plugin-based approach to bootstrap ShotGrid Toolkit in Nuke on a render farm. ### Prerequisites - Ensure `tk-core` is accessible in the `PYTHONPATH` on render nodes. This can be achieved by setting the `SHOTGUN_SGTK_MODULE_PATH` environment variable or by installing `tk-core` centrally using pip. - Set the following environment variables: - `SHOTGUN_SITE`: The Flow Production Tracking site URL. - `SHOTGUN_FARM_SCRIPT_USER`: The script user for authentication. - `SHOTGUN_FARM_SCRIPT_KEY`: The API key for the script user. - `SHOTGUN_CONFIG_URI`: The URI for the base pipeline configuration. ### Authentication and Bootstrap Process 1. **Import necessary modules**: `sys`, `os`, `sgtk`. 2. **Set `PYTHONPATH`**: If `SHOTGUN_SGTK_MODULE_PATH` is set, add it to `sys.path`. 3. **Authenticate**: Use `sgtk.authentication.ShotgunAuthenticator` and `sa.create_script_user` with credentials from environment variables. 4. **Initialize Toolkit Manager**: Create an instance of `sgtk.bootstrap.ToolkitManager` with the authenticated user. 5. **Configure Manager**: Set `mgr.base_configuration` from `SHOTGUN_CONFIG_URI` and disable `mgr.do_shotgun_config_lookup` to use the specified configuration. 6. **Set Plugin ID**: Set `mgr.plugin_id = "basic.nuke"` to indicate a Nuke integration. 7. **Get Entity**: Retrieve the Toolkit context using `mgr.get_entity_from_environment()` based on environment variables like `SHOTGUN_ENTITY_TYPE` and `SHOTGUN_ENTITY_ID`. 8. **Bootstrap Engine**: Start the Nuke engine using `mgr.bootstrap_engine("tk-nuke", entity=sg_entity)`. ### Deadline-specific Configuration To prevent Deadline from remapping paths, which can interfere with Toolkit's file recognition: 1. In Deadline, go to **Tools > Configure Plugin** (Super User mode). 2. Disable the **'Enable Path Mapping'** option. ### Example Usage (Conceptual Python Script) ```python import sys import os # Assuming environment variables are set TK_CORE_PATH = os.environ["SHOTGUN_SGTK_MODULE_PATH"] if TK_CORE_PATH not in sys.path: sys.path.append(TK_CORE_PATH) import sgtk sa = sgtk.authentication.ShotgunAuthenticator() SG_SITE_URL = os.environ["SHOTGUN_SITE"] SG_SCRIPT_USER = os.environ["SHOTGUN_FARM_SCRIPT_USER"] SG_SCRIPT_KEY = os.environ["SHOTGUN_FARM_SCRIPT_KEY"] user = sa.create_script_user( api_script=SG_SCRIPT_USER, api_key=SG_SCRIPT_KEY, host=SG_SITE_URL ) mgr = sgtk.bootstrap.ToolkitManager(sg_user=user) mgr.base_configuration = os.environ["SHOTGUN_CONFIG_URI"] mgr.do_shotgun_config_lookup = False mgr.plugin_id = "basic.nuke" sg_entity = mgr.get_entity_from_environment() nuke_engine = mgr.bootstrap_engine("tk-nuke", entity=sg_entity) print("Toolkit Nuke engine bootstrapped successfully.") ``` ``` -------------------------------- ### Tank Command Usage Examples Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pg_integrations_admin_guides_advanced_toolkit_administration_html This section provides various examples of using the 'tank' command for different administrative tasks. It shows how to list commands for entities, execute built-in commands like folder creation, launch applications, and specify paths for operations. ```bash # Show all tank commands for an asset named 'piano' > tank Asset piano # We can also list all assets containing the phrase 'pi' > tank Asset pi # We can execute the built-in folder creation command for # the piano > tank Asset piano folders # If the application launcher app is installed, we can launch maya # and set the work area to the piano > tank Asset piano launch_maya # Alternatively, we can specify a path on disk instead of a Flow Production Tracking entity > tank /mnt/projects/hero/assets/piano launch_maya # Or we can change our work directory and run tank like this > cd /mnt/projects/hero/assets/piano launch_maya > tank launch_maya ``` -------------------------------- ### Bootstrap Flow Production Tracking Toolkit from Path (Python) Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pg_integrations_admin_guides_advanced_toolkit_administration_html This Python code snippet demonstrates how to bootstrap the Flow Production Tracking Toolkit when the context is determined by a file path. It initializes the Toolkit API and starts the engine for a Maya environment. ```python # starting up sgtk when your context is based on a path import sgtk path = "/mnt/projects/hero/assets/chair01/lighting" # create a sgtk api handle tk = sgtk.sgtk_from_path(path) # create a context object ctx = tk.context_from_path(path) # start the tank engine sgtk.platform.start_engine('tk-maya', tk, ctx) ``` -------------------------------- ### Bootstrap Flow Production Tracking Toolkit from Entity (Python) Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pg_integrations_admin_guides_advanced_toolkit_administration_html This Python code snippet illustrates how to bootstrap the Flow Production Tracking Toolkit when the context is defined by a Flow Production Tracking entity (e.g., a Shot). It initializes the Toolkit API and starts the engine. ```python # starting up sgtk when your context is based on a Flow Production Tracking object import sgtk entity_type = "Shot" entity_id = 123 # create a sgtk api handle tk = sgtk.sgtk_from_entity(entity_type, entity_id) # create a context object ctx = tk.context_from_entity(entity_type, entity_id) ``` -------------------------------- ### Start Flow Production Tracking Event Daemon Windows Service Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_tr_event_daemon_installation_html Starts the Flow Production Tracking Event Daemon Windows service. This command can be executed via the command line or through standard Windows service management tools. Requires Python with PyWin32. ```shell > C:\Python27_32\python.exe shotgunEventDaemon.py start ``` -------------------------------- ### Instantiate and Run SetupProjectWizard Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pc_framework_adminui_html Demonstrates how to import the admin UI framework, create an instance of the SetupProjectWizard, and execute the wizard. The wizard guides users through setting up a project from a Flow Production Tracking instance for Toolkit. It returns a standard QDialog Accepted or Rejected value upon completion. ```python import sgtk adminui = sgtk.platform.import_framework("tk-framework-adminui", "setup_project") setup = adminui.SetupProjectWizard(project, parent) dialog_result = setup.exec_() ``` -------------------------------- ### Test Flow Production Tracking API Installation (Python) Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_tr_event_daemon_installation_html This command verifies if the Flow Production Tracking Python API is installed correctly and accessible. It imports the 'shotgun_api3' module. If successful, no output is shown; an ImportError indicates a problem with the installation or PYTHONPATH. ```shell $ python -c "import shotgun_api3" ``` ```shell $ python -c "import shotgun_api3" Traceback (most recent call last): File "", line 1, in ImportError: No module named shotgun_api3 ``` -------------------------------- ### AJA Device Configuration Example Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SG_RV_rv_manuals_rv_rv_sdi_manual_html&p=SGSUB Demonstrates how to combine command-line options to configure AJA devices, specifically setting the Rec.601 color matrix and a ring buffer size of 4. ```bash --rec601 --ring-buffer-size 4 ``` -------------------------------- ### Install Project Requirements (pip) Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_tr_event_daemon_installation_html This command installs all Python dependencies listed in the 'requirements.txt' file using pip. It's crucial for ensuring the Flow Production Tracking Events daemon has all necessary libraries to function correctly. ```shell $ pip install -r /path/to/requirements.txt ``` -------------------------------- ### Full Toolkit Bootstrap Initialization (Python) Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pg_developer_pg_sgtk_developer_bootstrapping_html A comprehensive example of initializing the ToolkitManager and bootstrapping an engine. It includes importing sgtk, setting up logging, authentication using a script key, and creating a project entity for bootstrapping. ```python # Import Toolkit so we can access to Toolkit specific features. import sgtk # Initialize the logger so we get output to our terminal. sgtk.LogManager().initialize_custom_handler() # Set debugging to true so that we get more verbose output, (should only be used for testing). sgtk.LogManager().global_debug = True # Authentication ################ # Instantiate the authenticator object. authenticator = sgtk.authentication.ShotgunAuthenticator() # Create a user programmatically using the script's key. user = authenticator.create_script_user( api_script="Script Name", api_key="4e48f....", host="https://yoursite.shotgunstudio.com" ) # Tells Toolkit which user to use for connecting to ShotGrid. # This is actually not necessary when using the ToolkitManager. The authenticated user will be set # before launching the engine. # sgtk.set_authenticated_user(user) # Bootstrap # ######### # create an instance of the ToolkitManager which we will use to set a bunch of settings before initiating the bootstrap. mgr = sgtk.bootstrap.ToolkitManager(user) mgr.plugin_id = "basic.shell" project = {"type": "Project", "id": 176} engine = mgr.bootstrap_engine("tk-shell", entity=project) ``` -------------------------------- ### SetupProjectWizard API Reference Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pc_framework_adminui_html A QWizard implementation that guides users through setting up a Project from their Flow Production Tracking instance for Toolkit. Instantiate the class with the project details and a parent window to launch the wizard. ```APIDOC ## SetupProjectWizard Constructor ### Description Initialize a SetupProjectWizard. This is a subclass of QtGui.QWizard. ### Method Constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import sgtk adminui = sgtk.platform.import_framework("tk-framework-adminui", "setup_project") # Assuming 'project' is a dictionary representing the Flow Production Tracking project # and 'parent' is a QWidget instance setup = adminui.SetupProjectWizard(project, parent) dialog_result = setup.exec_() ``` ### Response #### Success Response (200) Returns a standard QDialog Accepted or Rejected value indicating the user's action. #### Response Example ``` QDialog.Accepted or QDialog.Rejected ``` ``` -------------------------------- ### Install Flow Production Tracking Event Daemon as a Windows Service Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_tr_event_daemon_installation_html Installs the Flow Production Tracking Event Daemon as a Windows service. Requires Python with PyWin32. The command takes the path to the Python executable and the script name as arguments. ```shell > C:\Python27_32\python.exe shotgunEventDaemon.py install ``` -------------------------------- ### Start Enterprise Console Docker Container Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SG_Enterprise_do_console_do_console_docker_html&p=SGSUB This command starts the Enterprise Console Docker container in detached mode. By default, SEC will be accessible on port 8080. ```bash sudo docker-compose up -d ``` -------------------------------- ### SetupProjectWizard Constructor Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pc_framework_adminui_html Shows the basic constructor for the SetupProjectWizard class. This class is a subclass of QtGui.QWizard and is used to initialize the wizard for setting up a project. ```python SetupProjectWizard() ``` -------------------------------- ### Example File Path with Defined Key Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pg_integrations_admin_guides_file_system_configuration_html Illustrates how a defined key, such as 'name', can be incorporated into a file path template. This shows the practical application of keys in constructing file paths based on project structure and defined key properties. ```yaml nuke_shot_work: sequences/{Sequence}/{Shot}/{Step}/work/nuke/{name}.v{version}.nk ``` -------------------------------- ### Bootstrap Toolkit for Nuke on Render Farm (Python) Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pc_nuke_write_node_html This script demonstrates bootstrapping the Toolkit framework for Nuke on a render farm. It sets up the Python path, authenticates with ShotGrid using environment variables, and initializes the Nuke engine. Ensure necessary environment variables like SHOTGUN_SGTK_MODULE_PATH, SHOTGUN_SITE, SHOTGUN_FARM_SCRIPT_USER, SHOTGUN_FARM_SCRIPT_KEY, and SHOTGUN_CONFIG_URI are set. ```python import sys import os # If your render nodes can access the same tk-core install location as # artist workstations, retrieve its path from the environment and ensure # it is in the PYTHONPATH TK_CORE_PATH = os.environ["SHOTGUN_SGTK_MODULE_PATH"] if TK_CORE_PATH not in sys.path: sys.path.append(TK_CORE_PATH) # If your render nodes don’t have access to the Toolkit Core API in the same filesystem location as artist workstations, you have to make sure that it is available in the PYTHONPATH, so that render nodes can import it. An easy way # to install tk-core in a centralized location is with pip. You can read more # about it here: # https://developer.shotgridsoftware.com/tk-core/bootstrap.html#installing-the-sgtk-module-using-pip import sgtk # Authenticate using a pre-defined script user. sa = sgtk.authentication.ShotgunAuthenticator() # Here we retrieve credentials from environment variables, assuming a script user # will be used when rendering. This should be typically be handled by your render # farm administrators. SG_SITE_URL = os.environ["SHOTGUN_SITE"] SG_SCRIPT_USER = os.environ["SHOTGUN_FARM_SCRIPT_USER"] SG_SCRIPT_KEY = os.environ["SHOTGUN_FARM_SCRIPT_KEY"] user = sa.create_script_user( api_script=SG_SCRIPT_USER, api_key=SG_SCRIPT_KEY, host=SG_SITE_URL ) # Start up a Toolkit Manager with our script user mgr = sgtk.bootstrap.ToolkitManager(sg_user=user) # Set the base pipeline configuration from the environment variable: mgr.base_configuration = os.environ["SHOTGUN_CONFIG_URI"] # Disable Flow Production Tracking lookup to ensure that we are getting the Pipeline # Configuration defined in SHOTGUN_CONFIG_URI, and not a dev or override # Pipeline Configuration defined in Flow Production Tracking. mgr.do_shotgun_config_lookup = False # Set a plugin id to indicate to the bootstrap that we are starting # up a standard Nuke integration mgr.plugin_id = "basic.nuke" # Retrieve the Toolkit context from environment variables: # SHOTGUN_SITE: The Flow Production Tracking site url # SHOTGUN_ENTITY_TYPE: The Flow Production Tracking Entity type, e.g. Shot # SHOTGUN_ENTITY_ID: The Flow Production Tracking Entity id, e.g. 1234 sg_entity = mgr.get_entity_from_environment() # Now start up the Nuke engine for a given Flow Production Tracking Entity nuke_engine = mgr.bootstrap_engine("tk-nuke", entity=sg_entity) ``` -------------------------------- ### File Path Template Example Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_qa_troubleshooting_qa_context_missing_task_step_html This example demonstrates a file path template used in Toolkit. It shows how folder structures like 'Asset' and 'Step' are registered, but 'Task' might be missing if not explicitly defined in the schema, leading to context resolution issues. ```yaml assets/{sg_asset_type}/{Asset}/{Step}/work/maya/{task_name}_{name}.v{version}.{maya_extension} ``` -------------------------------- ### Test folder creation using the 'tank folders' command Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pg_developer_pg_getting_started_dynamic_filesystem_config_html This demonstrates how to test the folder creation logic using the Toolkit command-line interface. It involves navigating to the pipeline configuration root folder and executing the 'tank Asset Filet folders' command. The output shows the structure of the created folders, confirming the new filtering logic is applied correctly. ```bash > cd > ./tank Asset Filet folders ``` -------------------------------- ### Breakdown API Example in Python Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pc_app_breakdown_html An example demonstrating how to retrieve scene breakdown items and update all items that are not using the latest version. This involves initializing the ShotGrid Toolkit engine, accessing the 'tk-multi-breakdown' app, and then calling `analyze_scene()` to get the list of items. ```python # find the breakdown app instance import sgtk engine = sgtk.platform.current_engine() breakdown_app = engine.apps["tk-multi-breakdown"] # get list of breakdown items items = breakdown_app.analyze_scene() ``` -------------------------------- ### Defer Folder Creation with Tank Command (Shell) Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_qa_troubleshooting_qa_performance_troubleshooting_html This example illustrates how to defer the creation of root-level folders until explicitly run via the 'tank folders' command. This is useful for folders that only need to be created once at the project's inception. ```yaml # Example schema configuration for a root folder # ... other configurations ... defer_creation: "tk-shell" ``` ```shell # Command to run folder creation with the 'tk-shell' keyword tank folders ``` -------------------------------- ### Clone Flow Production Tracking Events Source Code (Git) Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_tr_event_daemon_installation_html This command clones the Flow Production Tracking Events repository from GitHub using Git. It's the recommended method for easily updating the source code. Ensure Git is installed on the machine before executing. ```shell $ cd /usr/local/shotgun $ git clone git://github.com/shotgunsoftware/shotgunEvents.git ``` -------------------------------- ### List Registered Commands with pprint Source: https://help.autodesk.com/view/SGDEV/ENU/index_guid=SGD_pg_developer_pg_sgtk_developer_bootstrapping_html This snippet demonstrates how to use the `pprint` module to display a formatted list of registered commands available in the engine. It's useful for inspecting available actions. ```python import pprint pprint.pprint(engine.commands.keys()) ```