Server Interface#

Common interface to the ESAF and Proposal information servers.

Interface to the servers.

Server([creds_file])

Common connection to information servers.

Exceptions

EsafNotFound

ESAF ID not found by server.

ProposalNotFound

Proposal ID not found by server.

RunNotFound

Run name not found by server.

ServerException

Base exception for this module.

exception apsbss.server_interface.EsafNotFound[source]#

ESAF ID not found by server.

exception apsbss.server_interface.ProposalNotFound[source]#

Proposal ID not found by server.

exception apsbss.server_interface.RunNotFound[source]#

Run name not found by server.

class apsbss.server_interface.Server(creds_file=None)[source]#

Common connection to information servers.

_runs

Return dictionary of run details.

beamlines

Return list of known beam line names.

current_esafs(sector)

Return list of ESAFs for 'sector' for the current run.

current_esafs_and_proposals(beamline[, nruns])

Proposals & ESAFs and proposals with same people for 'nruns' recent runs.

current_proposals(beamline)

Return list of proposals for 'beamline' for the current run.

current_run

Return the name of the current APS run.

esaf(esaf_id)

Return ESAF as a dictionary.

esaf_table(esafs)

Print the list of ESAFS as a table.

esafs(sector[, run])

Return list of ESAFs for the given sector & run.

find_run(target_date)

Find the run that contains the target date.

parse_runs_arg(runs)

Parse a 'runs' argument into a list of run names.

proposal(proposal_id, beamline[, run])

Return proposal as a dictionary.

proposal_table(proposals)

Print the list of proposals as a table.

proposals(beamline[, run])

List of all proposals on 'beamline' in 'run'.

recent_runs([nruns])

Return a list of the 'quantity' most recent 'nruns'.

runs

Return list of known beam line names.

search(query)

Return a list of ESAFs & proposals that match the query.

property beamlines: list#

Return list of known beam line names.

current_esafs(sector)[source]#

Return list of ESAFs for ‘sector’ for the current run.

PARAMETERS

sectorstr | int

Name of sector. If str, must be in %02d format (02, not 2).

current_esafs_and_proposals(beamline, nruns=3) dict[source]#

Proposals & ESAFs and proposals with same people for ‘nruns’ recent runs.

PARAMETERS

beamlinestr

Canonical name of beam line.

nrunsint

Number of APS runs to include, optional (default: 3, a one year period)

RETURNS

Dictionary of proposal and ESAF identification numbers. Proposals IDs are the dictionary keys, list of ESAFs with same people as proposal are the dictionary values.

current_proposals(beamline)[source]#

Return list of proposals for ‘beamline’ for the current run.

PARAMETERS

beamlinestr

Canonical name of beam line.

property current_run: str#

Return the name of the current APS run.

esaf(esaf_id)[source]#

Return ESAF as a dictionary.

PARAMETERS

esaf_idint

ESAF number

esaf_table(esafs: list) pyRestTable.Table[source]#

Print the list of ESAFS as a table.

PARAMETERS

esafs[Esaf]

List of Esaf objects.

esafs(sector, run=None)[source]#

Return list of ESAFs for the given sector & run.

PARAMETERS

sectorstr | int

Name of sector. If str, must be in %02d format (02, not 2).

runstr

List of APS run. Default to current run.

find_run(target_date)[source]#

Find the run that contains the target date.

parse_runs_arg(runs) list[source]#

Parse a ‘runs’ argument into a list of run names.

Parameters

runsstr | [str] | None

Name(s) of APS runs.

  • If ‘None’, then use the current run.

  • If a list, then all strings in the list must be valid names of APS runs.

  • If a string, refer to the following table:

    value

    meaning

    “”

    Use the current run.

    “all”

    Use all runs.

    “current”

    Use the current run.

    “future”

    Use the next run.

    “next”

    Use the next run.

    “now”

    Use the current run.

    “past”

    Use the previous run.

    “previous”

    Use the previous run.

    “prior”

    Use the previous run.

    “recent”

    Use the past six (6) runs.

    None

    Use the current run.

proposal(proposal_id, beamline, run=None)[source]#

Return proposal as a dictionary.

PARAMETERS

proposalIdint

Proposal identification number.

beamlinestr

Canonical name of beam line.

runstr

Canonical name of APS run. Default: the current run.

proposal_table(proposals: dict) pyRestTable.Table[source]#

Print the list of proposals as a table.

PARAMETERS

proposals[ProposalBase]

Dictionary of ProposalBase objects.

proposals(beamline, run=None)[source]#

List of all proposals on ‘beamline’ in ‘run’.

PARAMETERS

beamlinestr

Canonical name of beam line.

runstr

Canonical name of APS run. Default: the current run.

recent_runs(nruns=6) list[source]#

Return a list of the ‘quantity’ most recent ‘nruns’.

Sorted in reverse chronological order.

PARAMETERS

nrunsint

Number of APS run to include, optional (default: 6, a two year period)

property runs: list#

Return list of known beam line names.

search(query)[source]#

Return a list of ESAFs & proposals that match the query.

The ESAFs and Proposals have already been indexed for search in the esafs() and proposals() methods, respectively.

Parameters

querystr

Search expression.

Here are the keys available for queries:

Query Keys

key

stored

type

meaning

type

True

str

Either “ESAF” or “proposal”

id

True

int

ID number of ESAF or Proposal

pi

True

str

Full name & email of principal investigator

run

True

str

APS run name

title

True

str

Title of ESAF or Proposal

full

False

str

(default key) Full text of ESAF or Proposal

startDate

False

DATETIME

Starting date and time

endDate

False

DATETIME

Ending date and time

users

False

text

List of all users (including email) on ESAF or Proposal

Example query strings

Whoosh query strings [1] will search the full text of each ESAF and Proposal by default. Queries may specify a key (such as ‘pi’).

query

intent

“condensate”

Any ESAF or Proposal with “condensate” anywhere in the full text.

“‘WA-XPCS’”

Any ESAF or Proposal with “WA-XPCS” anywhere.

“cerium OR users:Smith”

Any ESAF or Proposal with “cerium” anywhere or “Smith” as a user.

“title:School pi:Choi”

Any ESAF or Proposal with “school” in the title and “Choi” as a PI.

“type:proposal AND oxid

Any Proposal with a word containing “oxid” anywhere.

Each item in the list of results is a dictionary. The keys are items in the Whoosh schema marked as ‘stored=True’. This dict is a subset of a ESAF or Proposal.

Tip

The ‘id’ and ‘type’ keys in the search results, together with the ‘beamline’ and ‘run’, can be used to obtain the full ESAF or Proposal record.

exception apsbss.server_interface.ServerException[source]#

Base exception for this module.