Skip to content

Commit 9b9cbed

Browse files
committed
organize based on the type of parent, need to work out this logic
1 parent f2a48a7 commit 9b9cbed

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scripts/migration/migrate.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ def get_clowder_v1_user_collections_top_level(headers, user_v1):
188188
top_level_collections.append(col)
189189
return top_level_collections
190190

191-
def process_collection_descendants(collection, headers):
192-
child_collections_endpoint = f"{CLOWDER_V1}/api/getChildCollections"
193-
datasets_endpoint = f"{CLOWDER_V1}/api/datasets"
191+
def process_collection_descendants(collection, headers, v2_parent_id, v2_parent_type, v2_dataset_id):
192+
child_collections_endpoint = f"{CLOWDER_V1}/api/{collection['id']}/getChildCollections"
193+
datasets_endpoint = f"{CLOWDER_V1}/api/collections/{collection['id']}/datasets"
194194

195195
child_col_response = requests.get(child_collections_endpoint, headers=headers)
196196
dataset_response = requests.get(datasets_endpoint, headers=headers)
@@ -199,6 +199,10 @@ def process_collection_descendants(collection, headers):
199199

200200
print(f"Got child collections and datasets")
201201
for child in child_col_json:
202+
if v2_parent_type == "dataset":
203+
print(f"Add folder to the dataset")
204+
else:
205+
print(f"parent was a folder")
202206
print(f"Make a folder for this child")
203207
print(f"Call process descendants")
204208
process_collection_descendants(child, headers)
@@ -231,7 +235,10 @@ def create_v2_dataset_from_collection(collection, user_v1, headers):
231235
dataset_in_v2_endpoint, headers=headers, json=dataset_example
232236
)
233237

234-
process_collection_descendants(collection, headers)
238+
new_dataset_json = response.json()
239+
v2_dataset_id = new_dataset_json["id"]
240+
241+
process_collection_descendants(collection, headers, new_dataset_json["id"], "dataset", v2_dataset_id)
235242

236243
return response.json()["id"]
237244

0 commit comments

Comments
 (0)