@@ -44,10 +44,25 @@ class ArcFlow:
4444 """
4545
4646
47- def __init__ (self , arclight_dir , aspace_dir , solr_url , aspace_solr_url , ead_extra_config = '' , force_update = False , agents_only = False , collections_only = False , skip_creator_indexing = False ):
47+ def __init__ (
48+ self ,
49+ arclight_dir ,
50+ aspace_dir ,
51+ solr_url ,
52+ aspace_solr_url ,
53+ ead_extra_config = '' ,
54+ force_update = False ,
55+ agents_only = False ,
56+ collections_only = False ,
57+ skip_creator_indexing = False ,
58+ skip_pdf_generation = False ,
59+ repository_id = None ,
60+ skip_deleted_record_processing = False ,
61+ skip_timestamp_update = False ,
62+ ):
4863 self .solr_url = solr_url
4964 self .aspace_solr_url = aspace_solr_url
50- self .batch_size = 1000
65+ self .batch_size = 400
5166 self .arclight_dir = arclight_dir
5267 if ead_extra_config .strip ():
5368 if not os .path .isfile (ead_extra_config ):
@@ -67,6 +82,10 @@ def __init__(self, arclight_dir, aspace_dir, solr_url, aspace_solr_url, ead_extr
6782 self .agents_only = agents_only
6883 self .collections_only = collections_only
6984 self .skip_creator_indexing = skip_creator_indexing
85+ self .skip_pdf_generation = skip_pdf_generation
86+ self .repository_id = repository_id
87+ self .skip_deleted_record_processing = skip_deleted_record_processing
88+ self .skip_timestamp_update = skip_timestamp_update
7089 self .log = logging .getLogger ('arcflow' )
7190 self .pid = os .getpid ()
7291 self .pid_file_path = os .path .join (base_dir , 'arcflow.pid' )
@@ -294,7 +313,8 @@ def task_resource(self, repo, resource_id, xml_dir, pdf_dir, indent_size=0):
294313 # next level of indentation for nested operations
295314 indent_size += 2
296315
297- pdf_job = (repo ['uri' ], self .request_pdf_job (repo ['uri' ], resource_id , indent_size = indent_size ), resource ['ead_id' ])
316+ if not self .skip_pdf_generation :
317+ pdf_job = (repo ['uri' ], self .request_pdf_job (repo ['uri' ], resource_id , indent_size = indent_size ), resource ['ead_id' ])
298318
299319 # if the EAD ID was updated in ArchivesSpace,
300320 # delete the previous EAD in ArcLight Solr
@@ -415,7 +435,12 @@ def process_collections(self):
415435
416436 # process resources that have been modified in ArchivesSpace since last update
417437 self .log .info ('Fetching resources from ArchivesSpace...' )
418- repos = self .client .get ('repositories' ).json ()
438+
439+ if self .repository_id is not None :
440+ repo = self .client .get (f'/repositories/{ self .repository_id } ' )
441+ repos = [repo .json ()] if repo else []
442+ else :
443+ repos = self .client .get ('repositories' ).json ()
419444
420445 indent_size = 2
421446 self .resources_counter = {}
@@ -467,15 +492,16 @@ def process_collections(self):
467492 except Exception as e :
468493 self .log .error (f'{ " " * indent_size } Error removing pending symlink { xml_file_path } : { e } ' )
469494
470- # Tasks for processing PDFs
471- results_4 = [pool .apply_async (
472- self .task_pdf ,
473- args = (repo_uri , job_id , ead_id , pdf_dir , indent_size ))
474- for repo_uri , job_id , ead_id in outputs_2 if job_id is not None ]
495+ if not self .skip_pdf_generation :
496+ # Tasks for processing PDFs
497+ results_4 = [pool .apply_async (
498+ self .task_pdf ,
499+ args = (repo_uri , job_id , ead_id , pdf_dir , indent_size ))
500+ for repo_uri , job_id , ead_id in outputs_2 if job_id is not None ]
475501
476- # Wait for PDF tasks to complete
477- for r in results_4 :
478- r .get ()
502+ # Wait for PDF tasks to complete
503+ for r in results_4 :
504+ r .get ()
479505
480506 return
481507
@@ -489,6 +515,10 @@ def process_deleted_records(self, scope):
489515 Determines which record types are checked for deletion and which
490516 timestamp is used as the lower bound for the delete-feed query.
491517 """
518+ if self .skip_deleted_record_processing :
519+ self .log .info ('Skipping processing of records deleted in ArchivesSpace.' )
520+ return
521+
492522 xml_dir = f'{ self .arclight_dir } /public/xml'
493523 resource_dir = f'{ xml_dir } /resources'
494524 agent_dir = f'{ xml_dir } /agents'
@@ -577,8 +607,8 @@ def index_collections(self, repo_id, xml_file_path, indent_size=0):
577607 cmd = [
578608 'bundle' , 'exec' , 'traject' ,
579609 '-u' , self .solr_url ,
580- '-s' , 'processing_thread_pool=8 ' ,
581- '-s' , 'solr_writer.thread_pool=8 ' ,
610+ '-s' , 'processing_thread_pool=16 ' ,
611+ '-s' , 'solr_writer.thread_pool=16 ' ,
582612 '-s' , f'solr_writer.batch_size={ self .batch_size } ' ,
583613 '-s' , 'solr_writer.commit_on_close=true' ,
584614 '-i' , 'xml' ,
@@ -1149,6 +1179,10 @@ def save_config_file(self):
11491179 Each record type (collections, creators) has its own timestamp so they
11501180 can be run independently without overwriting each other's state.
11511181 """
1182+ if self .skip_timestamp_update :
1183+ self .log .info ('Skipping update of .arcflow.yml configuration file.' )
1184+ return
1185+
11521186 try :
11531187 # Preserve timestamps for record types not processed in this run
11541188 try :
@@ -1284,7 +1318,7 @@ def run(self):
12841318 if scope in ('creators' , 'all' ):
12851319 active_timestamps .append (int (self .last_updated_creators .timestamp ()))
12861320 if self .force_update or all (t <= 0 for t in active_timestamps ):
1287- self .log .info ('Skipping deleted record processing .' )
1321+ self .log .info ('Skipping processing of records deleted in ArchivesSpace .' )
12881322 else :
12891323 self .process_deleted_records (scope )
12901324
@@ -1331,6 +1365,23 @@ def main():
13311365 '--skip-creator-indexing' ,
13321366 action = 'store_true' ,
13331367 help = 'Generate creator XML files but skip Solr indexing' ,)
1368+ parser .add_argument (
1369+ '--skip-pdf-generation' ,
1370+ action = 'store_true' ,
1371+ help = 'Skip PDF generation and related job processing (useful for testing)' ,)
1372+ parser .add_argument (
1373+ '--repository-id' ,
1374+ type = int ,
1375+ default = None ,
1376+ help = 'Process only resources from the specified repository ID (useful for testing)' ,)
1377+ parser .add_argument (
1378+ '--skip-deleted-record-processing' ,
1379+ action = 'store_true' ,
1380+ help = 'Skip processing of records deleted in ArchivesSpace (useful for testing)' ,)
1381+ parser .add_argument (
1382+ '--skip-timestamp-update' ,
1383+ action = 'store_true' ,
1384+ help = 'Skip updating last updated timestamps in .arcflow.yml (useful for testing)' ,)
13341385 args = parser .parse_args ()
13351386
13361387 # Validate mutually exclusive flags
@@ -1346,7 +1397,11 @@ def main():
13461397 force_update = args .force_update ,
13471398 agents_only = args .agents_only ,
13481399 collections_only = args .collections_only ,
1349- skip_creator_indexing = args .skip_creator_indexing )
1400+ skip_creator_indexing = args .skip_creator_indexing ,
1401+ skip_pdf_generation = args .skip_pdf_generation ,
1402+ repository_id = args .repository_id ,
1403+ skip_deleted_record_processing = args .skip_deleted_record_processing ,
1404+ skip_timestamp_update = args .skip_timestamp_update ,)
13501405 arcflow .run ()
13511406
13521407
0 commit comments