nexusLIMS.cli.process_records#
CLI command to process new NexusLIMS records.
This module provides a command-line interface for running the NexusLIMS record builder with file locking, timestamped logging, and email notifications. It replaces the functionality previously provided by process_new_records.sh.
Usage#
.. code-block:: bash
nexuslims build-records [OPTIONS]
Options#
.. code-block:: bash
-n, --dry-run : Dry run mode (find files without building records)
-v, --verbose : Increase verbosity (-v for INFO, -vv for DEBUG)
--from <date> : Start date for filtering (ISO format). Defaults to 1 week ago.
Use "none" to disable lower bound.
--to <date> : End date for filtering (ISO format). Omit to disable upper bound.
--version : Show version and exit
--help : Show help message and exit
Module Contents#
Functions#
Set up file logging with timestamped log file. |
|
Check log file for error patterns. |
|
Send error notification email. |
|
Process new NexusLIMS records with logging and email notifications. |
Data#
API#
- nexusLIMS.cli.process_records.logger#
‘getLogger(…)’
- nexusLIMS.cli.process_records.console#
‘Console(…)’
- nexusLIMS.cli.process_records.ERROR_PATTERNS#
- nexusLIMS.cli.process_records.EXCLUDE_PATTERNS#
[‘Temporary failure in name resolution’, ‘NoDataConsentError’, ‘NoMatchingReservationError’]
- nexusLIMS.cli.process_records.setup_file_logging(dry_run: bool = False) tuple[Path, FileHandler][source]#
Set up file logging with timestamped log file.
Creates a log directory structure based on the current date and adds a FileHandler to the root logger. Log files are named with timestamps in the format YYYYMMDD-HHMM.log (or YYYYMMDD-HHMM_dryrun.log for dry runs).
Note: This function removes any existing FileHandlers from the root logger before adding the new handler to prevent handler accumulation across multiple invocations (important for testing scenarios where the same process runs multiple CLI commands).
- nexusLIMS.cli.process_records.check_log_for_errors(log_path: Path) tuple[bool, list[str]][source]#
Check log file for error patterns.
Reads the log file and searches for error patterns (critical, error, fatal) while excluding known non-critical error patterns.
- nexusLIMS.cli.process_records.send_error_notification(log_path: Path, found_patterns: list[str]) None[source]#
Send error notification email.
Sends an email notification with the log file contents when errors are detected. Email sending is skipped if email configuration is not available.
- Parameters:
- Returns:
This function doesn’t return anything. Errors are logged but not raised.
- Return type:
None
Notes:
Email sending is gracefully skipped if configuration is missing
Any email sending errors are logged but don’t cause the function to fail
Uses SMTP with TLS encryption if configured
- nexusLIMS.cli.process_records.main(*, dry_run: bool, verbose: int, from_arg: str | None, to_arg: str | None) None#
Process new NexusLIMS records with logging and email notifications.
This command runs the NexusLIMS record builder to process new experimental sessions and generate XML records. It provides file locking to prevent concurrent runs, timestamped logging, and email notifications on errors.
By default, only sessions from the last week are processed. Use –from=none to process all sessions, or specify custom date ranges with –from and –to.