SingleFileExtractorContext#
- class nominal.experimental.extractor.context.SingleFileExtractorContext(output_dir: Path)#
Bases:
ExtractorContextContext for
single_file_extractor()functions: declare the one output viaset_output().- property additional_tags: dict[str, str]#
Tags the ingest request applies to all data from this run; empty when Nominal didn’t inject them.
- property dataset_rid: str | None#
RID of the dataset this run ingests into.
None when Nominal injected no value, empty included; see
ingest_job_rid.
- property ingest_job_rid: str | None#
RID of the ingest job running this extractor.
None when Nominal injected no value, empty included – an empty environment variable means the same thing as an absent one here, as it does everywhere else in this contract.
- property inputs: list[Path]#
All input files Nominal mounted for this run.
Legacy authoring API: prefer a separate
@inputdeclaration per registered input. Access logs one migration warning per run; it contributes no registration metadata. Taken from the registered_NOMINAL_INPUTSmetadata when present, in the order Nominal serializes them; otherwise discovered by listing the input mount, sorted by name.
- property job_timestamp_metadata: TimestampMetadata | None#
The job-level timestamp metadata this run’s outputs default to.
This is the metadata the pipeline resolved for the whole job (the ingest request’s override when given, else the image’s registered default) – the value a manifest output falls back to when it declares no per-output timestamp metadata of its own. None when Nominal didn’t inject it.
- get_param(name: str, default: str | None = None) str | None#
Read an optional parameter from the environment, or
defaultwhen unset.Legacy authoring API: prefer
@parameter("parts", type=int, default=2)and apartscallback argument. This method logs one migration warning per run and contributes no registration metadata. Its returned values remain strings (or None). Name resolution matchesparam(). With registered contract metadata present, an unregisterednameraisesExtractorError.
- input(name: str | None = None) Path#
Resolve an input file.
Legacy authoring API: prefer
@input("source", envvar="SOURCE")and asourcecallback argument. This method logs one migration warning per run and contributes no registration metadata.With
name– the input’s registered display name or its environment variable – returns that input’s path. Without it, returns the sole mounted input file, raising if there is not exactly one.
- param(name: str) str#
Read a required parameter from the environment.
Legacy authoring API: prefer
@parameter("parts", envvar="PARTS", type=int)and apartscallback argument. This method logs one migration warning per run and contributes no registration metadata.name– the parameter’s registered display name or its environment variable – is resolved against_NOMINAL_PARAMETERSwhen Nominal injected it; otherwise it is treated directly as the environment variable. RaisesExtractorErrorwhen the parameter is not set. Values returned by this legacy method remain strings. With registered contract metadata present, an unregisterednameraisesExtractorError.
- set_output(path: str | PathLike[str]) Path#
Declare the single file you wrote to the output directory.
Records the file (it must already exist under
output_dir); it does not write anything itself. A single-file extractor produces exactly one output, so a second call raises. Usemanifest_extractor()(with the image registered under theMANIFESToutput format) to emit multiple files.