nexusLIMS.builder.preflight#

Preflight checks for the NexusLIMS record builder.

This module provides a run_preflight_checks() function that validates the environment before the record builder starts any harvesting or record building work. Misconfigurations are caught early and reported with actionable messages.

ivar CheckResult:

Dataclass representing the result of a single preflight check.

ivar PreflightError:

Exception raised when one or more error-severity checks fail.

Module Contents#

Classes#

CheckResult

Result of a single preflight check.

Functions#

run_preflight_checks

Run all preflight checks and return the results.

API#

class nexusLIMS.builder.preflight.CheckResult[source]#

Result of a single preflight check.

Parameters:
  • name – Short label for the check (e.g. "db_tables").

  • passed – Whether the check passed.

  • severity"error" if the check failure means the run cannot succeed; "warning" if suspicious but the run may still succeed.

  • message – Human-readable, actionable description of the result.

name#

Type: str

passed#

Type: bool

severity#

Type: typing.Literal[error, warning]

message#

Type: str

exception nexusLIMS.builder.preflight.PreflightError(failed_checks: list[CheckResult])[source]#

Bases: Exception

Raised when one or more preflight checks with severity=’error’ fail.

Parameters:

failed_checks – The list of failed CheckResult objects with severity="error".

nexusLIMS.builder.preflight.run_preflight_checks(*, dry_run: bool = False) list[CheckResult][source]#

Run all preflight checks and return the results.

Checks are grouped into three categories:

  • Always-run single-result checks — DB connectivity, table existence, Alembic migration status, and instrument count.

  • Always-run multi-result checks — per-instrument filestore paths, harvester imports, timezone validity, and NEMO config presence.

  • Write-path checks (skipped in dry-run) — data path writability and export destination validation.

Every check is wrapped in try/except Exception so that an unexpected failure in one check never prevents the remaining checks from running.

Parameters:

dry_run – When True, skip checks that require write access (checks 8 and 9).

Returns:

All check results in the order they were executed.

Return type:

list[CheckResult]