-
Notifications
You must be signed in to change notification settings - Fork 1
/
ispyb-update-all-proposals
executable file
·56 lines (49 loc) · 1.76 KB
/
ispyb-update-all-proposals
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
56
import nsls2api_lib
import ispyb_lib
import argparse
import logging
import sys
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(
"--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
dry_run = args.dry_run
ispyb_proposals = nsls2api_lib.get_all_proposal_ids_for_instruments(
nsls2api_lib.ispyb_instruments
)
print(f"Number of ISPyB proposals is {len(ispyb_proposals)}")
for proposal in ispyb_proposals:
# get all users in PASS proposal
print(f"handling proposal: {proposal}")
proposal_info = nsls2api_lib.get_proposal_info(proposal)
ispyb_lib.add_usernames_for_proposal(
proposal,
nsls2api_lib.get_usernames_from_proposal(proposal),
nsls2api_lib.get_users_from_proposal(proposal),
proposal_info["instruments"][0],
dry_run=dry_run,
)
ispyb_lib.reset_users_for_proposal(proposal, dry_run=dry_run)
print("")
if __name__ == "__main__":
main()