nexusLIMS.builder package¶
Submodules¶
nexusLIMS.builder.record_builder module¶
Attributes
-
nexusLIMS.builder.record_builder.XSLT_PATH¶ The path to
cal_events_to_nx_record.xsl, which is used to translate the calender event response XML to a format compatible with the Nexus Schema- Type:
-
nexusLIMS.builder.record_builder.build_acq_activities(instrument, dt_from, dt_to, sample_id, generate_previews)[source]¶ Build an XML string representation of each AcquisitionActivity for a single microscopy session. This includes setup parameters and metadata associated with each dataset obtained during a microscopy session. Unique AcquisitionActivities are delimited via clustering of file collection time to detect "long" breaks during a session.
- Parameters:
instrument (
Instrument) -- One of the NexusLIMS instruments contained in the database. Controls what instrument calendar is used to get events.dt_from (datetime.datetime) -- The starting timestamp that will be used to determine which files go in this record
dt_to (datetime.datetime) -- The ending timestamp used to determine the last point in time for which files should be associated with this record
sample_id (str) -- An identifier for the sample from which data was collected
generate_previews (bool) -- Whether or not to create the preview thumbnail images
- Returns:
acq_activities (str) -- A string representing the XML output for each AcquisitionActivity associated with a given reservation/experiment on a microscope.
activities (
listofAcquisitionActivity:) -- The list ofAcquisitionActivityobjects generated for the record
-
nexusLIMS.builder.record_builder.build_new_session_records()[source]¶ Fetches new records that need to be built from the database (using
get_sessions_to_build()), builds those records usingbuild_record()(saving to the NexusLIMS folder), and returns a list of resulting .xml files to be uploaded to CDCS.- Returns:
xml_files -- A list of record files that were successfully built and saved to centralized storage
- Return type:
list of str
-
nexusLIMS.builder.record_builder.build_record(instrument, dt_from, dt_to, user=None, sample_id=None, generate_previews=True)[source]¶ Construct an XML document conforming to the NexusLIMS schema from a directory containing microscopy data files. For calendar parsing, currently no logic is implemented for a query that returns multiple records
- Parameters:
instrument (
Instrument) -- One of the NexusLIMS instruments contained in the database. Controls what instrument calendar is used to get events.dt_from (
datetimeor None) --dt_to (
datetimeor None) -- Thedt_from -- A
datetimeobject representing the starting timestamp that will be used to determine which files go in this record, as infetch_xml().dt_to -- A
datetimeobject representing the ending timestamp used to determine the last point in time for which files should be associated with this record, as infetch_xml().user (str or None) -- A valid NIST username (the short format: e.g. "ear1" instead of ernst.august.ruska@nist.gov). Controls the results returned from the calendar - value is as specified in
get_events()sample_id (str or None) -- A unique identifier pointing to a sample identifier for data collected in this record. If None, a UUIDv4 will be generated
generate_previews (bool) -- Whether or not to create the preview thumbnail images
- Returns:
xml_record -- A formatted string containing a well-formed and valid XML document for the data contained in the provided path
- Return type:
-
nexusLIMS.builder.record_builder.dry_run_file_find(s)[source]¶ Get the files that would be included for any records to be created based off the supplied session
- Parameters:
s (Session) -- A session read from the database
- Returns:
files -- A list of strings containing the files that would be included for the record of this session (if it were not a dry run)
- Return type:
list of str
-
nexusLIMS.builder.record_builder.dry_run_get_calendar_event(s)[source]¶ Get the calendar event that would be used to create a record based off the supplied session
- Parameters:
s (Session) -- A session read from the database
- Returns:
cal_event -- A list of strings containing the files that would be included for the record of this session (if it were not a dry run)
- Return type:
CalendarEvent
-
nexusLIMS.builder.record_builder.dump_record(instrument, dt_from, dt_to, filename=None, user=None, generate_previews=True)[source]¶ Writes an XML record composed of information pulled from the Sharepoint calendar as well as metadata extracted from the microscope data (e.g. dm3 files).
- Parameters:
instrument (
Instrument) -- One of the NexusLIMS instruments contained in the database. Controls what instrument calendar is used to get events.dt_from (datetime.datetime) -- The starting timestamp that will be used to determine which files go in this record
dt_to (datetime.datetime) -- The ending timestamp used to determine the last point in time for which files should be associated with this record
filename (None or str) -- The filename of the dumped xml file to write. If None, a default name will be generated from the other parameters
user (str) -- A string which corresponds to the NIST user who performed the microscopy experiment
generate_previews (bool) -- Whether or not to create the preview thumbnail images
- Returns:
filename -- The name of the created record that was returned
- Return type:
-
nexusLIMS.builder.record_builder.get_files(path, dt_from, dt_to)[source]¶ Get list of files under a path that were last modified between the two given timestamps.
- Parameters:
path (str) -- The file path in which to search for files
dt_from (datetime.datetime) -- The starting timestamp that will be used to determine which files go in this record
dt_to (datetime.datetime) -- The ending timestamp used to determine the last point in time for which files should be associated with this record
- Returns:
files -- A list of the files that have modification times within the time range provided (sorted by modification time)
- Return type:
-
nexusLIMS.builder.record_builder.process_new_records(dry_run=False)[source]¶ Using
build_new_session_records(), process new records, save them to disk, and upload them to the NexusLIMS CDCS instance.
-
nexusLIMS.builder.record_builder.validate_record(xml_filename)[source]¶ Validate an .xml record against the Nexus schema
- Parameters:
xml_filename (str or io.StringIO or io.BytesIO) -- The path to the xml file to be validated (can also be a file-like object like StringIO or BytesIO)
- Returns:
validates -- Whether or not the record validates against the Nexus schema
- Return type:
