@@ -23,22 +23,45 @@ def copy_collection_submission_metadata_to_cedar(dry_run=False, batch_size=100,
2323 logger .info (f'{ "[DRY RUN] " if dry_run else "" } Found { total } collection submissions to process' )
2424
2525 processed = errors = 0
26+ succeeded = []
27+ failed = []
2628 for submission in qs .iterator (chunk_size = batch_size ):
2729 if dry_run :
2830 logger .info (f'[DRY RUN] Would sync cedar metadata for submission { submission ._id } ' )
2931 continue
3032 try :
31- submission .sync_cedar_metadata ()
33+ record = submission .sync_cedar_metadata ()
34+ succeeded .append ((
35+ submission .guid ._id ,
36+ submission .collection ._id ,
37+ record ._id ,
38+ record .template .cedar_id ,
39+ ))
3240 processed += 1
3341 except Exception as e :
3442 logger .error (f'Failed to sync cedar metadata for submission { submission ._id } : { e } ' )
43+ template = submission .collection .provider .required_metadata_template
44+ failed .append ((
45+ submission .guid ._id ,
46+ submission .collection ._id ,
47+ template .cedar_id ,
48+ e ,
49+ ))
3550 errors += 1
3651
3752 logger .info (
3853 f'{ "[DRY RUN] " if dry_run else "" } '
3954 f'Done. Processed { processed } /{ total } submissions'
4055 f'{ f", { errors } error(s)" if errors else "" } '
4156 )
57+ if succeeded :
58+ logger .info ('Successfully synced (node_guid, collection_id, cedar_record_id, cedar_template_id):' )
59+ for node_guid , collection_id , record_id , template_cedar_id in succeeded :
60+ logger .info (f' node={ node_guid } , collection={ collection_id } , record={ record_id } , template={ template_cedar_id } ' )
61+ if failed :
62+ logger .info ('Failed (node_guid, collection_id, cedar_template_id):' )
63+ for node_guid , collection_id , template_cedar_id , exc in failed :
64+ logger .info (f' node={ node_guid } , collection={ collection_id } , template={ template_cedar_id } , error={ exc } ' )
4265
4366
4467class Command (BaseCommand ):
0 commit comments