# Python API (\< 3.0.37) deprecation & Direct Upload to S3

**URL:** <https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907>\
**Category:** Flow Production Tracking\
**Tags:** announcement, python-api, deprecation, rest-api\
**Created:** [October 28, 2019, 5:48pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907 "2019-10-28T17:48:57Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![Pumplerod](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/pumplerod/32/2050_2.png) [@Pumplerod](https://community.shotgridsoftware.com/u/Pumplerod)\
**Post date:** [March 4, 2020, 4:13pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/23 "2020-03-04T16:13:44Z")

</div>

When uploading media directly would we need to perform any colorspace transform to comply with browser support? I’m assuming this was/is currently handled at the middle step on the Shotgun Servers. Is their a particular codec for movie files? etc…

---

<div class="post-metadata">

**Author:** ![zoe.glynn](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/zoe.glynn/32/331_2.png) [@zoe.glynn](https://community.shotgridsoftware.com/u/zoe.glynn)\
**Post date:** [March 6, 2020, 10:44pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/24 "2020-03-06T22:44:44Z")

</div>

To be honest, we debated this heavily internally, but eventually chose not to ‘hide’ some default retry loop within the basic upload function because it came down to the caller knowing their retry context better than us. e.g. to block or not until success?, and we thought it best that people consider, and pick the best for their circumstance.  
Failures are expected only as very infrequent exceptions, due to S3 availability, or networking gremlins - and we wanted to call out this fact since the upload is now happening _direct to s3_ - shotgun itself is no longer able to babysit its success.  
I’d welcome thoughts on useful wrapper functions within the API that the community might make use of.

---

<div class="post-metadata">

**Author:** ![Fabian](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/fabian/32/3508_2.png) [@Fabian](https://community.shotgridsoftware.com/u/Fabian)\
**Post date:** [March 9, 2020, 9:24am UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/25 "2020-03-09T09:24:07Z")

</div>

Hi Zoe!

Thanks for your honest reply. I can see your point and I appreciate your efforts to make this as flexible for the community as you can!  
In my opinion you can keep the upload function as is and “just” add a convenience function (“upload\_with\_reties” ?) that catches maybe 80 percent of the retry scenarios. This way everybody could choose what fits for their specific needs and implementation. I know there is more to this then simply adding this functionality, just my 2 cents… 🙂  
For what it’s worth here is my current (untested) implementation:

```python
def shotgun_upload_with_retry(shotgun, entity_type, entity_id, path, field_name=None, display_name=None, tag_list=None,
                              retries=1):
    """
    :param shotgun_api3.Shotgun shotgun: A shotgun API instance.
    :param str entity_type: Entity type to link the upload to.
    :param int entity_id: Id of the entity to link the upload to.
    :param str path: Full path to an existing non-empty file on disk to upload.
    :param str field_name: The internal Shotgun field name on the entity to store the file in.
        This field must be a File/Link field type.
    :param str display_name: The display name to use for the file. Defaults to the file name.
    :param str tag_list: comma-separated string of tags to assign to the file.
    :param int retries: How often to retry to upload. Can be between 0 and 3.
    :returns: ID of the Attachment entity that was created for the image.
    :rtype: int
    :raises ShotgunError: When an error occurred during upload after the maximum retries have been reached.
    """
    retries = max(0, min(retries, 3))
    retry = 0
    while True:
        retry += 1
        try:
            return shotgun.upload(entity_type=entity_type, entity_id=entity_id, path=path,
                                  field_name=field_name, display_name=display_name, tag_list=tag_list)
        except ShotgunError:
            if retry > retries:
                raise

```

Cheers,  
Fabian

---

<div class="post-metadata">

**Author:** ![christian.deiss](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/christian.deiss/32/2160_2.png) [@christian.deiss](https://community.shotgridsoftware.com/u/christian.deiss)\
**Post date:** [March 10, 2020, 7:58pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/26 "2020-03-10T19:58:42Z")

</div>

Hi Zoe,

Just to verify, the version of tk-core (\>v0.18.149) is the only adjustment which is needed for SGTK. Is this correct?

I’m asking because we have a customized tk-config-default2, with a couple of customized frameworks and apps. Currently we are two versions behind the official release. Do we need to update to the latest version of tk-config-default2?

Thank you  
Christian

---

<div class="post-metadata">

**Author:** ![zoe.glynn](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/zoe.glynn/32/331_2.png) [@zoe.glynn](https://community.shotgridsoftware.com/u/zoe.glynn)\
**Post date:** [March 16, 2020, 10:06pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/27 "2020-03-16T22:06:53Z")

</div>

Hi Christian, correct, tk-core v0.18.149 (even though it is well behind the current official release) is sufficient to be compatible with requirements for direct upload.

---

<div class="post-metadata">

**Author:** ![christian.deiss](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/christian.deiss/32/2160_2.png) [@christian.deiss](https://community.shotgridsoftware.com/u/christian.deiss)\
**Post date:** [March 16, 2020, 11:48pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/28 "2020-03-16T23:48:51Z")

</div>

Great! Thank you.

---

<div class="post-metadata">

**Author:** ![zoe.glynn](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/zoe.glynn/32/331_2.png) [@zoe.glynn](https://community.shotgridsoftware.com/u/zoe.glynn)\
**Post date:** [March 17, 2020, 5:42pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/29 "2020-03-17T17:42:03Z")

</div>

Dear community,

Due to the exceptional circumstances created by COVID-19, we are postponing this deprecation to April 21, 2020.

The main post regarding the schedule has been updated accordingly: [Deprecation of old versions of Shotgun API, RV and iOS - April 21 2020](https://community.shotgridsoftware.com/t/deprecation-of-old-versions-of-shotgun-api-rv-and-ios-april-21-2020/4001)

---

<div class="post-metadata">

**Author:** ![Xavier](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/xavier/32/2145_2.png) [@Xavier](https://community.shotgridsoftware.com/u/Xavier)\
**Post date:** [March 17, 2020, 11:37pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/30 "2020-03-17T23:37:53Z")

</div>

Sorry for being off topic, but if Shotgun is moving to python API 3.0, wouldn’t that mean it is now actually compatible-“able” with Blender? Blender dropped 2.0 quite of a while ago…

---

<div class="post-metadata">

**Author:** ![zoe.glynn](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/zoe.glynn/32/331_2.png) [@zoe.glynn](https://community.shotgridsoftware.com/u/zoe.glynn)\
**Post date:** [March 18, 2020, 5:56am UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/31 "2020-03-18T05:56:03Z")

</div>

Thanks for the dialogue here, Fabian, and your sample implementation to illustrate what you’re thinking of. It’s great to be able to take this back to the team, although it will be some time before we get around to revisiting what’s included in the API.

---

<div class="post-metadata">

**Author:** ![bouchep](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/bouchep/32/93_2.png) [@bouchep](https://community.shotgridsoftware.com/u/bouchep)\
**Post date:** [March 18, 2020, 6:46pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/32 "2020-03-18T18:46:10Z")

</div>

@Xavier,

The latest Shotgun Python API versions are compatible with Python 3 as of [v3.1.0](https://github.com/shotgunsoftware/python-api/releases/tag/v3.1.0). These latest versions of the Shotgun Python API are compatible with _both_ Python 3 and Python 2.

If Blender includes a Python 3.x environment you should be able to use the latest version of the Shotgun Python API without issues as of Jul 29, 2019 and with version v3.1.0 or newer.

---

<div class="post-metadata">

**Author:** ![Xavier](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/xavier/32/2145_2.png) [@Xavier](https://community.shotgridsoftware.com/u/Xavier)\
**Post date:** [March 18, 2020, 9:32pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/33 "2020-03-18T21:32:15Z")

</div>

Thank you!  
Last time I check this Shotgun was on Python 2.0 which Blender did not support anymore.  
Time to email Ton Roosendaall 🙂  
Blender Foundation just made official the development of an internal asset manager in 2020, so it might be the right time.

> **[Asset Manager — Blender Developers Blog](https://code.blender.org/2020/03/asset-manager/)**
>
> The asset manager project goal is to help artists to quickly re-use, share and organize assets and production files.

In my opinion the largest reason Blender does not penetrate more bigger business at the moment is the lack of effective pipeline integration. If Shotgun gets in it’s game, that door will open.

---

<div class="post-metadata">

**Author:** ![johnny.duguid](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/johnny.duguid/32/4_2.png) [@johnny.duguid](https://community.shotgridsoftware.com/u/johnny.duguid)\
**Post date:** [April 15, 2020, 7:24pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/34 "2020-04-15T19:24:18Z")

</div>

FYI!

> [@Deprecation of old versions of Shotgun API, RV and iOS](https://community.shotgridsoftware.com/t/deprecation-of-old-versions-of-shotgun-api-rv-and-ios/4001/10):
>
> Since the fight against COVID-19 isn’t won yet, we are announcing that we are postponing this deprecation again, this time to June 16th. Again, we are recommending that you update your APIs and tools as soon as possible. Upgrading to newer version of our tools will enhance your experience, improving performance and resiliency.

---

<div class="post-metadata">

**Author:** ![jhudsonFP](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jhudsonFP](https://community.shotgridsoftware.com/u/jhudsonFP)\
**Post date:** [May 13, 2020, 9:44am UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/35 "2020-05-13T09:44:39Z")

</div>

This might be a daft questions, but generally speaking I talk to the API via inbuilt methods in apps:

```
    # via the self._app handle we can for example access:
    # - The engine, via self._app.engine
    # - A Shotgun API instance, via self._app.shotgun
    # - A tk API instance, via self._app.sgtk

```

So when I’m using self.\_app.shotgun will that be automatically using API3, assuming my core is up to date? Thanks very much.

---

<div class="post-metadata">

**Author:** ![bouchep](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/bouchep/32/93_2.png) [@bouchep](https://community.shotgridsoftware.com/u/bouchep)\
**Post date:** [May 15, 2020, 6:34pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/36 "2020-05-15T18:34:12Z")

</div>

Hi @jhudsonFP,

First off, welcome to the community!

To answer your question, yes, your usage will leverage the copy of the Shotgun Python API which is included with your Toolkit setup so assuming your Tooklit core is up to date you should be ok.

---

<div class="post-metadata">

**Author:** ![jhudsonFP](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jhudsonFP](https://community.shotgridsoftware.com/u/jhudsonFP)\
**Post date:** [May 19, 2020, 8:25am UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/37 "2020-05-19T08:25:35Z")

</div>

Hi @bouchep, thanks very much!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/shotgunsoftware/original/2X/e/e9c7b2033d3dc2d7fadac71d426d1c572f175e27.png) [@system](https://community.shotgridsoftware.com/u/system)\
**Post date:** [June 16, 2020, 12:10am UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/38 "2020-06-16T00:10:07Z")

</div>

Automatically bumped on June 16, 2020, 12:10am UTC



---

<div class="post-metadata">

**Author:** ![jhultgre](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/jhultgre/32/487_2.png) [@jhultgre](https://community.shotgridsoftware.com/u/jhultgre)\
**Post date:** [June 18, 2020, 6:54pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/39 "2020-06-18T18:54:13Z")

</div>

Is there an event for when an image field is no longer transient?  
I’m hitting errors about this for my daemon plugin that shares thumbnails from publishedfiles to the entity.

---

<div class="post-metadata">

**Author:** ![bouchep](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/bouchep/32/93_2.png) [@bouchep](https://community.shotgridsoftware.com/u/bouchep)\
**Post date:** [June 18, 2020, 8:35pm UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/40 "2020-06-18T20:35:34Z")

</div>

Hi @jhultgre,

So the short answer is yes, there is an event when the `image` field is populated by the transcoder and isn’t transient anymore.

 ![Screen Shot 2020-06-18 at 16.28.37](https://global.discourse-cdn.com/shotgunsoftware/original/2X/1/1dc34bf01469c2b2336532619a4f51193bb40122.png)

The above screenshot shows two events on the `image` field of a `Version` entity. The first event shows the value being set to the transient URL. The second event shows the URL changing from the transient value to the storage value.

The unfortunate news is that you’d still need to query the URL value as there is nothing in the _event itself_ to distinguish between an event that sets the transient value to an event that sets the permanent value as evidenced by the `event_type` and `meta` fields.

In short, you’ll need to keep processing all events but you’ll need to make sure the URL isn’t the transient one before you issue the `share_thumbnail()` call.

---

<div class="post-metadata">

**Author:** ![Fabian](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/fabian/32/3508_2.png) [@Fabian](https://community.shotgridsoftware.com/u/Fabian)\
**Post date:** [June 22, 2022, 10:32am UTC](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907/41 "2022-06-22T10:32:12Z")

</div>

Reviving this super old thread because as far as I can see **ShotGrid has not included any retries for uploads in any SGTK code**. What is the timeframe on this? Is there maybe still a chance that you can add the retries by default as I suggested.  
Thank you.

[Previous page](https://community.shotgridsoftware.com/t/python-api-3-0-37-deprecation-direct-upload-to-s3/907.md?page=1)
