-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathispyb-update-by-cycle
executable file
·55 lines (48 loc) · 1.81 KB
/
ispyb-update-by-cycle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/opt/conda_envs/2023-3.2-py310/bin/python
import ispyb_lib
import nsls2api_lib
import argparse
import sys
import logging
def main(args=[]):
parser = argparse.ArgumentParser(
description="Create or update people, visit, and proposal information in ISPyB. Currently restricted to one visit per proposal, and these visits are assigned to 'amx' due to the lack of visit information in NSLS2API."
)
parser.add_argument(
"--cycle",
type=str,
default=nsls2api_lib.get_current_cycle(),
help=f"Cycle to create/update people, visits, and proposals for. Default is current cycle ({nsls2api_lib.get_current_cycle()})",
)
parser.add_argument(
"--verbose",
"-v",
action="count",
help="Show more log messages. (Use -vv for even more.)",
)
parser.add_argument(
"--dry-run",
action="store_true",
default=False,
help="Dry run - do not do actions that change ISPyB.",
)
args = parser.parse_args(args or sys.argv[1:])
if args.verbose:
if args.verbose == 1:
logging.basicConfig(level="INFO")
if args.verbose == 2:
logging.basicConfig(level="DEBUG")
else:
logging.basicConfig() # "WARNING" by default
cycle = args.cycle
dry_run = args.dry_run
cycle_proposals = nsls2api_lib.get_proposal_ids_for_cycle_instruments(
cycle, nsls2api_lib.ispyb_instruments
)
print(f"Number of ISPyB proposals to update is {len(cycle_proposals)}")
for index, proposal in enumerate(cycle_proposals, 1):
print(f"{index}: Adding/updating users for proposal {proposal}")
proposal_info = nsls2api_lib.get_proposal_info(proposal)
ispyb_lib.reset_users_for_proposal(proposal, dry_run=dry_run)
if __name__ == "__main__":
main()