euler-inference
A small, modality-agnostic runner for applying Python models to indexed datasets.
euler-inference connects an in-process model to one or more
euler-loading modalities. It
intersects their dataset IDs, loads synchronized samples, runs predict(), and
writes indexed outputs while preserving source paths when possible.
indexed modalities → euler-loading → Model.predict(inputs) → indexed outputs
Quick start
Install the package:
pip install euler-inference
Create a model file. The pipeline deliberately keeps the contract tiny:
# /absolute/path/to/model.py
import numpy as np
class Model:
OUTPUTS = [{"key": "depth", "type": "npy"}]
def __init__(self, config: dict, device: str | None = None):
self.scale = config.get("scale", 1.0)
def predict(self, inputs: dict) -> dict:
height, width = inputs["rgb"].shape[-2:]
depth = np.ones((height, width), dtype=np.float32) * self.scale
return {"depth": depth}
Point a config at the model and an indexed modality:
{
"external_model": {
"model_path": "/absolute/path/to/model.py",
"model_config": {"scale": 2.0}
},
"dataset": {
"modalities": {"rgb": "/data/vkitti2/rgb"}
},
"output_base_path": "/data/predictions",
"sample": 0.1,
"sample_mode": "random"
}
Run it:
euler-inference --config config.json
The dataset directories or zip archives must contain ds-crawler metadata.
euler-loading resolves each loader from that metadata, so the model receives
the native loaded value: for example a NumPy array or torch tensor.
Sampling
sample limits work before any files are loaded:
| Value | Meaning |
|---|---|
| omitted | Process every synchronized dataset ID |
integer greater than 1 |
Process at most that many IDs |
float between 0 and 1 |
Process that fraction of all IDs |
Fractional counts round down, with a minimum of one sample for a non-empty dataset. Counts larger than the dataset are capped at its size.
sample_mode controls which IDs are chosen:
sequential(default) selects the first IDs in dataset order.randomselects uniformly without replacement from the complete set of synchronized IDs.
euler-inference -c config.json --sample 250 --sample-mode sequential
euler-inference -c config.json --sample 0.05 --sample-mode random
Resuming an interrupted run
A run that fails part-way (the model raises, a write fails, Ctrl-C) still
saves every output's ds-crawler index, which lists exactly the files written
so far. Rerun the same command with --append to finish the run instead of
starting over:
euler-inference -c config.json --append
For each output, folder or .zip, the files its index lists are kept, and the
model only runs for the samples an output is still missing. A sample that
reached some outputs but not all is predicted again and written only to the
outputs missing it. Files the index lists that are missing or empty are
regenerated.
samplesizes the finished output. Samples already written count toward it; the rest are picked, sequentially or at random, from the samples still missing, so a resumed random subset stays uniformly random.- Folders are extended in place; a zip is rebuilt. The kept files are
copied into
.<name>.zip.append-tmp.zipbeside the archive, which replaces it once finalized. Until then the original is left as it was. An archive that gains no files is not rebuilt at all. - Only the index is trusted. A run that is killed (SIGTERM or SIGKILL, e.g. by a scheduler's time limit or the OOM killer) exits without saving its indexes. A folder output is then regenerated over its files, and an archive the run left unclosed is refused: move it away to regenerate it.
- Append with the original settings. Outputs holding files this run would
not write (another
type,suffix,source_modalityor dataset), another modality key, or the other storage form (--zip) are refused before the model loads. - With nothing left to run, the model is not loaded; the indexes and the outputs manifest are written as after a complete run.
Without --append a run replaces its outputs. Before writing, it removes the
index an earlier run left in a folder output, so a crash cannot leave an index
that lists another run's files.
From Python, pass append=True to infer(); in a config, set "append": true.
Model contract
The external file must define Model with these methods:
class Model:
def __init__(self, config: dict, device: str | None = None): ...
def predict(self, inputs: dict) -> dict: ...
configisexternal_model.model_config, or{}when omitted.inputscontains every regular and hierarchical modality by its configured name. Loader metadata determines each value's type.predict()runs once per sample and returns a dict keyed by configured output names.- The model runs in the current process, so its dependencies must be installed in the active environment.
Models may declare two optional class attributes:
class Model:
OUTPUTS = [{"key": "depth", "type": "npy"}]
DEFAULT_CONFIG = {"backbone": "resnet50"}
User-provided model config takes precedence over DEFAULT_CONFIG. Explicit
config outputs take precedence over OUTPUTS. A model may also define
close(), called once after the run. This is model contract 1.0 (the capability
report's model_contract.version).
Configuration
The complete monolithic example lives at
configs/example_external_model.json.
| Key | Required | Description |
|---|---|---|
external_model.model_path |
yes | Absolute path to the Python model file |
external_model.model_config |
no | Dict or path to a JSON object passed to Model |
dataset.modalities |
yes | Named regular modality paths; IDs are intersected |
dataset.hierarchical_modalities |
no | Named values inherited down a dataset hierarchy |
output_base_path |
yes | Root for prediction datasets |
outputs |
no | Output keys, formats, and writer settings |
device |
no | cpu, cuda, or mps; passed through to the model |
sample |
no | Integer count or fractional dataset size |
sample_mode |
no | sequential or random |
zip |
no | Write each output as a zip dataset |
append |
no | Resume an incomplete output (see Resuming an interrupted run); default false |
strict |
no | Require known modality metadata; default true |
write_outputs_manifest |
no | Write the outputs manifest (below); default true |
A modality can be a path string or a structured entry:
{
"dataset": {
"modalities": {
"rgb": "/data/rgb",
"depth": {"path": "/data/depth", "split": "test"},
"image": {
"path": "/data/multi-modal.zip",
"metadata_scope": "rgb",
"modality_key": "rgb"
}
}
}
}
split selects an inline ds-crawler split. metadata_scope disambiguates
multiple indexed modalities at the same physical path; in deterministic cases
it is inferred from the input name or modality_key.
Outputs
Each output accepts key, type, optional suffix, optional writer metadata,
optional source_modality, and optional source_grid:
{
"outputs": [
{"key": "rgb", "type": "png"},
{
"key": "depth",
"type": "npy",
"writer": {
"euler_loading": {
"loader": "generic_dense_depth",
"function": "depth"
},
"meta": {"radial_depth": false, "scale_to_meters": 1.0}
}
}
]
}
When an output key matches an input modality—or source_modality names
one—the source writer and relative filename are mirrored. Otherwise the legacy
serializer writes {sample_id}{suffix}.{type} beneath the sample hierarchy.
Supported legacy formats are npy, npz, png, jpg, jpeg, and exr.
An image output holds exactly the values it is given, or the write raises
ImageEncodingError and the run stops (it never clips or wraps values):
| Array | png |
jpg |
|---|---|---|
uint8, bool, integers within 0..255 |
8-bit gray, RGB or RGBA | 8-bit gray or RGB |
uint16, other integers within 0..65535, one channel (H, W) |
16-bit gray | error |
| float within [0, 1] | rounded to 8 bits | rounded to 8 bits |
| float outside [0, 1], NaN, negative or wider integers | error | error |
A float more than half an 8-bit step outside [0, 1] is an error: clip or
rescale it in the model, or write npy/npz/exr. (Before 2.16 floats were
clipped and a uint16 depth map was written modulo 256.)
Modality keys
Each output writes a .ds_crawler/dataset-head.json whose modality.key names
what it contains (rgb, depth, sky_mask, …). It comes from
writer.type, else writer.euler_train.modality_type, else the output key.
Prefer modality keys known to
euler-dataset-contract.
Unknown keys are written, but logged as a warning.
When pipeline.output_targets names a datasetType for an output (euler-view
does this), that dataset type is written as modality.key:
- a generic or non-modality writer type (
other,calibration) or another alias of the same modality is replaced, with a warning; - a writer type naming a different modality is an error;
- an output that mirrors an input (
source_modality) keeps the input's key, and a different modality is an error.
Both errors are raised, together with missing required writer.meta in strict
mode, before the model loads. With --no-strict, missing required meta is
filled with euler-dataset-contract's defaults.
Outputs manifest
A successful run writes <output_base_path>/.euler_pipeline/pipeline_outputs.json
(or pipeline.outputs_manifest_path) listing where each output landed and
where it comes from, so tools such as euler-view can register the outputs, and
rebuild their lineage, without guessing:
{
"contract": {"kind": "pipeline_outputs", "version": "1.1"},
"producer": {"name": "euler-inference", "version": "2.16.0", "contractVersion": "0.23.0"},
"lineage": {
"launchId": "08cf710c-98ea-474a-ad15-e07c1b1151e6",
"attempt": "4242.0.0",
"sessionId": "a1b2c3",
"experimentId": "exp-17",
"model": {
"name": "model",
"path": "/models/marigold/model.py",
"sha256": "9b1c…",
"card": "/models/marigold/model_card.json",
"checkpoint": {"ref": "/ckpt/epoch_12.pt", "path": "/ckpt/epoch_12.pt", "bytes": 1340000000, "modifiedAt": "2026-11-20T08:00:00Z"}
},
"inputs": [
{"modality": "rgb", "path": "/data/vkitti2/rgb", "split": "test", "datasetId": "vkitti2", "modalityKey": "rgb"}
],
"selection": {"sampleMode": "random", "append": false, "sample": 0.1}
},
"outputRoot": "/data/predictions",
"completedAt": "2026-11-11T12:00:00Z",
"outputs": [
{
"slot": "depth",
"datasetType": "depth",
"relativePath": "depth.zip",
"storage": "zip",
"metadata": {"modalityKey": "depth", "datasetId": "vkitti2", "fileCount": 120}
}
]
}
The manifest only ever describes complete outputs. A manifest from an earlier
run into the same root is removed before anything is written, and a failed run
writes none. It is replaced atomically. With pipeline.output_targets, only the
targeted outputs are listed, with their slots, modelModalityId and
datasetType. Disable it with --no-outputs-manifest or
"write_outputs_manifest": false.
lineage holds what is known: launchId (EULER_LAUNCH_ID, or
pipeline.launch_id; the two must agree), attempt (euler-connector's, the
one its progress records carry), sessionId (EULER_SESSION_ID),
experimentId (EULER_EXPERIMENT_ID); the model file and its SHA-256, the
model card (CLI and infer(model_card="…")), the configured checkpoint
(ref as given; path, size and time when it is a local file, never hashed);
every input's root, split, scope and its head's dataset id and modality key;
and the sample selection. Keys that are unknown are left out.
Run status (run.json)
.euler_pipeline/run.json (next to the manifest) says what the run writing
the root is doing. It is written atomically when the run starts and replaced
when it ends:
{
"contract": {"kind": "pipeline_run", "version": "1.0"},
"producer": {"name": "euler-inference", "version": "2.16.0", "contractVersion": "0.23.0"},
"state": "failed",
"startedAt": "2026-11-26T10:00:00Z",
"host": "gpu-node-17",
"pid": 12399,
"launchId": "08cf710c-98ea-474a-ad15-e07c1b1151e6",
"attempt": "4242.0.0",
"outputRoot": "/data/predictions",
"finishedAt": "2026-11-26T10:20:00Z",
"samples": {"datasetSize": 1200, "selected": 120, "written": 57},
"error": "RuntimeError: CUDA out of memory"
}
state is running, completed or failed; samples.kept counts the
samples an append run kept. A running file whose process is gone belongs to a
run that was killed (SIGKILL, a node failure, a time limit). It is written also
with --no-outputs-manifest.
One output root
A run writes below one output root. -o/--output-base-path and
pipeline.output_root must name the same directory (or give only one), and
every pipeline.output_targets[].path must be <output root>/<relativePath>;
otherwise the run stops before anything is written.
How an output relates to its input (source_grid)
A model that crops or resizes its input returns an output on another pixel grid than the image it came from. The shapes alone cannot tell whether a 400×872 depth map is the top-left of a 400×879 input or a squeezed copy of it, so declare it per output:
class Model:
OUTPUTS = [{"key": "depth", "type": "npy", "source_grid": "crop_top_left"}]
source_grid |
The output is |
|---|---|
"identity" |
on the input's grid (sizes must match) |
"resize" |
the whole input stretched to the output size |
"crop_top_left" |
the top-left part of the input, e.g. a latent model that floors each side to a multiple of 8 |
"crop_center" |
the centred part of the input |
The input defaults to source_modality, else the only regular modality, else
the only RGB one; name it with {"rule": "resize", "source": "rgb"}
otherwise. For every sample, euler-inference turns the rule and the actual
input and output sizes into euler-dataset-contract's exact source_grid
(source size plus affine pixel mapping) and writes it to that file's
attributes. When every sample gets the same one, it also goes into the
output's dataset head (modality.meta.source_grid). euler-eval reads it to
score the prediction on the right pixels. An output whose size differs from
its input's without a declared rule logs a warning, and evaluation falls back
to guessing. Recording needs euler-dataset-contract with source_grid
support.
Known limitation: mappings the sizes do not determine
A rule turns into an exact mapping only because the input and output sizes pin it down. Some preprocessing does not leave enough in the sizes:
- a resize to an intermediate size followed by a crop, such as
Depth-Anything-3's
upper_bound_crop/lower_bound_crop(resize the long or short side toprocess_res, then centre-crop each side down to a multiple of 14); the intermediate size cannot be recovered from the input and output sizes in general; - letterboxing or padding to a fixed size;
- crops whose position depends on the content or on randomness.
None of the four rules describes these, and declaring the nearest one
records a wrong mapping. Until models can report it themselves, either make
such an output land on a rule-describable grid (resize or pad it back onto
the input grid and declare identity, or pick a preprocessing mode that is
a plain resize, like Depth-Anything-3's default upper_bound_resize), or
declare no source_grid and set euler-eval's spatial_alignment by hand.
Open design question (deferred): let a model return the exact
source_grid matrix per sample, which euler-dataset-contract can already
store. That needs a channel in the model contract, for example an optional
reserved "source_grid" key in predict()'s result mapping output keys to
matrices, or an optional Model.source_grid(inputs, outputs) method.
Either way euler-inference would validate the matrix
(euler_dataset_contract.validate_source_grid) and record it exactly as it
records rule-derived ones.
Model cards
A model card keeps model-owned metadata beside the model and leaves paths to
the operator. Placeholders use {{type:name}} syntax:
{
"model": "./model.py",
"checkpoint": "{{checkpoint:weights}}",
"inputs": {"rgb": "{{modality:rgb}}"},
"outputs": [{"key": "depth", "type": "npy"}],
"sample": 100,
"sample_mode": "random"
}
euler-inference \
--model-card model_card.json \
--set weights=/models/weights.pt \
--data rgb=/data/rgb \
--output-base-path /data/predictions
Use --hierarchical-data name=/path for hierarchical placeholders. See
examples/model_card.json and
examples/model_template.py for a complete pair.
Python API
from euler_inference import infer, read_output_paths
root = infer(
model_path="model.py",
dataset_modalities={"rgb": "/data/ds:test#scope=rgb"},
outputs=[{"key": "depth"}], # depth's default storage format
output_base_path="/data/predictions",
sample=0.1,
sample_mode="random",
)
read_output_paths(root) # {"depth": Path("/data/predictions/depth")}
Inside an euler-view launch, pass the launch's pipeline.json (output root,
manifest path and output targets) instead of an output path:
infer(..., pipeline="pipeline.json"); a mapping or a
PipelineRuntimeConfig works too. infer() also accepts model_card=,
bindings=, data=, and hierarchical_data=, and returns the output root.
Outputs without a format
An output that names no type is written in its modality key's default
storage format from euler-dataset-contract (storage_format(key); euler-suite report lists them): depth as float32 .npy in metres, RGB as 8-bit PNG,
label maps as .npy ids. The head gets the meta that follows (scale_to_meters,
the contract's defaults) and, where the format's range depends on the data,
the range of the values written. {"key": "pred", "modality": "depth"} names
the key when the model's output key is another; writer.meta overrides
single fields. Values the format cannot hold (an RGB float outside [0, 1], a
NaN in an integer format) raise StorageEncodingError instead of being
clipped. Every output's head names euler-loading's generic reader of its key
and file type, so the predictions load back.
Capability report
euler-inference registers an euler.capabilities entry point,
euler-inference (euler_inference.capabilities:capability_report). Its
inference_capability_report (1.1) lists the model contract version, the model
card and pipeline fields, the manifest (pipeline_outputs 1.1) and run status
(pipeline_run 1.0) contracts, every output format with the arrays it encodes
(and whether EXR is available), the default output format of outputs without
a type, the Python API, storage kinds and sampling modes.
euler-suite report from euler-dataset-contract collects it; euler-view reads
it per cluster environment.
Development
git clone https://github.com/d-rothen/euler-inference.git
cd euler-inference
uv sync --extra dev
uv run pytest -q
The unit suite uses synthetic datasets and does not require model weights or a GPU. Contributions should keep the model boundary modality-agnostic and add a focused regression test for behavior changes.
The VKITTI2 integration checks are opt-in:
VKITTI2_RGB_PATH=/data/vkitti2/rgb \
VKITTI2_TEXTGT_PATH=/data/vkitti2/textgt \
uv run pytest -m real
Common integration mistakes
model_pathin a monolithic config must be absolute.- Output keys returned by
predict()must match configuredoutputs[].key. - Relative imports in dynamically loaded model files are fragile; add the
model directory to
sys.pathor package the model code. - Explicit
source_modalityvalues must name a regular input with a resolvable euler-loading writer. - A model that crops or resizes its input without declaring
source_gridleaves evaluation to guess which one it did.
Metadata
Release files for euler-inference 2.18.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| euler_inference-2.18.0.tar.gz | 108.7 kB | Without provenance | Details for euler_inference-2.18.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| euler_inference-2.18.0-py3-none-any.whl | Python 3 | none | any | Details for euler_inference-2.18.0-py3-none-any.whl |
Total release size: 179.6 kB
Release files / euler_inference-2.18.0.tar.gz
| Download URL | euler_inference-2.18.0.tar.gz |
|---|---|
| Size | 108.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69425b5a8e6481668ab1aba757bdf4a7a9d24b4eda484cc93378d2feda0902d3
|
|
BLAKE2b-256 checksum How to use checksums |
d2dabaa85a382875b76174ff97849ff38ce35684718dab253c42c9ec5c641712
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / euler_inference-2.18.0-py3-none-any.whl
| Download URL | euler_inference-2.18.0-py3-none-any.whl |
|---|---|
| Size | 70.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
129cfb8f5f13d93d0e2e2798d04f7488eb6766730bac943a5c8998346b478317
|
|
BLAKE2b-256 checksum How to use checksums |
31c5c502289bb0bacce59d14c7b4476bc2f86792b66f60756ed42a1178154e97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for euler-inference 2.18.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.