Skip to content

Commit

Permalink
support from file
Browse files Browse the repository at this point in the history
  • Loading branch information
cfuselli committed Oct 22, 2024
1 parent 31d4689 commit c6c56a3
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions amstrax/auto_processing_new/offline_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ def parse_args():
parser = argparse.ArgumentParser(description="Offline processing of XAMS data (job submission)")

# Arguments for selecting runs
parser.add_argument("--run_id", type=str, nargs="*", help="Specific run ID(s) to process.")
parser.add_argument("--run_query", type=str, help="Query string to select runs from rundb (e.g., by date).")
# We should make it a group, so that only one of them can be used
run_selection = parser.add_mutually_exclusive_group(required=True)
run_selection.add_argument("--run_id", type=str, nargs="*", help="Specific run ID(s) to process.")
run_selection.add_argument("--run_file", type=str, help="File with run IDs to process. It should contain one run ID per line.")

# Arguments for processing
parser.add_argument(
Expand Down Expand Up @@ -77,15 +79,22 @@ def main(args):
"""
Main function for offline job submission of selected runs.
"""
# Select runs either by run_id or using a custom query

# Check the run selection method
if args.run_id:
run_docs = [{"number": int(run_id)} for run_id in args.run_id]
elif args.run_query:
raise NotImplementedError("Querying runs from rundb is not yet implemented.")
elif args.run_file:
# It should contain a list of run numbers, one per line
with open(args.run_file, "r") as f:
run_numbers = f.readlines()
run_docs = [{"number": int(run_number)} for run_number in run_numbers]
else:
log.error("Either --run_id or --run_query must be provided.")
log.error("Either --run_id or --run_file must be provided.")
return




# Submit jobs for each run
for run_doc in run_docs:
run_id = f'{int(run_doc["number"]):06}'
Expand Down

0 comments on commit c6c56a3

Please sign in to comment.