From 324aa228824d127a63ca898384445a45f68dc7b3 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Tue, 3 Jun 2025 14:20:08 -0700 Subject: [PATCH 1/4] WIP --- docs/cookbook/attachments.rst | 105 ++++++++++++++++++++++++++++------ docs/reference.rst | 7 ++- 2 files changed, 92 insertions(+), 20 deletions(-) diff --git a/docs/cookbook/attachments.rst b/docs/cookbook/attachments.rst index e265071e..119fa669 100644 --- a/docs/cookbook/attachments.rst +++ b/docs/cookbook/attachments.rst @@ -238,7 +238,7 @@ are available: A dictionary representing which LocalStorage entity is applied for this local file link. - **url** (:obj:`str`) *read-only*: - A file:// link provided for convenience pointing to the value in the ``local_path`` + A file URI (``file://``) path provided for convenience pointing to the value in the ``local_path`` Reading Local File Fields ========================= @@ -284,40 +284,107 @@ defaults. Any other keys that are provided will be ignored. Optionally set the mime-type of the associated local file. This is assigned automatically using a best-guess based on the file extension. - * **name** :obj:`str`: Optional display name of the local file. This is set to the filename by default. * **local_path** :obj:`str`: - The full local path to the file. Flow Production Tracking will find the LocalStorage + The full local path to the file. Flow Production Tracking will find the ``LocalStorage`` that has the most specific match to this path and automatically assign that LocalStorage to the file. + Alternative to ``relative_path`` + +* **local_storage** :obj:`dict`: + The reference to an existing ``LocalStorage``. + Must contain ``type: LocalStorage`` plus either an ``id`` or a ``name`` + +* **relative_path** :obj:`str`: + The path to the file relative ``local_storage`` root. + Requires ``local_storage`` + Only acceptinh slash ``/`` separated path. Does not accept Windows path. + Alternative to ``local_path`` + +Example 1 Using ``local_path`` +------------------------------ :: - data = {'sg_uploaded_movie': {'local_path': '/Users/kp/Movies/testing/test_movie_002.mov', - 'name': 'Better Movie'} - result = sg.update('Version', 123, data) + result = sg.update( + 'Version', + 123, + { + 'sg_uploaded_movie': { + 'local_path': '/Users/kp/Movies/testing/test_movie_002.mov', + 'name': 'Better Movie', + } + ) Returns:: - {'id':123, - 'sg_uploaded_movie': { 'content_type': 'video/quicktime', - 'link_type': 'local', - 'name': 'my_test_movie.mov', - 'local_path': '/Users/kp/Movies/testing/test_movie_002.mov' - 'local_path_linux': '/home/users/macusers/kp/Movies/testing/test_movie_002.mov' - 'local_path_mac': '/Users/kp/Movies/testing/test_movie_002.mov' - 'local_path_windows': 'M:\\macusers\kp\Movies\testing\test_movie_002.mov' - 'local_storage': {'id': 1, - 'name': 'Dailies Directories', - 'type': 'LocalStorage'}, - 'url': 'file:///Users/kp/Movies/testing/test_movie_002.mov'}, - 'type': 'Version'}] + { + 'id':123, + 'sg_uploaded_movie': { + 'content_type': 'video/quicktime', + 'link_type': 'local', + 'name': 'my_test_movie.mov', + 'local_path': '/Users/kp/Movies/testing/test_movie_002.mov' + 'local_path_linux': '/home/users/macusers/kp/Movies/testing/test_movie_002.mov' + 'local_path_mac': '/Users/kp/Movies/testing/test_movie_002.mov' + 'local_path_windows': 'M:\\macusers\kp\Movies\testing\test_movie_002.mov' + 'local_storage': { + 'id': 1, + 'name': 'Dailies Directories', + 'type': 'LocalStorage' + }, + 'url': 'file:///Users/kp/Movies/testing/test_movie_002.mov' + }, + 'type': 'Version', + } The ``content_type`` was assigned a best-guess value based on the file extension. Flow Production Tracking selected the most appropriate specific LocalStorage match and assigned it to local_storage automatically. + +Example 2 Using ``relative_path`` +--------------------------------- + +:: + + result = sg.update( + 'Version', + 123, + { + 'sg_uploaded_movie': { + 'local_storage': { + 'type': 'LocalStorage', + 'name': 'Dailies Directories', + }, + 'relative_path': 'testing/test_movie_002.mov', + } + ) + +Returns:: + + { + 'id':123, + 'sg_uploaded_movie': { + 'content_type': 'video/quicktime', + 'link_type': 'local', + 'name': 'my_test_movie.mov', + 'local_path': '/Users/kp/Movies/testing/test_movie_002.mov' + 'local_path_linux': '/home/users/macusers/kp/Movies/testing/test_movie_002.mov' + 'local_path_mac': '/Users/kp/Movies/testing/test_movie_002.mov' + 'local_path_windows': 'M:\\macusers\kp\Movies\testing\test_movie_002.mov' + 'local_storage': { + 'id': 1, + 'name': 'Dailies Directories', + 'type': 'LocalStorage' + }, + 'url': 'file:///Users/kp/Movies/testing/test_movie_002.mov' + }, + 'type': 'Version', + } + + Un-setting local file field values ================================== diff --git a/docs/reference.rst b/docs/reference.rst index 5f3888a5..ad55d318 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -803,8 +803,13 @@ Additional keys exist for local file links 'local_path_linux': "string" | None, 'local_path_mac': "string" | None, 'local_path_windows': "string" | None, - 'local_storage': {dictionary}, + 'local_storage': { + 'type': 'LocalStorage', + 'id': int | Pass, + 'name': "string" | Pass, TODO + }, 'name': "string", + 'relative_path': "string" | None 'url': "string", } API versions < v3.0.3: From c4f95633fa4664d20fa69aa360a8897b2be8e12b Mon Sep 17 00:00:00 2001 From: Julien Langlois <16244608+julien-lang@users.noreply.github.com> Date: Wed, 4 Jun 2025 16:33:54 -0700 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/cookbook/attachments.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/cookbook/attachments.rst b/docs/cookbook/attachments.rst index 119fa669..64b33e17 100644 --- a/docs/cookbook/attachments.rst +++ b/docs/cookbook/attachments.rst @@ -300,7 +300,7 @@ defaults. Any other keys that are provided will be ignored. * **relative_path** :obj:`str`: The path to the file relative ``local_storage`` root. Requires ``local_storage`` - Only acceptinh slash ``/`` separated path. Does not accept Windows path. + Only accepting slash ``/`` separated path. Does not accept Windows path. Alternative to ``local_path`` Example 1 Using ``local_path`` @@ -370,10 +370,10 @@ Returns:: 'content_type': 'video/quicktime', 'link_type': 'local', 'name': 'my_test_movie.mov', - 'local_path': '/Users/kp/Movies/testing/test_movie_002.mov' - 'local_path_linux': '/home/users/macusers/kp/Movies/testing/test_movie_002.mov' - 'local_path_mac': '/Users/kp/Movies/testing/test_movie_002.mov' - 'local_path_windows': 'M:\\macusers\kp\Movies\testing\test_movie_002.mov' + 'local_path': '/Users/kp/Movies/testing/test_movie_002.mov', + 'local_path_linux': '/home/users/macusers/kp/Movies/testing/test_movie_002.mov', + 'local_path_mac': '/Users/kp/Movies/testing/test_movie_002.mov', + 'local_path_windows': 'M:\\macusers\kp\Movies\testing\test_movie_002.mov', 'local_storage': { 'id': 1, 'name': 'Dailies Directories', From 9f069aa43bcf4f105fa7ef73cde8cd2d71a2a145 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 4 Jun 2025 16:35:40 -0700 Subject: [PATCH 3/4] ee --- docs/reference.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference.rst b/docs/reference.rst index ad55d318..e2e050e8 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -805,8 +805,8 @@ Additional keys exist for local file links 'local_path_windows': "string" | None, 'local_storage': { 'type': 'LocalStorage', - 'id': int | Pass, - 'name': "string" | Pass, TODO + 'id': int | None, + 'name': "string" | None, }, 'name': "string", 'relative_path': "string" | None From 53b4e21230b9c3a15dc268aaa00ea459dcd059cf Mon Sep 17 00:00:00 2001 From: Julien Langlois <16244608+julien-lang@users.noreply.github.com> Date: Thu, 12 Jun 2025 12:18:22 -0700 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Carlos Villavicencio <123113322+carlos-villavicencio-adsk@users.noreply.github.com> --- docs/cookbook/attachments.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/cookbook/attachments.rst b/docs/cookbook/attachments.rst index 64b33e17..934ed58e 100644 --- a/docs/cookbook/attachments.rst +++ b/docs/cookbook/attachments.rst @@ -303,7 +303,7 @@ defaults. Any other keys that are provided will be ignored. Only accepting slash ``/`` separated path. Does not accept Windows path. Alternative to ``local_path`` -Example 1 Using ``local_path`` +Example 1: Using ``local_path`` ------------------------------ :: @@ -344,7 +344,7 @@ The ``content_type`` was assigned a best-guess value based on the file extension the most appropriate specific LocalStorage match and assigned it to local_storage automatically. -Example 2 Using ``relative_path`` +Example 2: Using ``relative_path`` --------------------------------- ::