Skip to content

Commit 734c9f1

Browse files
committed
this seems to be working
the map for the dataset collections seems to work will add documentation next commit
1 parent b600cc9 commit 734c9f1

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

scripts/migration/dataset_collection_json.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def get_dataset_collections_map():
2727

2828
for collection, datasets in data.items():
2929
for dataset in datasets:
30-
dataset_to_collection[dataset] = collection
30+
if dataset not in dataset_to_collection:
31+
dataset_to_collection[dataset] = [collection]
32+
else:
33+
current_value = dataset_to_collection[dataset]
34+
current_value.append(collection)
35+
dataset_to_collection[dataset] = current_value
3136
return dataset_to_collection
3237

scripts/migration/migrate.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
post_metadata_definition,
1717
)
1818

19+
from scripts.migration.dataset_collection_json import get_dataset_collections_map
20+
21+
DATASET_COLLECTIONS_MAP = get_dataset_collections_map()
22+
1923
# Configuration and Constants
2024
DEFAULT_PASSWORD = "Password123&"
2125

@@ -725,10 +729,12 @@ def build_collection_metadata_for_v1_dataset(dataset_id, user_v1, headers):
725729
# TODO test this method
726730
def build_collection_space_metadata_for_v1_dataset(dataset, user_v1, headers):
727731
dataset_id = dataset["id"]
728-
# TODO this is too slow we need a way to sort through collection hierarchy better
729-
dataset_collections = get_clowder_v1_dataset_collections(
730-
headers=headers, user_v1=user_v1, dataset_id=dataset_id
731-
)
732+
dataset_collections = []
733+
if dataset_id in DATASET_COLLECTIONS_MAP:
734+
dataset_collections_ids = DATASET_COLLECTIONS_MAP[dataset_id]
735+
for col_id in dataset_collections_ids:
736+
collection = get_clowder_v1_collection(col_id, headers=headers)
737+
dataset_collections.append(collection)
732738
dataset_spaces = dataset["spaces"]
733739
space_entries = []
734740
for space_id in dataset_spaces:
@@ -739,7 +745,8 @@ def build_collection_space_metadata_for_v1_dataset(dataset, user_v1, headers):
739745
space_entry = {
740746
"id": space["id"],
741747
"name": space["name"],
742-
"creator": space["creator"],
748+
# TODO this is not part of the json
749+
# "creator": space["creator"],
743750
}
744751
space_entries.append(space_entry)
745752
except Exception as e:

0 commit comments

Comments
 (0)