pyshotgrid


Namepyshotgrid JSON
Version 2.0.2 PyPI version JSON
download
home_pageNone
SummaryA pythonic and object oriented way to talk to Autodesk ShotGrid.
upload_time2024-05-04 20:47:25
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords shotgrid
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <img src="https://github.com/fabiangeisler/pyshotgrid/blob/main/icons/pysg_logo.png?raw=true" />
</p>

[![VFX Platform](https://img.shields.io/badge/vfxplatform-2024%20%7C%202023%20%7C%202022-white.svg)](http://www.vfxplatform.com/)
[![pypi](https://img.shields.io/pypi/v/pyshotgrid.svg)](https://pypi.python.org/pypi/pyshotgrid)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pyshotgrid.svg)](https://pypi.python.org/pypi/pyshotgrid/)
[![Tests](https://github.com/fabiangeisler/pyshotgrid/actions/workflows/Tests.yml/badge.svg)](https://github.com/fabiangeisler/pyshotgrid/actions/workflows/Tests.yml)
[![coverage](https://img.shields.io/badge/%20coverage-99%25-%231674b1?style=flat&color=darkgreen)](https://github.com/fabiangeisler/pyshotgrid/actions/workflows/Tests.yml)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)

`pyshotgrid` is a python package that gives you a pythonic and
object oriented way to talk to [Autodesk Flow Production Tracking](https://www.autodesk.com/products/flow-production-tracking/overview)
(formally known as ShotGrid).

# Quickstart

Install `pyshotgrid` via pip:

```shell
pip install pyshotgrid
```

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

```python
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][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
  ```python
  # 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
  ```python
  # 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.
  ```python
  # Name of the first Version in a Playlist.
  print(sg_playlist["versions"].get()[0]["code"].get())
  ```
* Get information about a field
  ```python
  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
  ```python
  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
  ```python
  print(sg_project.url)  # https://example.shotgunstudio.com/detail/Project/1
  ```
* Convert it to a regular dict, to use it in Autodesk [shotgun_api3][shotgun_api3].
  ```python
  sg_project.to_dict()  # {"type": "Project", "id": 1}
  ```
* Iterate over all fields
  ```python
  # 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:
  ```python
  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][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][SGProject]) gives you additional functions
  to query shots, assets or publishes:
  ```python
  sg_project.shots()
  sg_project.assets()
  sg_project.publishes()
  ```
  Checkout the [overview of all the default entities][Overview default entities] and the
  [API documentation][API sg_default_entities] 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][How to add custom entities] in the docs.

# FAQ

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

## Is `pyshotgrid` replacing [shotgun_api3][shotgun_api3]?
No, quite the opposite. It is meant to be used in conjunction with [shotgun_api3][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][shotgun_api3]. That said,
it is totally possible to write `pyshotgrid` code without using [shotgun_api3][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][SGEntity] to provide
a minimum of functionality in all cases. However you can write your own class
that inherits from [SGEntity][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`.

## Why does `pyshotgrid` not support Python 3.7? [shotgun_api3][shotgun_api3] has support for it.
A couple of reasons:
- [Python 3.7 reached EOL](https://devguide.python.org/versions/) and is no longer maintained.
- Python 3.7 is soon off the [VFX Reference Platform](https://vfxplatform.com/).
- The hidden goal of this project is to create a python library that uses the latest
  innovations in the Python world.
  In a nutshell I want to create the simplest setup that gives you:
  - automatic publishing to PyPI
  - automatic testing with tox, pytest and coverage
  - automatic [Sphinx](https://www.sphinx-doc.org/en/master/) documentation
  - [mypy](https://mypy-lang.org/) type hints
  - [ruff](https://github.com/astral-sh/ruff) linting
  - [black](https://github.com/psf/black) code formatting (actually done by `ruff format`)
  - [pre-commit](https://github.com/pre-commit/pre-commit) checks
  - [invoke](https://www.pyinvoke.org/) setup for common tasks in the repository
  - streamlined commit messages and changelog with [commitizen](https://github.com/commitizen-tools/commitizen)

  A good chunk of these tools do not support Python 3.7 anymore and I do not have the time to
  keep up the compatibility.

## Is this an official project from Autodesk?
No, just a brainchild from me, [Fabian Geisler](https://github.com/fabiangeisler).
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](https://github.com/audreyr/cookiecutter) and
the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template
(but was heavily modified in the meantime).

[SGEntity]: https://fabiangeisler.github.io/pyshotgrid/modules/core.html#pyshotgrid.core.SGEntity
[SGProject]: https://fabiangeisler.github.io/pyshotgrid/modules/sg_default_entities.html#pyshotgrid.sg_default_entities.SGProject
[Overview default entities]: https://fabiangeisler.github.io/pyshotgrid/default_entities_overview.html
[API sg_default_entities]: https://fabiangeisler.github.io/pyshotgrid/modules/sg_default_entities.html
[How to add custom entities]: https://fabiangeisler.github.io/pyshotgrid/how_to_add_custom_entities.html
[shotgun_api3]: https://github.com/shotgunsoftware/python-api

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyshotgrid",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "shotgrid",
    "author": null,
    "author_email": "Fabian Geisler <info@fasbue.com>",
    "download_url": "https://files.pythonhosted.org/packages/a0/0c/c42fc695cd95d0adcd1ea6da6a87c57ca82e41ff0ca642844071d3791d88/pyshotgrid-2.0.2.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <img src=\"https://github.com/fabiangeisler/pyshotgrid/blob/main/icons/pysg_logo.png?raw=true\" />\n</p>\n\n[![VFX Platform](https://img.shields.io/badge/vfxplatform-2024%20%7C%202023%20%7C%202022-white.svg)](http://www.vfxplatform.com/)\n[![pypi](https://img.shields.io/pypi/v/pyshotgrid.svg)](https://pypi.python.org/pypi/pyshotgrid)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pyshotgrid.svg)](https://pypi.python.org/pypi/pyshotgrid/)\n[![Tests](https://github.com/fabiangeisler/pyshotgrid/actions/workflows/Tests.yml/badge.svg)](https://github.com/fabiangeisler/pyshotgrid/actions/workflows/Tests.yml)\n[![coverage](https://img.shields.io/badge/%20coverage-99%25-%231674b1?style=flat&color=darkgreen)](https://github.com/fabiangeisler/pyshotgrid/actions/workflows/Tests.yml)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n\n`pyshotgrid` is a python package that gives you a pythonic and\nobject oriented way to talk to [Autodesk Flow Production Tracking](https://www.autodesk.com/products/flow-production-tracking/overview)\n(formally known as ShotGrid).\n\n# Quickstart\n\nInstall `pyshotgrid` via pip:\n\n```shell\npip install pyshotgrid\n```\n\nYou are now ready to use it in your project (For other installation methods see the\n[Installation](https://fabiangeisler.github.io/pyshotgrid/installation.html) section in the documentation)!\nHere is a quick example to list the \"code\" (aka. \"name\") of all shots from all projects:\n\n```python\nimport pyshotgrid as pysg\n\nsite = pysg.new_site(base_url='https://example.shotgunstudio.com',\n                     script_name='Some User',\n                     api_key='$ome_password')\n\nfor project in site.projects():\n    print(project[\"name\"].get())\n    for shot in project.shots():\n        print(shot[\"code\"].get())\n```\n\n# Features\n\nIn `pyshotgrid` you are working with [SGEntity][SGEntity] instances which each represent exactly one entity\nin ShotGrid. Any operation on it is reflected to ShotGrid.\nSo for example you can :\n\n* Get entity fields in ShotGrid\n  ```python\n  # Get the value of a field ...\n  print(sg_project[\"name\"].get())  # \"foobar\"\n  # ... or get multiple fields at once.\n  print(sg_project.get([\"name\", \"tank_name\"]))  # {\"name\": \"foobar\", \"tank_name\": \"fb\"}\n  ```\n* Update entity fields in ShotGrid\n  ```python\n  # Set the value of a field ...\n  sg_project[\"name\"].set(\"foobar\")\n  # ... or set multiple fields at once.\n  sg_project.set({\"name\": \"foobar\", \"tank_name\": \"fb\"})\n  ```\n* Values are automatically converted to `pyshotgrid` objects which makes it\n  possible to chain queries together.\n  ```python\n  # Name of the first Version in a Playlist.\n  print(sg_playlist[\"versions\"].get()[0][\"code\"].get())\n  ```\n* Get information about a field\n  ```python\n  print(sg_project[\"name\"].data_type)     # \"text\"\n  print(sg_project[\"name\"].description)   # \"The name of the project.\"\n  print(sg_project[\"name\"].display_name)  # \"Project Name\"\n  ```\n* Upload/Download to/from a field\n  ```python\n  sg_version['sg_uploaded_movie'].upload('/path/to/movie.mov')\n  sg_version['sg_uploaded_movie'].download('/path/to/download/to/')\n  ```\n* Get the URL of the entity\n  ```python\n  print(sg_project.url)  # https://example.shotgunstudio.com/detail/Project/1\n  ```\n* Convert it to a regular dict, to use it in Autodesk [shotgun_api3][shotgun_api3].\n  ```python\n  sg_project.to_dict()  # {\"type\": \"Project\", \"id\": 1}\n  ```\n* Iterate over all fields\n  ```python\n  # Iterate over the fields directly to get some information about them...\n  for field, value in sg_project.fields().items():\n       print(field.display_name)\n  # ... or iterate over the fields and values at the same time.\n  for field_name, value in sg_project.all_field_values().items():\n       print(field_name, value)\n  ```\n* Do you keep forgetting which field is the \"name\" of an entity? (was it \"code\" or \"name\"?)\n  Just use the \"SGEntity.name\" property:\n  ```python\n  sg_project.name  # returns the \"name\" field.    Same as:  sg_project[\"name\"]\n  sg_shot.name     # returns the \"code\" field.    Same as:  sg_shot[\"code\"]\n  sg_task.name     # returns the \"content\" field. Same as:  sg_task[\"content\"]\n  ```\n\n* It is possible to inherit from [SGEntity][SGEntity] and create implementations for specific\n  entity types. `pyshotgrid` ships with a few common entities by default. For example\n  the implementation for the `Project` entity ([SGProject][SGProject]) gives you additional functions\n  to query shots, assets or publishes:\n  ```python\n  sg_project.shots()\n  sg_project.assets()\n  sg_project.publishes()\n  ```\n  Checkout the [overview of all the default entities][Overview default entities] and the\n  [API documentation][API sg_default_entities] for all the extra functionality!\n  As an additional bonus: You can customize and extend all these classes to your hearts content.\n  Have a look at [How to add custom entities][How to add custom entities] in the docs.\n\n# FAQ\n\n## Is it faster than [shotgun_api3][shotgun_api3]?\nNo, and since it is build on top of [shotgun_api3][shotgun_api3], it never will be.\n`pyshotgrid` is syntactic sugar that hopefully enables you to develop better and faster. :)\n\n## Is `pyshotgrid` replacing [shotgun_api3][shotgun_api3]?\nNo, quite the opposite. It is meant to be used in conjunction with [shotgun_api3][shotgun_api3] and\nimprove handling and writing code with it. Its main goal is to make it easier to write\ncode for common scenarios and leave the special cases for [shotgun_api3][shotgun_api3]. That said,\nit is totally possible to write `pyshotgrid` code without using [shotgun_api3][shotgun_api3].\n\n## I have some custom entity setup in ShotGrid. Can this be reflected in `pyshotgrid`?\nYes, it can! By default `pyshotgrid` returns any entity as [SGEntity][SGEntity] to provide\na minimum of functionality in all cases. However you can write your own class\nthat inherits from [SGEntity][SGEntity] and register that to `pyshotgrid`. After that,\n`pyshotgrid` will use your custom entity whenever you ask for it. With this method\nyou can even overwrite default classes that ship with `pyshotgrid`.\n\n## Why does `pyshotgrid` not support Python 3.7? [shotgun_api3][shotgun_api3] has support for it.\nA couple of reasons:\n- [Python 3.7 reached EOL](https://devguide.python.org/versions/) and is no longer maintained.\n- Python 3.7 is soon off the [VFX Reference Platform](https://vfxplatform.com/).\n- The hidden goal of this project is to create a python library that uses the latest\n  innovations in the Python world.\n  In a nutshell I want to create the simplest setup that gives you:\n  - automatic publishing to PyPI\n  - automatic testing with tox, pytest and coverage\n  - automatic [Sphinx](https://www.sphinx-doc.org/en/master/) documentation\n  - [mypy](https://mypy-lang.org/) type hints\n  - [ruff](https://github.com/astral-sh/ruff) linting\n  - [black](https://github.com/psf/black) code formatting (actually done by `ruff format`)\n  - [pre-commit](https://github.com/pre-commit/pre-commit) checks\n  - [invoke](https://www.pyinvoke.org/) setup for common tasks in the repository\n  - streamlined commit messages and changelog with [commitizen](https://github.com/commitizen-tools/commitizen)\n\n  A good chunk of these tools do not support Python 3.7 anymore and I do not have the time to\n  keep up the compatibility.\n\n## Is this an official project from Autodesk?\nNo, just a brainchild from me, [Fabian Geisler](https://github.com/fabiangeisler).\nI am a Pipeline Developer based in Berlin.\nFeel free to follow me on GitHub. :)\n\n## How will the rebranding from \"ShotGrid\" to \"Flow Production Tracking\" affect this project?\nThere will be no code-breaking name changes and `pyshotgrid` will not be rebranded.\nOnly docs and docstrings will use the new name.\n\n# Credits\n\nThis package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and\nthe [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template\n(but was heavily modified in the meantime).\n\n[SGEntity]: https://fabiangeisler.github.io/pyshotgrid/modules/core.html#pyshotgrid.core.SGEntity\n[SGProject]: https://fabiangeisler.github.io/pyshotgrid/modules/sg_default_entities.html#pyshotgrid.sg_default_entities.SGProject\n[Overview default entities]: https://fabiangeisler.github.io/pyshotgrid/default_entities_overview.html\n[API sg_default_entities]: https://fabiangeisler.github.io/pyshotgrid/modules/sg_default_entities.html\n[How to add custom entities]: https://fabiangeisler.github.io/pyshotgrid/how_to_add_custom_entities.html\n[shotgun_api3]: https://github.com/shotgunsoftware/python-api\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A pythonic and object oriented way to talk to Autodesk ShotGrid.",
    "version": "2.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/fabiangeisler/pyshotgrid/issues",
        "Documentation": "https://fabiangeisler.github.io/pyshotgrid",
        "Homepage": "https://github.com/fabiangeisler/pyshotgrid"
    },
    "split_keywords": [
        "shotgrid"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ebe77d58ea82cfd1a3624ef596ee0b661ccb82fcc379bb37e04e71cce3e2ea8",
                "md5": "403a283c528462023232b27977e14cba",
                "sha256": "bfb6591e88691ca4e51d29dc0a297e4896ccf869ba499b227bef345c9a8a1e83"
            },
            "downloads": -1,
            "filename": "pyshotgrid-2.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "403a283c528462023232b27977e14cba",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 21493,
            "upload_time": "2024-05-04T20:47:23",
            "upload_time_iso_8601": "2024-05-04T20:47:23.825663Z",
            "url": "https://files.pythonhosted.org/packages/0e/be/77d58ea82cfd1a3624ef596ee0b661ccb82fcc379bb37e04e71cce3e2ea8/pyshotgrid-2.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a00cc42fc695cd95d0adcd1ea6da6a87c57ca82e41ff0ca642844071d3791d88",
                "md5": "2dbcd5d189890d9c2bfa45c3b1e4f045",
                "sha256": "62338f7e7dfaaae90b5717efdfd40babbeabc751588868585057a5cf6649670d"
            },
            "downloads": -1,
            "filename": "pyshotgrid-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2dbcd5d189890d9c2bfa45c3b1e4f045",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 138782,
            "upload_time": "2024-05-04T20:47:25",
            "upload_time_iso_8601": "2024-05-04T20:47:25.583518Z",
            "url": "https://files.pythonhosted.org/packages/a0/0c/c42fc695cd95d0adcd1ea6da6a87c57ca82e41ff0ca642844071d3791d88/pyshotgrid-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-04 20:47:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fabiangeisler",
    "github_project": "pyshotgrid",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pyshotgrid"
}
        
Elapsed time: 0.23739s