Skip to main content

A thread-safe wrapper around Flow Production Tracking (formerly ShotGrid) with query field support

Project description

fpt-api

A thread-safe wrapper around Flow Production Tracking (formerly ShotGrid) that extends shotgun_api3 to support query field retrieval and parallel processing.

It also supports the retrieval of all Entities of a given Page, applying the Page filters.

Features

  • 🔍 Retrieves query fields (not supported in base shotgun_api3)
  • 📄 Retrieves all Entities of a given Page, applying the Page filters
  • 🧵 Thread-safe operations (not supported in base shotgun_api3)
  • ⚡ Parallel processing for improved performance
  • 🔄 Streaming results for processing large datasets
  • 🔌 Drop-in replacement for basic shotgun_api3 operations
  • • Supports dotted query fields, e.g. entity.Shot.sg_assets_count

Installation

From PyPI:

pip install fpt-api
pip install git+https://github.com/shotgunsoftware/python-api.git

From source:

pip install git+https://github.com/ksallee/fpt-api.git
pip install git+https://github.com/shotgunsoftware/python-api.git

Why This Wrapper?

The standard shotgun_api3 library has two main limitations:

  1. No support for query field retrieval, which is essential for reporting and analytics
  2. Not thread-safe, which can cause issues in multi-threaded applications

This wrapper addresses both issues by:

  • Implementing query field retrieval
  • Adding thread safety
  • Parallelizing query field retrieval for better performance
  • Supporting streaming for large result sets

Usage

Basic Usage

from fpt_api import FPT

# Initialize the client
fpt = FPT(
    "https://yourshotgunurl.com",
    script_name="your_script_name",
    api_key="your_script_key"
)

# Find a single shot
shot = fpt.find_one(
    "Shot",
    [["id", "is", 1234]],
    ["code", "sg_status_list", "sg_query_field"]
)

# Find multiple shots (returns all results at once)
shots = fpt.find(
    "Shot",
    [["id", "in", [1234, 12345]]],
    ["code", "sg_status_list", "sg_query_field"]
)

# Stream results one by one
for shot in fpt.yield_find(
    "Shot",
    [["id", "in", [1234, 12345]]],
    ["code", "sg_status_list", "sg_query_field"]
):
    process_shot(shot)  # Process each shot as it becomes ready

# Get the value of a dotted query field
version = fpt.find_one(
    "Version",
    [["id", "is", 1234]],
    ["entity.Shot.sg_assets_count"]
)

# Get all Entities of a given Page, applying the Page filters
for shot in fpt.yield_page_entities(5105):
    print(shot)

API Reference

Check out the Official Shotgun API Reference for more information on the base shotgun_api3 library. FPT does not change the base API, but rather extends it with additional functionality.

Yield all Entities of a given Page, applying the Page filters:

def yield_page_entities(
    self,
    page_id: int,
    additional_filters: Optional[List] = None,
    fields: Optional[List[str]] = None,
) -> Iterator[Entity]:
    """
    Yield entities from a Page, applying the Page filters.

    :param page_id: ID of the Page to process
    :param additional_filters: Additional filters to apply
    :param fields: Fields to retrieve
    :yields: Entities found
    """

Performance Notes

  • Query fields are retrieved in parallel using threads
  • For standard find(), results are returned after all query fields are retrieved
  • yield_find() streams results as they become available
  • Connection pooling reduces overhead for multiple requests

Contributing

Contributions are welcome! Please feel free to submit pull requests.

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

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

fpt_api-0.3.3.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

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

fpt_api-0.3.3-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file fpt_api-0.3.3.tar.gz.

File metadata

  • Download URL: fpt_api-0.3.3.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for fpt_api-0.3.3.tar.gz
Algorithm Hash digest
SHA256 68d1578b75085b2f3739a758295b2a58c80633618f929ad125eb5eb589ea49bc
MD5 64d98e6d5dc1918d2d3b6a6e5997f395
BLAKE2b-256 9ba2656b005cadb17da8fd7e58baeeaeab2fecf216a0736e58d3d8644635a264

See more details on using hashes here.

File details

Details for the file fpt_api-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: fpt_api-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for fpt_api-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cc5d693537371a61faa7e0ee01a63c44f37c61b6328a4fb2252afeea61223f28
MD5 f671ee56faeb6d2635a4147eee98df88
BLAKE2b-256 7e7f983b2d6ee517c3966b2c5dd7542778fe694a89cb726b7afac1b34c72728b

See more details on using hashes here.

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