dmagic.scheduling

Module containing routines to access the APS scheduling system.

You must create in your home directory a scheduling.ini configuration file

Functions:

current_run(auth, args)

Determine the current run

beamtime_requests(run, auth, args)

Get a dictionary-like object with all proposals that have a beamtime request scheduled during the run.

list_beamtimes(auth, args)

List all beamtimes scheduled for the run containing today + args.set days.

get_beamtime(gup_number, auth, args)

Get the raw beamtime record for a specific GUP number in the current run.

get_current_proposal(proposals, args)

Get a dictionary-like object with currently active proposal information.

get_current_pi(proposal)

Get information about the currently active proposal PI.

get_current_users(proposal)

Get users listed in the currently active proposal.

get_current_emails(proposal[, exclude_pi])

Find user's emails listed in the currently active proposal

get_current_proposal_id(proposal)

Get the proposal id for the currently active proposal.

get_current_proposal_title(proposal)

Get the title of the currently active proposal.

get_proposal_starting_date(proposal)

Get the proposal starting date for the current proposal.

dmagic.scheduling.beamtime_requests(run, auth, args)[source]

Get a dictionary-like object with all proposals that have a beamtime request scheduled during the run. If no proposal is active or auth does not have permission for beamline, return None.

Parameters:
  • run (string) – Run name e.g. ‘2024-1’

  • auth (Basic http authorization object) – Basic http authorization.

  • beamline (string) – beamline ID as stored in the APS scheduling system, e.g. 2-BM-A,B or 7-BM-B or 32-ID-B,C

Returns:

proposals (list) – dict-like object with proposals that have a beamtime request scheduled during the run. Returns None if there are no proposals or if auth does not have permission for beamline.

dmagic.scheduling.current_run(auth, args)[source]

Determine the current run

Parameters:

auth (Basic http authorization object) – Basic http authorization.

Returns:

run (string) – Run name 2024-1.

dmagic.scheduling.get_beamtime(gup_number, auth, args)[source]

Get the raw beamtime record for a specific GUP number in the current run.

Parameters:
  • gup_number (str or int) – The GUP number to look up.

  • auth (HTTPBasicAuth) – Basic http authorization.

Returns:

dict or None – Raw beamtime item from the scheduling API, or None if not found.

dmagic.scheduling.get_current_emails(proposal, exclude_pi=True)[source]

Find user’s emails listed in the currently active proposal

Parameters:

proposal (dictionary-like object containing proposal information)

Returns:

List of user emails (default (all but PI))

dmagic.scheduling.get_current_pi(proposal)[source]

Get information about the currently active proposal PI.

Parameters:

proposal (dictionary-like object containing proposal information)

Returns:

dictionary-like object containing PI information

dmagic.scheduling.get_current_proposal(proposals, args)[source]

Get a dictionary-like object with currently active proposal information. If no proposal is active, return None

Parameters:

proposal (dictionary-like object containing proposal information)

Returns:

dict-like object with information for currently active proposal

dmagic.scheduling.get_current_proposal_id(proposal)[source]

Get the proposal id for the currently active proposal.

Parameters:

proposal (dictionary-like object containing proposal information)

Returns:

currently active proposal ID as an int

dmagic.scheduling.get_current_proposal_title(proposal)[source]

Get the title of the currently active proposal.

Parameters:

proposal (dictionary-like object containing proposal information)

Returns:

str (title of the currently active proposal)

dmagic.scheduling.get_current_users(proposal)[source]

Get users listed in the currently active proposal.

Parameters:

proposal (dictionary-like object containing proposal information)

Returns:

users (dictionary-like object containing user information)

dmagic.scheduling.list_beamtimes(auth, args)[source]

List all beamtimes scheduled for the run containing today + args.set days.

Parameters:

auth (HTTPBasicAuth) – Basic http authorization.

Returns:

list of dict – Each dict contains: gup_number, gup_title, pi_last_name, pi_first_name, pi_institution, pi_email, pi_badge, year_month, start_time, end_time, run_name. Returns an empty list if none are found.