Skip to main content

A pythonic and object oriented way to talk to Autodesk ShotGrid.

Project description

VFX Platform pypi PyPI pyversions Tests coverage pre-commit Code style: black Ruff Checked with mypy

pyshotgrid is a python package that gives you a pythonic and object-oriented way to talk to Autodesk Flow Production Tracking (formerly known as ShotGrid or Shotgun).

Quickstart

Install pyshotgrid via pip:

pip install pyshotgrid

You are now ready to use it in your project (For other installation methods see the Installation section in the documentation)! Here is a quick example to list the "code" (aka. "name") of all shots from all projects:

import pyshotgrid as pysg

site = pysg.new_site(base_url='https://example.shotgunstudio.com',
                     script_name='Some User',
                     api_key='$ome_password')

for project in site.projects():
    print(project["name"].get())
    for shot in project.shots():
        print(shot["code"].get())

Features

In pyshotgrid you are working with SGEntity instances which each represent exactly one entity in ShotGrid. Any operation on it is reflected to ShotGrid. So for example you can :

  • Get entity fields in ShotGrid

    # Get the value of a field ...
    print(sg_project["name"].get())  # "foobar"
    # ... or get multiple fields at once.
    print(sg_project.get(["name", "tank_name"]))  # {"name": "foobar", "tank_name": "fb"}
    
  • Update entity fields in ShotGrid

    # Set the value of a field ...
    sg_project["name"].set("foobar")
    # ... or set multiple fields at once.
    sg_project.set({"name": "foobar", "tank_name": "fb"})
    
  • Values are automatically converted to pyshotgrid objects which makes it possible to chain queries together.

    # Name of the first Version in a Playlist.
    print(sg_playlist["versions"].get()[0]["code"].get())
    
  • Get information about a field

    print(sg_project["name"].data_type)     # "text"
    print(sg_project["name"].description)   # "The name of the project."
    print(sg_project["name"].display_name)  # "Project Name"
    
  • Upload/Download to/from a field

    sg_version['sg_uploaded_movie'].upload('/path/to/movie.mov')
    sg_version['sg_uploaded_movie'].download('/path/to/download/to/')
    
  • Get the URL of the entity

    print(sg_project.url)  # https://example.shotgunstudio.com/detail/Project/1
    
  • Convert it to a regular dict, to use it in Autodesk shotgun_api3.

    sg_project.to_dict()  # {"type": "Project", "id": 1}
    
  • Iterate over all fields

    # Iterate over the fields directly to get some information about them...
    for field, value in sg_project.fields().items():
         print(field.display_name)
    # ... or iterate over the fields and values at the same time.
    for field_name, value in sg_project.all_field_values().items():
         print(field_name, value)
    
  • Do you keep forgetting which field is the "name" of an entity? (was it "code" or "name"?) Just use the "SGEntity.name" property:

    sg_project.name  # returns the "name" field.    Same as:  sg_project["name"]
    sg_shot.name     # returns the "code" field.    Same as:  sg_shot["code"]
    sg_task.name     # returns the "content" field. Same as:  sg_task["content"]
    
  • It is possible to inherit from SGEntity and create implementations for specific entity types. pyshotgrid ships with a few common entities by default. For example the implementation for the Project entity (SGProject) gives you additional functions to query shots, assets or publishes:

    sg_project.shots()
    sg_project.assets()
    sg_project.publishes()
    

    Checkout the overview of all the default entities and the API documentation for all the extra functionality! As an additional bonus: You can customize and extend all these classes to your hearts content. Have a look at How to add custom entities in the docs.

FAQ

Is it faster than shotgun_api3?

No, and since it is build on top of shotgun_api3, it never will be. pyshotgrid is syntactic sugar that hopefully enables you to develop better and faster. :)

Is pyshotgrid replacing shotgun_api3?

No, quite the opposite. It is meant to be used in conjunction with shotgun_api3 and improve handling and writing code with it. Its main goal is to make it easier to write code for common scenarios and leave the special cases for shotgun_api3. That said, it is totally possible to write pyshotgrid code without using shotgun_api3.

I have some custom entity setup in ShotGrid. Can this be reflected in pyshotgrid?

Yes, it can! By default pyshotgrid returns any entity as SGEntity to provide a minimum of functionality in all cases. However, you can write your own class that inherits from SGEntity and register that to pyshotgrid. After that, pyshotgrid will use your custom entity whenever you ask for it. With this method you can even overwrite default classes that ship with pyshotgrid.

Is this an official project from Autodesk?

No, just a brainchild from me, Fabian Geisler. I am a Pipeline Developer based in Berlin. Feel free to follow me on GitHub. :)

How will the rebranding from "ShotGrid" to "Flow Production Tracking" affect this project?

There will be no code-breaking name changes and pyshotgrid will not be rebranded. Only docs and docstrings will use the new name.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template (but was heavily modified in the meantime).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyshotgrid-2.1.0.tar.gz (137.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyshotgrid-2.1.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file pyshotgrid-2.1.0.tar.gz.

File metadata

  • Download URL: pyshotgrid-2.1.0.tar.gz
  • Upload date:
  • Size: 137.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyshotgrid-2.1.0.tar.gz
Algorithm Hash digest
SHA256 0e89eeba8c46824ed4aef5ba7903be5d0b2ddc1676c2715f1320240dcc16a06a
MD5 f5b5eea9e9b4077b5476907d450b8440
BLAKE2b-256 559f98290fe234ef6ba01659cd38c41f491dd2a915879b25a9e330dd92392d62

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshotgrid-2.1.0.tar.gz:

Publisher: Release.yml on fabiangeisler/pyshotgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshotgrid-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyshotgrid-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyshotgrid-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a869b935979c73f30c3a46e3c8b87941a79f4e6c0a43baa273b550fd3722f7c9
MD5 e24859976f24301149394bdc67e74201
BLAKE2b-256 386cec75a227c7a3dc01c0b356a7c0b9e2c0d4aaf447a3ed2cb533ac636c39f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshotgrid-2.1.0-py3-none-any.whl:

Publisher: Release.yml on fabiangeisler/pyshotgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page