@@ -1133,7 +1133,7 @@ def start_dirt_migration(self, username: str):
11331133 for file in image_files :
11341134 # get file entity ID given root image file ID
11351135 file_entity_id = mig .get_file_entity_id (file .id )
1136- file .entity_id = file_entity_id
1136+ file ._replace ( entity_id = file_entity_id )
11371137
11381138 # if no corresponding file entity for this managed file, skip it
11391139 if file_entity_id is None :
@@ -1145,9 +1145,10 @@ def start_dirt_migration(self, username: str):
11451145
11461146 # if no corresponding marked collection for this image, use an orphan folder named by date (as stored on the DIRT server NFS)
11471147 if collection_entity_id is None :
1148- logger .warning (f"DIRT root image collection with entity ID { file_entity_id } not found" )
1148+ logger .warning (f"DIRT root image collection with entity ID { collection_entity_id } not found" )
11491149
11501150 # create the collection if we need to
1151+ collection_name = file .folder
11511152 collection_path = join (migration_collection_path , 'collections' , file .folder )
11521153 if file .folder not in collections_created :
11531154 # mark this collection as seen
@@ -1156,10 +1157,10 @@ def start_dirt_migration(self, username: str):
11561157 # create the collection in the data store
11571158 logger .info (f"Creating DIRT migration subcollection { collection_path } " )
11581159 client .mkdir (collection_path )
1159-
1160- # otherwise we have a corresponding marked collection, get its title
1161- collection_name , collection_created , collection_changed = mig .get_marked_collection (collection_entity_id )
1162- collection_path = join (migration_collection_path , 'collections' , collection_name )
1160+ else :
1161+ # otherwise we have a corresponding marked collection, get its title
1162+ collection_name , collection_created , collection_changed = mig .get_marked_collection (collection_entity_id )
1163+ collection_path = join (migration_collection_path , 'collections' , collection_name )
11631164
11641165 if collection_name not in collections_created :
11651166 collections_created .add (collection_name )
@@ -1171,7 +1172,7 @@ def start_dirt_migration(self, username: str):
11711172 # get CyVerse ID of newly created collection
11721173 stat = client .stat (collection_path )
11731174 id = stat ['id' ]
1174- file .collection_datastore_id = id
1175+ file ._replace ( collection_datastore_id = id )
11751176
11761177 # get metadata and environmental data and attach to file
11771178 metadata , lat , lon , planting , harvest , soil_group , soil_moist , soil_n , soil_p , soil_k , pesticides = mig .get_marked_collection_info (
@@ -1195,8 +1196,8 @@ def start_dirt_migration(self, username: str):
11951196 client .set_metadata (id , props , [])
11961197
11971198 # persist collection information on managed file record
1198- file .collection = collection_name
1199- file .collection_entity_id = collection_entity_id
1199+ file ._replace ( collection = collection_name )
1200+ file ._replace ( collection_entity_id = collection_entity_id )
12001201
12011202 # create managed file record
12021203 file_rec = ManagedFile .objects .create (migration = migration ,
@@ -1207,7 +1208,7 @@ def start_dirt_migration(self, username: str):
12071208 orphan = file .orphan ,
12081209 missing = file .missing ,
12091210 uploaded = file .uploaded ,
1210- entity_id = file .file_entity_id ,
1211+ entity_id = file .entity_id ,
12111212 collection_entity_id = file .collection_entity_id ,
12121213 nfs_path = join (rootnfs_dir , 'root-images' , file .folder , file .name ),
12131214 staging_path = join (staging_dir , file .name ))
0 commit comments