@@ -72,28 +72,10 @@ relevant to its type are populated:
7272
7373Common attributes are: ` concrete_type ` , ` storage_location_id ` , ` storage_type ` , ` upload_type ` , ` banner ` , ` description ` , ` etag ` , ` created_on ` , ` created_by `
7474
75- ## Data Migration Between Storage Locations
76-
77- Files in a project or folder can be migrated from one storage location to another using
78- ` index_files_for_migration ` followed by ` migrate_indexed_files ` . Migration is
79- currently supported ** only** between S3 storage locations (both Synapse-managed
80- ` SYNAPSE_S3 ` and external ` EXTERNAL_S3 ` ) that reside in the ** same AWS
81- region** .
82-
83- Migration is a two-phase process:
84-
85- 1 . ** Index** — scan the project/folder and record every file that needs to move into a
86- local SQLite database.
87- 2 . ** Migrate** — read the index database and move each file to the destination
88- storage location.
89-
90- Separating the phases lets you review what will be migrated before committing
91- to the move.
92-
9375## 1. Set up and get project
9476
9577``` python
96- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines= 4 - 18 }
78+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines: " start:setup " : " end:setup " }
9779```
9880
9981## 2. Create an external S3 storage location
@@ -103,7 +85,7 @@ properly configured with an `owner.txt` file. Synapse will transfer data
10385directly to and from this bucket on the user's behalf.
10486
10587``` python
106- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines= 20 - 33 }
88+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines: " start:create_s3_storage_location " : " end:create_s3_storage_location " }
10789```
10890
10991<details class =" example " >
@@ -121,24 +103,32 @@ Create a folder and assign it the S3 storage location. All files uploaded into
121103this folder will be stored in your S3 bucket.
122104
123105``` python
124- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines= 39 - 51 }
106+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines: " start:create_folder_with_s3_storage_location " : " end:create_folder_with_s3_storage_location] " }
125107```
126108
109+ <details class =" example " >
110+ <summary >You'll notice the output looks like:</summary >
111+
112+ ```
113+ ProjectSetting(id=..., project_id=..., settings_type='upload', locations=[...], concrete_type='org.sagebionetworks.repo.model.project.UploadDestinationListSetting', etag='...')
114+ ```
115+ </details >
116+
127117## 4. Create a Google Cloud Storage location
128118
129119Create a storage location backed by a Google Cloud Storage bucket and assign it
130120to a folder.
131121
132122``` python
133- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines= 54 - 75 }
123+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines: " start:create_gcs_storage_location " : " end:create_gcs_storage_location " }
134124```
135125
136126## 5. Create an SFTP storage location
137127
138128SFTP storage locations point to an external SFTP server, where files are stored outside of Synapse. Synapse only manages the metadata and does not handle the file transfer itself. This setup requires the pysftp package, and files must be uploaded separately through the ** client** once configured.
139129
140130``` python
141- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines= 78 - 102 }
131+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines: " start:create_sftp_storage_location " : " end:create_sftp_storage_location " }
142132```
143133
144134## 6. Create an HTTPS storage location
@@ -148,7 +138,7 @@ used when the external server is accessed over HTTPS. Note that the Python
148138client does NOT support uploading files to HTTPS storage locations directly yet. To add files, use the Synapse REST API directly.
149139
150140``` python
151- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines= 107 - 128 }
141+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines: " start:create_https_storage_location " : " end:create_https_storage_location " }
152142```
153143
154144## 7. Create an External Object Store storage location
@@ -158,23 +148,21 @@ accessed by Synapse. Unlike `EXTERNAL_S3`, the Python client transfers data
158148directly to the object store using locally configured AWS credentials —
159149Synapse is never involved in the data transfer, only in storing the metadata.
160150
161- You can add a profile to work with s3 in ` ~/.synapseConfig `
151+ Configure your AWS credentials using any method supported by the AWS SDK
152+ (environment variables, ` ~/.aws/credentials ` , IAM roles, etc.). See the
153+ [ AWS documentation on credential configuration] ( https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html )
154+ for details.
155+
156+ Once credentials are configured, add a matching profile section to ` ~/.synapseConfig `
157+ so the client knows which profile to use for a given endpoint and bucket:
162158
163- Add a section matching your endpoint+bucket URL:
164159```
165160[https://s3.us-east-1.amazonaws.com/test-external-object-store]
166161profile_name = my-s3-profile
167162```
168- Then ensure my-s3-profile exists in ` ~/.aws/config ` with valid keys:
169-
170- ```
171- [my-s3-profile]
172- aws_access_key_id = ...
173- aws_secret_access_key = ...
174- ```
175163
176164``` python
177- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines= 135 - 164 }
165+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines: " start:create_object_store_storage_location " : " end:create_object_store_storage_location " }
178166```
179167
180168## 8. Create a Proxy storage location
@@ -184,7 +172,7 @@ authentication and access to the underlying storage. Files are registered by
184172creating a ` ProxyFileHandle ` via the REST API. Then, files can be uploaded via store function with data_file_handle_id.
185173
186174``` python
187- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines= 168 - 226 }
175+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines: " start:create_proxy_storage_location " : " end:create_proxy_storage_location " }
188176```
189177
190178## 9. Retrieve and inspect storage location settings
@@ -193,7 +181,7 @@ You can retrieve a storage location by ID. Only fields relevant to the storage
193181type are populated.
194182
195183``` python
196- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines= 230 - 236 }
184+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines: " start:retrieve_storage_location " : " end:retrieve_storage_location " }
197185```
198186
199187<details class =" example " >
@@ -214,42 +202,9 @@ creation. To "update" a storage location, create a new one with the desired
214202settings and reassign it to the folder or project.
215203
216204``` python
217- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines=245 - 280 }
218- ```
219-
220- ## 11. Index and migrate files to a new storage location
221-
222- > ** Warning:** This will migrate files associated with the folder. Run against a
223- > test project first and review the index result before migrating production data.
224-
225- Phase 1. indexes all files that need to move into a local SQLite database. This will return a MigrationResults object. You can use the ` as_csv ` to check the details of indexing status.
226-
227- ``` python
228- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines=288 - 298 }
205+ {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines:" start:update_storage_location" :" end:update_storage_location" }
229206```
230207
231- Index results can be checked in the index results csv
232- ![ indexresults] ( ./tutorial_screenshots/index_results.png )
233-
234- Phase 2. reads that database and performs the actual migration. This will return a MigrationResults object. You can use the ` as_csv ` to check the details of migration status and errors if any.
235-
236- ``` python
237- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py! lines=300 - 310 }
238- ```
239-
240- Currently, detailed Traceback is saved in the exception columns of the csv.
241- ![ migrationresults] ( ./tutorial_screenshots/migration_results.png )
242-
243- ## Source code for this tutorial
244-
245- <details class =" quote " >
246- <summary >Click to show me</summary >
247-
248- ``` python
249- {! docs/ tutorials/ python/ tutorial_scripts/ storage_location.py!}
250- ```
251- </details >
252-
253208## References used in this tutorial
254209
255210- [ StorageLocation] [ synapseclient.models.StorageLocation ]
0 commit comments