sg-python-api 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sg_python_api-0.1.0.dist-info/METADATA +177 -0
- sg_python_api-0.1.0.dist-info/RECORD +31 -0
- sg_python_api-0.1.0.dist-info/WHEEL +4 -0
- sg_python_api-0.1.0.dist-info/licenses/LICENSE +21 -0
- shotgun_api3/__init__.py +68 -0
- shotgun_api3/_async_client.py +2906 -0
- shotgun_api3/_async_driver.py +945 -0
- shotgun_api3/_async_httpx2.py +662 -0
- shotgun_api3/_async_transport.py +162 -0
- shotgun_api3/_capabilities.py +165 -0
- shotgun_api3/_client.py +2682 -0
- shotgun_api3/_config.py +1463 -0
- shotgun_api3/_crud.py +916 -0
- shotgun_api3/_driver.py +879 -0
- shotgun_api3/_errors.py +49 -0
- shotgun_api3/_execution.py +273 -0
- shotgun_api3/_files.py +1094 -0
- shotgun_api3/_methods.py +1205 -0
- shotgun_api3/_protocol.py +1347 -0
- shotgun_api3/_sentinel.py +5 -0
- shotgun_api3/_sg_timezone.py +5 -0
- shotgun_api3/_signatures.py +53 -0
- shotgun_api3/_transport.py +901 -0
- shotgun_api3/_version.py +3 -0
- shotgun_api3/lib/__init__.py +1 -0
- shotgun_api3/lib/mockgun/__init__.py +16 -0
- shotgun_api3/lib/mockgun/_async.py +315 -0
- shotgun_api3/lib/mockgun/_mockgun.py +1666 -0
- shotgun_api3/lib/sgtimezone.py +209 -0
- shotgun_api3/py.typed +0 -0
- shotgun_api3/shotgun.py +58 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: sg-python-api
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for Autodesk Flow Production Tracking
|
|
5
|
+
Project-URL: Documentation, https://github.com/dactylo/sg-python-api/tree/main/docs
|
|
6
|
+
Project-URL: Homepage, https://github.com/dactylo/sg-python-api
|
|
7
|
+
Project-URL: Issues, https://github.com/dactylo/sg-python-api/issues
|
|
8
|
+
Project-URL: Repository, https://github.com/dactylo/sg-python-api
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: api,flow-production-tracking,shotgrid,shotgun,shotgun-api3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: urllib3<3,>=2
|
|
21
|
+
Provides-Extra: async
|
|
22
|
+
Requires-Dist: httpx2<3,>=2; extra == 'async'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# sg-python-api
|
|
26
|
+
|
|
27
|
+
sg-python-api is a Python client for Autodesk Flow Production Tracking, written for pipeline tools
|
|
28
|
+
and scripts built on Autodesk's `shotgun_api3` client. It keeps the same import name and documented
|
|
29
|
+
API, so an existing integration can switch without rewriting its calls and gain shared connections,
|
|
30
|
+
bounded network waits, and retries that do not repeat an ambiguous write. It also adds a native
|
|
31
|
+
asynchronous client.
|
|
32
|
+
|
|
33
|
+
This documentation uses SG for Flow Production Tracking, formerly named Shotgun and ShotGrid.
|
|
34
|
+
|
|
35
|
+
## Why use it?
|
|
36
|
+
|
|
37
|
+
- **Reuse connections:** share one synchronous client across threads, or one async client across
|
|
38
|
+
tasks on the same event loop.
|
|
39
|
+
- **Bound network waits:** default connect and read timeouts help applications recover from an
|
|
40
|
+
unavailable service.
|
|
41
|
+
- **Handle writes carefully:** retries account for whether an operation is safe to repeat. An
|
|
42
|
+
ambiguous write is left for the application to reconcile.
|
|
43
|
+
- **Test without a site:** synchronous and asynchronous `mockgun` clients provide an in-memory API
|
|
44
|
+
for application tests.
|
|
45
|
+
|
|
46
|
+
sg-python-api is an independent implementation of the documented API of Autodesk's Python client
|
|
47
|
+
`3.10.2`. Some behavior differs on purpose, so validate your application's workflows against a test
|
|
48
|
+
site before replacing its production client. The [migration guide](https://github.com/dactylo/sg-python-api/blob/v0.1.0/docs/migration-guide.md) walks
|
|
49
|
+
through the switch, and the [compatibility reference](https://github.com/dactylo/sg-python-api/blob/v0.1.0/COMPATIBILITY.md) lists the differences.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
You need Python 3.11 or newer and an SG site running server version 7.10.0 or newer. Authenticated
|
|
54
|
+
requests to a remote site require HTTPS.
|
|
55
|
+
|
|
56
|
+
`sg-python-api` and Autodesk's `shotgun-api3` both install the `shotgun_api3` package, so install
|
|
57
|
+
exactly one of them in a Python environment. If the official client is already installed, follow
|
|
58
|
+
the [migration steps](https://github.com/dactylo/sg-python-api/blob/v0.1.0/docs/migration-guide.md#install-the-replacement) to replace it.
|
|
59
|
+
|
|
60
|
+
When a release is available on your package index, install into the Python environment that runs
|
|
61
|
+
your application:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
python -m pip install sg-python-api
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
To install from a checkout instead, run:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
python -m pip install .
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The base installation provides the synchronous `Shotgun` client and both `mockgun` test clients. To
|
|
74
|
+
use the native asynchronous client, `AsyncShotgun`, install the `async` extra, which adds the
|
|
75
|
+
`httpx2` HTTP library:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
python -m pip install 'sg-python-api[async]'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
From a checkout, use:
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
python -m pip install '.[async]'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Quick start
|
|
88
|
+
|
|
89
|
+
These examples read one project from your site. They take the site URL and script credentials from
|
|
90
|
+
environment variables so the API key stays out of source code; the client does not read these
|
|
91
|
+
variables itself. Set `SHOTGUN_URL` to your site's HTTPS URL, and set `SHOTGUN_SCRIPT_NAME` and
|
|
92
|
+
`SHOTGUN_API_KEY` to a script account that can read projects.
|
|
93
|
+
|
|
94
|
+
### Synchronous client
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
import os
|
|
98
|
+
|
|
99
|
+
from shotgun_api3 import Shotgun
|
|
100
|
+
|
|
101
|
+
sg = Shotgun(
|
|
102
|
+
os.environ['SHOTGUN_URL'],
|
|
103
|
+
script_name=os.environ['SHOTGUN_SCRIPT_NAME'],
|
|
104
|
+
api_key=os.environ['SHOTGUN_API_KEY'],
|
|
105
|
+
)
|
|
106
|
+
try:
|
|
107
|
+
project = sg.find_one('Project', [], ['name'])
|
|
108
|
+
print(project)
|
|
109
|
+
finally:
|
|
110
|
+
sg.close()
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The script prints a project dictionary containing `type`, `id`, and `name`, or `None` when no
|
|
114
|
+
project is visible to that account. You can share one `Shotgun` client across threads; `close()`
|
|
115
|
+
releases its pooled connections when you no longer need it.
|
|
116
|
+
|
|
117
|
+
### Asynchronous client
|
|
118
|
+
|
|
119
|
+
With the `async` extra installed and the same environment variables set, run:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
import asyncio
|
|
123
|
+
import os
|
|
124
|
+
|
|
125
|
+
from shotgun_api3 import AsyncShotgun
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
async def main() -> None:
|
|
129
|
+
async with AsyncShotgun(
|
|
130
|
+
os.environ['SHOTGUN_URL'],
|
|
131
|
+
script_name=os.environ['SHOTGUN_SCRIPT_NAME'],
|
|
132
|
+
api_key=os.environ['SHOTGUN_API_KEY'],
|
|
133
|
+
) as sg:
|
|
134
|
+
project = await sg.find_one('Project', [], ['name'])
|
|
135
|
+
print(project)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
asyncio.run(main())
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The output matches the synchronous example. The `async with` block closes the client even when an
|
|
142
|
+
operation fails. Without the `async` extra, importing `AsyncShotgun` raises `ImportError`.
|
|
143
|
+
|
|
144
|
+
Share an `AsyncShotgun` only among tasks on one event loop, and cancel its work by cancelling the
|
|
145
|
+
task. A cancelled write may already have reached the server, so check its outcome before repeating
|
|
146
|
+
it. The [async reference](https://github.com/dactylo/sg-python-api/blob/v0.1.0/COMPATIBILITY.md#async-extension-surfaces) covers shutdown and
|
|
147
|
+
cancellation in detail.
|
|
148
|
+
|
|
149
|
+
## Documentation
|
|
150
|
+
|
|
151
|
+
| If you want to... | Read |
|
|
152
|
+
| ----------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
153
|
+
| Replace Autodesk's client in an existing application | [Migration guide](https://github.com/dactylo/sg-python-api/blob/v0.1.0/docs/migration-guide.md) |
|
|
154
|
+
| Check what behaves differently from Autodesk's client | [Compatibility](https://github.com/dactylo/sg-python-api/blob/v0.1.0/COMPATIBILITY.md) |
|
|
155
|
+
| Tune pooling and page prefetch, or observe requests | [Configuration extensions](https://github.com/dactylo/sg-python-api/blob/v0.1.0/COMPATIBILITY.md#configuration-and-observer-extensions) |
|
|
156
|
+
| Confirm which client loads and run a smoke test | [Testing an installation](https://github.com/dactylo/sg-python-api/blob/v0.1.0/docs/testing.md) |
|
|
157
|
+
| Compare measured latency and transfer memory | [Benchmarks](https://github.com/dactylo/sg-python-api/blob/v0.1.0/docs/benchmarks.md) |
|
|
158
|
+
| See changes by version | [Changelog](https://github.com/dactylo/sg-python-api/blob/v0.1.0/CHANGELOG.md) |
|
|
159
|
+
|
|
160
|
+
## Development
|
|
161
|
+
|
|
162
|
+
See the [development guide](https://github.com/dactylo/sg-python-api/blob/v0.1.0/docs/development.md) for the required tools, CI, and dependency locks.
|
|
163
|
+
With those tools installed, run:
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
make setup
|
|
167
|
+
make check
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`make check` also runs the live-site tests, which create and delete records, whenever the
|
|
171
|
+
`SG_TEST_*` variables described in the development guide are set.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
sg-python-api is available under the [MIT License](https://github.com/dactylo/sg-python-api/blob/v0.1.0/LICENSE). It is an independent project and is
|
|
176
|
+
not affiliated with or endorsed by Autodesk. Flow Production Tracking is a product of Autodesk,
|
|
177
|
+
Inc.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
shotgun_api3/__init__.py,sha256=fviJGOi_Gb9jHi5Q9ty5tIbeIvxMtLNrKx_4HJVgemI,2011
|
|
2
|
+
shotgun_api3/_async_client.py,sha256=or11Le6Y2WB3TVTVj_7QiLfOLpDbwjs1p3VVAQhFHLQ,111070
|
|
3
|
+
shotgun_api3/_async_driver.py,sha256=ldrETCNgihOcuoGYVqt8M4u2R1euNkvp3TRXLYQbzJ0,32838
|
|
4
|
+
shotgun_api3/_async_httpx2.py,sha256=3pjeFsb5racGArvlR50c3w0XtrttXuRU_6E9Y-cBU3c,24387
|
|
5
|
+
shotgun_api3/_async_transport.py,sha256=8iAcoFafEHKRBirBkqdIqMFgqLs1YTgtzgACudD0kM4,4928
|
|
6
|
+
shotgun_api3/_capabilities.py,sha256=RrStvExVC3TAADhfbY2JpYZUXmvE63vXIJy1R-nkEII,5527
|
|
7
|
+
shotgun_api3/_client.py,sha256=n4lbXG9UxQhrv1IhwsJd8dD41JIq_Xh-_zqDueSguW8,100184
|
|
8
|
+
shotgun_api3/_config.py,sha256=hCKJtaO06wZFJEz-yIw2SagDeWqZMHpuqSmS33qG2Q4,55264
|
|
9
|
+
shotgun_api3/_crud.py,sha256=Ax36jA2E-lauRf2D-2rmRDj61SilOygtkjKgs5XDCUs,30319
|
|
10
|
+
shotgun_api3/_driver.py,sha256=sPkiseKisJTMSNAxkCvdGXc_H1kKS6sg-rJQLKXSVgU,30139
|
|
11
|
+
shotgun_api3/_errors.py,sha256=fk7v3XbmZK63M272r5wDwF_GgI-4RynPfAWv1P-J-GI,1480
|
|
12
|
+
shotgun_api3/_execution.py,sha256=Kn2Yd9sXIA975stnof7MeuA8bT3dyOuWDIqQnP65LO0,8235
|
|
13
|
+
shotgun_api3/_files.py,sha256=a1PfHKV4OMi6j7BQG2rkMPCcaNTB5uAWNiqCh64AEXg,35223
|
|
14
|
+
shotgun_api3/_methods.py,sha256=8dD5BUN_5hnGAYomUEAX1dHZnI4Cliid6PrrP8AhhPI,36132
|
|
15
|
+
shotgun_api3/_protocol.py,sha256=dKr1XqB6Xo56QloZ2MAyN4ulqYkTjw8VYeJRd5QHufQ,45286
|
|
16
|
+
shotgun_api3/_sentinel.py,sha256=KAQzQjJVhTTZPLFY1f88-_vP7U06i2g6ZS7KJcn4vIA,116
|
|
17
|
+
shotgun_api3/_sg_timezone.py,sha256=yr7Wdln9fwfTVGMQSFsgO-eduuTHQ5EbSY5xEVQ2tYw,115
|
|
18
|
+
shotgun_api3/_signatures.py,sha256=_yhNnbkVF-0opaBfg9H6SauBN2RT4hJsHGa3ZO3Ug4s,1622
|
|
19
|
+
shotgun_api3/_transport.py,sha256=LmQ0e2VvAKwFdNy4SyfRHwgKC6GWnwkIN5Wa2fin3AM,30047
|
|
20
|
+
shotgun_api3/_version.py,sha256=yK498PuHvOUCFnIC1QKSqvFXzUBBuOMHBsVo5gSpFCE,102
|
|
21
|
+
shotgun_api3/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
shotgun_api3/shotgun.py,sha256=X7PLlCC-gR8dJgY_uLYXw_LWN8mz5MsQsSYJldtavTk,1706
|
|
23
|
+
shotgun_api3/lib/__init__.py,sha256=4WGYod6xHcj23rapx5bTDGdjT52H1CAQNMz4BmzNmn0,55
|
|
24
|
+
shotgun_api3/lib/sgtimezone.py,sha256=nYSaCsIeq_SJh7YgL4yWN7dTVVz9lAfx-G3mzsHb8iM,7027
|
|
25
|
+
shotgun_api3/lib/mockgun/__init__.py,sha256=2mHjMJAV4mZ8JvnP8WHn6tkdMJoB7UQtNSs99YzNW30,703
|
|
26
|
+
shotgun_api3/lib/mockgun/_async.py,sha256=7bTZFdlSzeoGq9fRbPBAf-X08qDmrkzV9rxskx5AGX8,10812
|
|
27
|
+
shotgun_api3/lib/mockgun/_mockgun.py,sha256=k2cqLMCKpU5oIbUGiYulf1aIU0HLrMB6DQQ3KrCy7WQ,65093
|
|
28
|
+
sg_python_api-0.1.0.dist-info/METADATA,sha256=7Wzieh6ix8BwZJ_oD-B4_G-bO6m5pPDr1wzC5EFYhUQ,7789
|
|
29
|
+
sg_python_api-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
30
|
+
sg_python_api-0.1.0.dist-info/licenses/LICENSE,sha256=V3moMsQxKDchTd3mtXl5J-ODaNBDvFrapOf1DK7Nx_U,1082
|
|
31
|
+
sg_python_api-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 the sg-python-api authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
shotgun_api3/__init__.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Provide compatible synchronous and optional asynchronous Shotgun clients.
|
|
2
|
+
|
|
3
|
+
Import `Shotgun` directly from this package. Import `AsyncShotgun` explicitly
|
|
4
|
+
after installing the `async` extra; it is loaded lazily and excluded from star
|
|
5
|
+
imports.
|
|
6
|
+
|
|
7
|
+
Close synchronous clients with `close()`. Use asynchronous clients through an
|
|
8
|
+
async context manager or call `await close()`. The public `sg_timezone` object
|
|
9
|
+
is the shared timezone configuration used for datetime conversion.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import importlib
|
|
13
|
+
from typing import TYPE_CHECKING
|
|
14
|
+
|
|
15
|
+
from .shotgun import SG_TIMEZONE as _SG_TIMEZONE
|
|
16
|
+
from .shotgun import (
|
|
17
|
+
AuthenticationFault,
|
|
18
|
+
Error,
|
|
19
|
+
Fault,
|
|
20
|
+
MissingTwoFactorAuthenticationFault,
|
|
21
|
+
ProtocolError,
|
|
22
|
+
ResponseError,
|
|
23
|
+
Shotgun,
|
|
24
|
+
ShotgunError,
|
|
25
|
+
ShotgunFileDownloadError,
|
|
26
|
+
ShotgunThumbnailNotReady,
|
|
27
|
+
UserCredentialsNotAllowedForSSOAuthenticationFault,
|
|
28
|
+
__version__,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
if TYPE_CHECKING:
|
|
32
|
+
from ._async_client import AsyncShotgun as AsyncShotgun
|
|
33
|
+
|
|
34
|
+
sg_timezone = _SG_TIMEZONE
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
'AuthenticationFault',
|
|
38
|
+
'Error',
|
|
39
|
+
'Fault',
|
|
40
|
+
'MissingTwoFactorAuthenticationFault',
|
|
41
|
+
'ProtocolError',
|
|
42
|
+
'ResponseError',
|
|
43
|
+
'Shotgun',
|
|
44
|
+
'ShotgunError',
|
|
45
|
+
'ShotgunFileDownloadError',
|
|
46
|
+
'ShotgunThumbnailNotReady',
|
|
47
|
+
'UserCredentialsNotAllowedForSSOAuthenticationFault',
|
|
48
|
+
'__version__',
|
|
49
|
+
'sg_timezone',
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def __getattr__(name: str) -> object:
|
|
54
|
+
"""Resolve optional package exports without loading them on base import."""
|
|
55
|
+
if name != 'AsyncShotgun':
|
|
56
|
+
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
|
|
57
|
+
try:
|
|
58
|
+
importlib.import_module('httpx2')
|
|
59
|
+
except ModuleNotFoundError as exc:
|
|
60
|
+
if exc.name != 'httpx2':
|
|
61
|
+
raise
|
|
62
|
+
raise ImportError(
|
|
63
|
+
"AsyncShotgun requires httpx2 from the 'async' extra: install sg-python-api[async]"
|
|
64
|
+
) from exc
|
|
65
|
+
module = importlib.import_module(f'{__name__}._async_client')
|
|
66
|
+
exported = getattr(module, name)
|
|
67
|
+
globals()[name] = exported
|
|
68
|
+
return exported
|