Skip to content

Commit 767dce1

Browse files
committed
debug migration
1 parent 7cd9f45 commit 767dce1

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

plantit/plantit/celery_tasks.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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))

plantit/plantit/migration.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ async def push_migration_event(user: User, migration: Migration, file: plantit.u
6464
class ManagedFile(NamedTuple):
6565
id: str
6666
name: str
67-
nfs_path: str
6867
path: str
6968
type: str
7069
folder: str
7170
orphan: bool
7271
missing: bool
7372
uploaded: Optional[str]
74-
entity_id: Optional[str]
75-
collection_entity_id: Optional[str]
73+
nfs_path: Optional[str] = None
74+
entity_id: Optional[str] = None
75+
collection: Optional[str] = None
76+
collection_entity_id: Optional[str] = None
7677

7778

7879
def row_to_managed_file(row):
@@ -94,7 +95,7 @@ def row_to_managed_file(row):
9495
return ManagedFile(
9596
id=fid,
9697
name=name,
97-
nfs_path=path.replace('public://', ''),
98+
path=path.replace('public://', ''),
9899
type='metadata',
99100
folder=path.rpartition('metadata-files')[2].replace(name, '').replace('/', ''),
100101
orphan=False,
@@ -105,7 +106,7 @@ def row_to_managed_file(row):
105106
return ManagedFile(
106107
id=fid,
107108
name=name,
108-
nfs_path=path.replace('public://', ''),
109+
path=path.replace('public://', ''),
109110
type='output',
110111
folder=folder,
111112
orphan=False,
@@ -115,7 +116,7 @@ def row_to_managed_file(row):
115116
return ManagedFile(
116117
id=fid,
117118
name=name,
118-
nfs_path=path.replace('public://', ''),
119+
path=path.replace('public://', ''),
119120
type='logs',
120121
folder=path.rpartition('output-logs')[2].replace(name, '').replace('/', ''),
121122
orphan=False,

0 commit comments

Comments
 (0)