nexusLIMS.harvesters.nemo#

NEMO harvester module.

This module contains the functionality to harvest instruments, reservations, etc. from an instance of NEMO (https://github.com/usnistgov/NEMO/), a calendering and laboratory logistics application.

Submodules#

Package Contents#

Functions#

create_res_event_from_usage_event

Create ReservationEvent from usage event with question data.

res_event_from_session

Create reservation event from session.

API#

nexusLIMS.harvesters.nemo.create_res_event_from_usage_event(usage_event: dict, session: Session, nemo_connector: NemoConnector, field: str = 'run_data') ReservationEvent[source]#

Create ReservationEvent from usage event with question data.

Assumes usage_event has been expanded via _parse_event() and has valid question data in the specified field (run_data or pre_run_data).

Both run_data and pre_run_data fields are JSON-encoded strings that use the same structure as reservation question_data, so we can parse them and reuse existing helper functions by creating a wrapper dict.

Parameters:
  • usage_event – The usage event dictionary from NEMO API

  • session – The Session object

  • nemo_connector – The NemoConnector instance

  • field – Which field to extract question data from (“run_data” or “pre_run_data”)

Returns:

The created reservation event

Return type:

ReservationEvent

Raises:
nexusLIMS.harvesters.nemo.res_event_from_session(session: Session, connector: NemoConnector | None = None) ReservationEvent[source]#

Create reservation event from session.

Create an internal ReservationEvent representation of a session by finding a matching reservation in the NEMO system and parsing the data contained within into a ReservationEvent.

This method assumes a certain format for the “reservation questions” associated with each reservation and parses that information into the resulting ReservationEvent. The most critical of these is the data_consent field. If an affirmative response in this field is not found (because the user declined consent or the reservation questions are missing), a record will not be built.

The following JSON object represents a minimal schema for a set of NEMO “Reservation Questions” that will satisfy the expectations of this method. Please see the NEMO documentation on this feature for more details.

[
  {
    "type": "textbox",
    "name": "project_id",
    "title": "Project ID",
  },
  {
    "type": "textbox",
    "name": "experiment_title",
    "title": "Title of Experiment",
  },
  {
    "type": "textarea",
    "name": "experiment_purpose",
    "title": "Experiment Purpose",
  },
  {
    "type": "radio",
    "title": "Agree to NexusLIMS curation",
    "choices": ["Agree", "Disagree"],
    "name": "data_consent",
    "default_choice": "Agree"
  },
  {
    "type": "group",
    "title": "Sample information",
    "name": "sample_group",
    "questions": [
      {
        "type": "textbox",
        "name": "sample_name",
        "title": "Sample Name / PID",
      },
      {
        "type": "radio",
        "title": "Sample or PID?",
        "choices": ["Sample Name", "PID"],
        "name": "sample_or_pid",
      },
      {
        "type": "textarea",
        "name": "sample_details",
        "title": "Sample Details",
      }
    ]
  }
]
Parameters:
  • session – The session for which to get a reservation event

  • connector (Optional[NemoConnector], optional) – Optional NemoConnector to use instead of looking one up. Useful for testing.

Returns:

res_event – The matching reservation event

Return type:

ReservationEvent