mxcubecore.HardwareObjects.abstract.PyISPyBDataAdapter#

Classes

PyISPyBDataAdapter(client, beamline_name[, ...])

Adapter to convert data from PyISPyB REST API.

class mxcubecore.HardwareObjects.abstract.PyISPyBDataAdapter.PyISPyBDataAdapter(client: PyISPyBRestClient, beamline_name: str, new_session_duration_days: int = 2)[source]#

Bases: object

Adapter to convert data from PyISPyB REST API.

Parameters:
associate_bl_sample_and_energy_scan(entry_dict: dict) int[source]#

Associates bl sample and energy scan in PyISPyB.

Parameters:

entry_dict (dict) – A dictionary containing energy scan and bl sample information.

Returns:

The id of the association. -1 if association failed.

Return type:

int

create_session(proposal: Proposal) Session[source]#

Creates new session via PyISPyB REST API for the given proposal.

Parameters:

proposal (Proposal) –

Return type:

Session

find_detector(manufacturer, model, mode, type='') dict | None[source]#

Finds detector by its type, manufacturer, model and mode.

Gives the first matching detector or None if no match is found. :param manufacturer: The manufacturer of the detector. :param model: The model of the detector. :param mode: The mode of the detector. :param type: The type of the detector (optional).

Returns:

A dictionary containing detector details.

Return type:

dict | None

find_proposal(code: str, number: str) Proposal[source]#

Finds a proposal by its code and number.

Parameters:
  • code (str) –

  • number (str) –

Return type:

Proposal

find_sessions_by_proposal_and_beamline_for_today(code: str, number: str, beamline: str) list[mxcubecore.model.lims_session.Session][source]#

Finds todays sessions by proposal code, number and beamline name.

Parameters:
  • code (str) –

  • number (str) –

  • beamline (str) –

Return type:

list[mxcubecore.model.lims_session.Session]

get_current_user_data() dict[source]#

Fetches current user details.

Return type:

dict

get_data_collection(data_collection_id: int) dict[source]#

Fetches data collection details from PyISPyB.

Parameters:

data_collection_id (int) – The id of the data collection to fetch.

Returns:

Dictionary containing data collection details or empty if fetching failed.

Return type:

dict

get_proposals() list[mxcubecore.model.lims_session.Proposal][source]#

Returns proposals to which authenticated user has access.

Return type:

list[mxcubecore.model.lims_session.Proposal]

get_samples(proposal_id: int) list[dict][source]#

Fetches samples for the given proposal id from PyISPyB.

Parameters:

proposal_id (int) –

Return type:

list[dict]

get_session(session_id: int) dict[source]#

Fetches session details from PyISPyB by session id.

Parameters:

session_id (int) –

Return type:

dict

get_sessions_by_code_and_number(code: str, number: str, beamline: str) LimsSessionManager[source]#

Finds a session by its proposal code and number and beamline name.

Parameters:
  • code (str) –

  • number (str) –

  • beamline (str) –

Return type:

LimsSessionManager

get_sessions_by_username(username: str = '', beamline_name: str = '') LimsSessionManager[source]#

Get the list of sessions for the authenticated user and current beamline.

PyISPyB returns only proposals accessible to the authenticated user. For each proposal, the method fetches sessions for the current month and picks one overlapping with the current time. If no such session exists, a new one is created. :param username: Username to fetch sessions for (left for consistency) :param beamline_name: Beamline name to fetch sessions for (left for consistency)

Returns:

A manager containing the list of sessions

Return type:

LimsSessionManager

Parameters:
  • username (str) –

  • beamline_name (str) –

store_beamline_setup(session_id: int, bl_config: dict) int | None[source]#

Stores beamline setup in PyISPyB and associates it with the session.

Parameters:
  • session_id (int) – The id of the session to associate the beamline setup with.

  • bl_config (dict) – A dictionary containing beamline setup information.

Returns:

The id of the stored beamline setup. None if failed.

Return type:

int | None

store_energy_scan(energyscan: dict) dict[str, int][source]#

Stores energy scan in PyISPyB

Parameters:

energyscan (dict) – A dictionary containing energy scan information.

Returns:

number}, where number is the id of the stored energy scan.

Return type:

Dictionary {“energyScanId”

store_image(image_dict: dict) int[source]#

Stores a data collection image in PyISPyB.

Parameters:

image_dict (dict) – A dictionary containing image information (paths and properties of data collection). Expected to contain “dataCollectionId” key.

Returns:

The id of the stored image. 0 if failed or dataCollectionId is missing.

Return type:

int

store_robot_action(robot_action: dict) int[source]#

Stores robot action.

Parameters:

robot_action (dict) – A dictionary containing robot action information. Expected to contain “sampleId” key.

Returns:

The id of the robot action. 0 if failed or required keys are missing.

Return type:

int

store_xfe_spectrum(xfe_spectrum: dict) dict[str, int][source]#

Stores XFE fluorescence spectrum in PyISPyB

Parameters:

xfe_spectrum (dict) – A dictionary containing XFE fluorescence spectrum information.

Returns:

number}, where number is the id of the stored XFE fluorescence spectrum.

Return type:

Dictionary {“xfeFluorescenceSpectrumId”

update_bl_sample(bl_sample: dict) dict[source]#

Updates beamline sample in PyISPyB.

Parameters:

bl_sample (dict) – A dictionary containing beamline sample information. Expected to contain “blSampleId” key.

Returns:

Response from PyISPyB - a dictionary containing updated beamline sample details or empty if updating failed.

Return type:

dict

update_session(session: dict) dict[source]#

Updates Beamline Setup of existing session.

Returns dictionary containing updated session details from PyISPyB. If updating failed, returns empty dictionary.

Parameters:

session (dict) –

Return type:

dict