@@ -746,18 +746,18 @@ def build_collection_space_metadata_for_v1_dataset(dataset, user_v1, headers):
746746 "id" : space ["id" ],
747747 "name" : space ["name" ],
748748 # TODO this is not part of the json
749- # "creator": space["creator"],
749+ "creator" : space ["creator" ],
750750 }
751751 space_entries .append (space_entry )
752752 except Exception as e :
753753 print (f"Error in getting space entry." )
754754 print (e )
755- try :
756- space_entry = {"id" : space ["id" ], "name" : space ["name" ]}
757- space_entries .append (space_entry )
758- except Exception as e :
759- print (f"Error in getting space entry" )
760- print (e )
755+ try :
756+ space_entry = {"id" : space ["id" ], "name" : space ["name" ]}
757+ space_entries .append (space_entry )
758+ except Exception as e :
759+ print (f"Error in getting space entry" )
760+ print (e )
761761 collection_data = []
762762 for collection in dataset_collections :
763763 collection_children = build_collection_hierarchy (
@@ -773,6 +773,7 @@ def build_collection_space_metadata_for_v1_dataset(dataset, user_v1, headers):
773773def process_user_and_resources (user_v1 , USER_MAP , DATASET_MAP ):
774774 """Process user resources from Clowder v1 to Clowder v2."""
775775 user_v1_datasets = get_clowder_v1_user_datasets (user_id = user_v1 ["id" ])
776+ user_v1_datasets = user_v1_datasets [:2 ]
776777 user_v2_api_key = create_local_user (user_v1 )
777778 USER_MAP [user_v1 ["id" ]] = user_v2_api_key
778779 base_user_headers_v2 = {"x-api-key" : user_v2_api_key }
@@ -866,6 +867,8 @@ def process_user_and_resources(user_v1, USER_MAP, DATASET_MAP):
866867 print (
867868 f"Failed to add collection info as metadata in Clowder v2. Status code: { response .status_code } "
868869 )
870+ else :
871+ print (f"Skipping dataset { dataset_v1_id } as it does not meet the criteria." )
869872
870873 return [USER_MAP , DATASET_MAP ]
871874
@@ -911,21 +914,21 @@ def process_user_and_resources(user_v1, USER_MAP, DATASET_MAP):
911914
912915 ##############################################################################################################
913916 # migrate spaces
914- # print("Now migrating spaces.")
915- # for user_v1 in users_v1:
916- # print(f"Migrating spaces of user {user_v1['email']}")
917- # user_v1_spaces = get_clowder_v1_user_spaces(user_v1)
918- # user_v2_api_key = USER_MAP[user_v1["id"]]
919- # for space in user_v1_spaces:
920- # group_id = create_v2_group(space, headers={"X-API-key": user_v2_api_key})
921- # add_v1_space_members_to_v2_group(
922- # space, group_id, headers={"X-API-key": user_v2_api_key}
923- # )
924- # space_datasets = get_clowder_v2_space_datasets(space["id"])
925- # for space_dataset in space_datasets:
926- # dataset_v2_id = DATASET_MAP[space_dataset["id"]]
927- # share_dataset_with_group(
928- # group_id, space, headers={"X-API-key": user_v2_api_key}
929- # )
930- # print(f"Migrated spaces of user {user_v1['email']}")
917+ print ("Now migrating spaces." )
918+ for user_v1 in users_v1 :
919+ print (f"Migrating spaces of user { user_v1 ['email' ]} " )
920+ user_v1_spaces = get_clowder_v1_user_spaces (user_v1 )
921+ user_v2_api_key = USER_MAP [user_v1 ["id" ]]
922+ for space in user_v1_spaces :
923+ group_id = create_v2_group (space , headers = {"X-API-key" : user_v2_api_key })
924+ add_v1_space_members_to_v2_group (
925+ space , group_id , headers = {"X-API-key" : user_v2_api_key }
926+ )
927+ space_datasets = get_clowder_v2_space_datasets (space ["id" ])
928+ for space_dataset in space_datasets :
929+ dataset_v2_id = DATASET_MAP [space_dataset ["id" ]]
930+ share_dataset_with_group (
931+ group_id , space , headers = {"X-API-key" : user_v2_api_key }
932+ )
933+ print (f"Migrated spaces of user { user_v1 ['email' ]} " )
931934 print ("Migration complete." )
0 commit comments