registry.RunRegistry

registry.RunRegistry(
    db_path='josh_runs.duckdb',
    enable_spatial=True,
    _conn=None,
    _spatial_filter_bbox=None,
    _spatial_filter_geojson=None,
    _time_filter_range=None,
)

DuckDB-backed registry for tracking parameter sweeps and job runs.

Supports both file-based persistence and in-memory mode (using “:memory:”).

Attributes

Name Type Description
db_path Path | str Path to the DuckDB database file, or “:memory:” for in-memory.
enable_spatial bool If True, load spatial extension and create geometry column.
_conn Any DuckDB connection (created automatically).

Examples

>>> # File-based (persistent)
>>> registry = RunRegistry("experiment.duckdb")
>>> # In-memory (for testing)
>>> registry = RunRegistry(":memory:")
>>> # With spatial support enabled (default)
>>> registry = RunRegistry("experiment.duckdb", enable_spatial=True)
>>> # Context manager
>>> with RunRegistry("experiment.duckdb") as registry:
...     session_id = registry.create_session(...)

Methods

Name Description
bottle Create a self-contained bottle archive from a registered run.
check_consistency Detect run<->analysis drift between the execution and data tables.
check_design Check a target design’s coverage against current runs.
check_remote_consistency Check that current runs’ expected outputs actually landed in the bucket.
check_sparsity Check for sparse columns in cell_data.
close Close the database connection.
compare_configs Export two run configs and open a side-by-side diff in an IDE.
compare_josh Export two runs’ josh sources and open a side-by-side diff in an IDE.
complete_run Record the completion of a job run.
create_session Create a new sweep session.
delete_design Delete a registered design and its requirements.
describe_labels Human-readable listing of all labeled runs.
describe_run Human-readable detail for a single run.
describe_sessions Human-readable listing of all sweep sessions.
describe_summary Human-readable overview of everything in the registry.
drop_run Delete all registry state for a run, so its config can be redone.
export_config Export a run’s config content to a file for IDE diffing.
export_josh Export a run’s josh source content to a file for IDE viewing/diffing.
export_results_df Export session results as a pandas DataFrame.
find_by_attribute Find run_hashes carrying attribute key == value.
find_current_by_attribute Find current runs by attribute, resolved with label and attributes.
find_tagged Find every key in scope whose tags[tag_key] == value.
get_attributes Get the analysis attributes attached to a run_hash, or {} if none.
get_config_by_hash Get config information by run hash.
get_configs_for_session Get all configs for a session.
get_custom_tags Get the tags attached to key under a synthetic scope.
get_data_summary Get summary of all data in registry.
get_debug_output_files Get debug output file paths for a labeled/hashed run.
get_design Load a registered :class:TargetDesign, or None if absent.
get_file_mappings Get the external data file mappings for a run.
get_output_uris Resolve registered export URIs for runs, jar-free from run_outputs.
get_replicate_count Get the number of distinct replicates for a run hash from cell_data.
get_run Get run information by ID.
get_run_info Get aggregated structured detail for a single run.
get_run_status Get a run’s lifecycle status.
get_runs_by_parameters Query runs by parameter values.
get_runs_for_hash Get all runs for a run hash.
get_session Get session information by ID.
get_session_summary Get aggregated statistics for a session.
get_tags_by_run_id Get the tags attached to a run_id, or {} if none.
get_tags_by_session_id Get the tags attached to a session_id, or {} if none.
label_run Assign a human-readable label to a run configuration.
list_attribute_keys List all distinct run-level attribute keys in use.
list_config_columns List all parameter column names in config_parameters.
list_config_parameters List all config parameter names from sweep configurations.
list_designs List the names of all registered target designs, sorted.
list_entity_types List all entity types found in cell_data.
list_export_variables List all export variable names from simulation outputs.
list_labels List all labeled runs.
list_parameters Alias for list_config_parameters(). Deprecated, use list_config_parameters().
list_sessions List sessions, optionally filtered by experiment name.
list_tag_keys List all distinct tag keys in use for a scope.
list_variable_columns List all variable column names in cell_data.
list_variables Alias for list_export_variables(). Deprecated, use list_export_variables().
load_debug Load debug messages for a run from registered debug output files.
loaded_replicates Return the set of replicate indices already loaded for a run hash.
mark_run Set a run’s lifecycle status.
pull_from_s3 Pull a registry’s Parquet export from S3 back into this registry.
push_to_s3 Publish this registry’s tables to S3 as Parquet, one file per table.
query Execute a SQL query with parameters.
query_remote Aggregate a variable directly against bucket-resident CSVs, no ingest.
register_design Persist (or replace) a :class:TargetDesign by name.
register_output Register an output file from a run.
register_run Register a job configuration (run specification).
reset_run Clear a run’s executions/results and reactivate it, keeping its config.
resolve_config_source Locate the original .jshc file on disk and check if it still matches.
resolve_josh_source Locate the original .josh file on disk and check if it still matches.
resolve_label Get the run_hash for a labeled run.
run_history Walk the supersession chain for a run, newest (current) first.
set_attributes Attach analysis attributes (factors, join keys) to a run_hash.
spatial_filter Context manager for spatial filtering of queries.
start_run Record the start of a job run.
supersede Mark run_hash as the replacement for an existing run.
tag_by_run_id Attach free-form JSON metadata to a specific run execution.
tag_by_session_id Attach free-form JSON metadata to a sweep session.
tag_custom Attach free-form JSON metadata under a synthetic scope.
time_filter Context manager for temporal filtering of queries.
to_csv Export a table to CSV format.
to_parquet Export a table to Parquet format.
update_session_status Update the status of a session.

bottle

registry.RunRegistry.bottle(
    label_or_hash,
    output_dir=Path('bottles'),
    cli=None,
    omit_jshd=False,
)

Create a self-contained bottle archive from a registered run.

By default, copies data files into the archive and raises if any are missing. Use omit_jshd=True for lightweight archives when the recipient has the data locally.

Parameters

Name Type Description Default
label_or_hash str Run label or run_hash to bottle. required
output_dir str | Path Directory for the archive. Default: ./bottles/. Path('bottles')
cli Any | None Optional JoshCLI instance for JAR metadata. None
omit_jshd bool If True, skip copying .jshd data files. False

Returns

Name Type Description
Path Path to the created .tar.gz archive.

Raises

Name Type Description
KeyError If the run is not found.
ValueError If josh content is not stored for the run.
FileNotFoundError If omit_jshd is False and a data file is missing.

check_consistency

registry.RunRegistry.check_consistency(run_hash=None, *, strict=False)

Detect run<->analysis drift between the execution and data tables.

Guards the principle that the registry (analysis) must reflect what running produced. Checks (scoped to run_hash if given, else all runs):

  • data_without_configcell_data for a run_hash with no job_configs row (orphaned data; error).
  • orphan_cell_datacell_data whose run_id is absent from job_runs (the FK should prevent this; error if seen).
  • duplicate_replicate — a (run_hash, replicate) present under more than one run_id (row inflation from a pre-fix re-ingest; error).
  • ran_not_ingested — a run_hash with a succeeded job_runs row but no cell_data (ran but results never loaded; warning).

Parameters

Name Type Description Default
run_hash str | None Limit the check to one run, or None for the whole registry. None
strict bool If True, raise RuntimeError when any issue is found. False

Returns

Name Type Description
list[ConsistencyIssue] A list of :class:ConsistencyIssue (empty if consistent).

Raises

Name Type Description
RuntimeError If strict and any issue is found.

check_design

registry.RunRegistry.check_design(design)

Check a target design’s coverage against current runs.

Completeness is asserted over attributes, not run_hashes: a requirement is satisfied when at least min_active distinct active runs carry its attributes (as a superset). Superseded/bad runs never count toward satisfaction but are surfaced per requirement so an unmet cell that has runs reads as “present but retired”, not “nothing ran”. See REGISTRY_PROVENANCE.md §12.

Parameters

Name Type Description Default
design str | TargetDesign A registered design name, or a :class:TargetDesign to check ad hoc without persisting it. required

Returns

Name Type Description
A TargetCoverageReport class:TargetCoverageReport.

Raises

Name Type Description
KeyError If a name is given that isn’t registered.

check_remote_consistency

registry.RunRegistry.check_remote_consistency(
    output_type='patch',
    current_only=True,
    endpoint=None,
    access_key=None,
    secret_key=None,
    use_ssl=None,
)

Check that current runs’ expected outputs actually landed in the bucket.

The bucket-aware sibling of :meth:check_consistency: for every active run, the registered export URIs (the expected set) are checked against what is actually present in the bucket. See REGISTRY_PROVENANCE.md §8c.

Issue kinds:

  • missing_remote_output (error) — a registered active URI absent from the bucket (a replicate that never landed).
  • remote_count_mismatch (error) — fewer present files than the run’s registered output count.
  • orphan_remote_output (warning) — a bucket file in a tracked folder that belongs to a non-active run (or no registered run): the stale/superseded files the manual workaround filters by hand.

Parameters

Name Type Description Default
output_type str Export type (see :meth:get_output_uris). 'patch'
current_only bool Reserved for symmetry; the expected set is always the active runs. Non-active runs are used only to explain orphans. True
endpoint str | None S3 endpoint; falls back to MINIO_ENDPOINT. None
access_key str | None S3 access key; falls back to MINIO_ACCESS_KEY. None
secret_key str | None S3 secret key; falls back to MINIO_SECRET_KEY. None
use_ssl bool | None Use HTTPS (see :func:configure_s3). None

Returns

Name Type Description
list[ConsistencyIssue] A list of :class:ConsistencyIssue, most-actionable first (errors
list[ConsistencyIssue] before warnings).

check_sparsity

registry.RunRegistry.check_sparsity()

Check for sparse columns in cell_data.

Sparse columns (>50% NULL by default) often indicate that different simulation types are being mixed in the same registry, which hurts query performance.

Returns

Name Type Description
SparsityReport SparsityReport with statistics for each variable column.

Examples

>>> report = registry.check_sparsity()
>>> if report.should_warn:
...     print(report)

close

registry.RunRegistry.close()

Close the database connection.

compare_configs

registry.RunRegistry.compare_configs(
    label_or_hash_1,
    label_or_hash_2,
    ide='vscode',
)

Export two run configs and open a side-by-side diff in an IDE.

Convenience wrapper around :func:joshpy.diff.open_diff.

Parameters

Name Type Description Default
label_or_hash_1 str Label or run_hash of the first run. required
label_or_hash_2 str Label or run_hash of the second run. required
ide str IDE to open diff in (default: "vscode"). Supported: "vscode", "cursor". 'vscode'

Returns

Name Type Description
tuple[Path, Path] Tuple of Paths to the exported config files.

Raises

Name Type Description
KeyError If a label or hash is not found.
RuntimeError If the IDE CLI is not found in PATH.

compare_josh

registry.RunRegistry.compare_josh(
    label_or_hash_1,
    label_or_hash_2,
    ide='vscode',
)

Export two runs’ josh sources and open a side-by-side diff in an IDE.

Convenience wrapper around :func:joshpy.inspect.open_josh_diff.

Parameters

Name Type Description Default
label_or_hash_1 str Label or run_hash of the first run. required
label_or_hash_2 str Label or run_hash of the second run. required
ide str IDE to open diff in (default: "vscode"). Supported: "vscode", "cursor". 'vscode'

Returns

Name Type Description
tuple[Path, Path] Tuple of Paths to the exported josh files.

Raises

Name Type Description
KeyError If a label or hash is not found, or josh content is not stored.
RuntimeError If the IDE CLI is not found in PATH.

complete_run

registry.RunRegistry.complete_run(run_id, exit_code, error_message=None)

Record the completion of a job run.

Parameters

Name Type Description Default
run_id str The run ID to update. required
exit_code int Process exit code (0 = success). required
error_message str | None Error message if run failed. None

create_session

registry.RunRegistry.create_session(
    config,
    experiment_name=None,
    session_id=None,
)

Create a new sweep session.

Parameters

Name Type Description Default
config Any Job configuration containing simulation, template, and sweep info. Must have simulation, template_path, and to_dict() attributes (typically a JobConfig from joshpy.jobs). required
experiment_name str | None Name for the experiment. Defaults to config.simulation. None
session_id str | None Optional externally-provided session ID. If None, generates a UUID. This allows the frontend/API layer to manage session IDs (e.g., using project IDs). None

Returns

Name Type Description
str The session ID (generated or provided).

Examples

>>> from joshpy.jobs import JobConfig, SweepConfig, ConfigSweepParameter
>>> config = JobConfig(
...     template_path=Path("template.jshc.j2"),
...     source_path=Path("simulation.josh"),
...     simulation="Main",
...     sweep=SweepConfig(
...         config_parameters=[ConfigSweepParameter(name="maxGrowth", values=[10, 20, 30])]
...     ),
... )
>>> session_id = registry.create_session(config=config)

Note

total_jobs and total_replicates are computed from the JobSet after job expansion. Use job_set.total_jobs and job_set.total_replicates.

delete_design

registry.RunRegistry.delete_design(name)

Delete a registered design and its requirements.

Returns

Name Type Description
bool True if a design was deleted, False if none existed.

describe_labels

registry.RunRegistry.describe_labels()

Human-readable listing of all labeled runs.

Convenience wrapper around :func:joshpy.inspect.format_labels.

Returns

Name Type Description
str A formatted table of labels with run_hash and creation time.

describe_run

registry.RunRegistry.describe_run(label_or_hash)

Human-readable detail for a single run.

Convenience wrapper around :func:joshpy.inspect.format_run_info.

Parameters

Name Type Description Default
label_or_hash str Label or run_hash of the run to describe. required

Returns

Name Type Description
str A multi-section detail string (parameters, data files, replicates,
str and per-run results).

Raises

Name Type Description
KeyError If the label or hash is not found.

describe_sessions

registry.RunRegistry.describe_sessions()

Human-readable listing of all sweep sessions.

Convenience wrapper around :func:joshpy.inspect.format_sessions.

Returns

Name Type Description
str A formatted table of sessions with experiment name, status, and
str run counts.

describe_summary

registry.RunRegistry.describe_summary()

Human-readable overview of everything in the registry.

Convenience wrapper around :func:joshpy.inspect.format_summary.

Returns

Name Type Description
str A high-level data summary for the whole registry.

drop_run

registry.RunRegistry.drop_run(label_or_hash)

Delete all registry state for a run, so its config can be redone.

This is the only operation that deletes or replaces existing run data. All other registry writes are append-only (runs, cell_data) or metadata (labels, session status). Use this to clear a run before re-running it from scratch — e.g. when a sweep’s outputs are bad and you want a clean slate rather than pooling more replicates onto them.

Removes, in foreign-key order, everything tied to the run’s hash: cell_data, run_outputs, job_runs, config_parameters, session_configs, and the job_configs row (including its label). The owning session row is left intact (it may hold other runs).

Parameters

Name Type Description Default
label_or_hash str Label or run_hash of the run to drop. required

Returns

Name Type Description
A DropSummary class:DropSummary with per-table deleted-row counts.

Raises

Name Type Description
KeyError If the label or hash is not found.

export_config

registry.RunRegistry.export_config(label_or_hash, output_dir)

Export a run’s config content to a file for IDE diffing.

Resolves by label first, falls back to run_hash.

Parameters

Name Type Description Default
label_or_hash str Label or run_hash to look up. required
output_dir str | Path Directory to write the config file to. required

Returns

Name Type Description
Path Path to the written file.

Raises

Name Type Description
KeyError If no matching run is found.

export_josh

registry.RunRegistry.export_josh(label_or_hash, output_dir)

Export a run’s josh source content to a file for IDE viewing/diffing.

Resolves by label first, falls back to run_hash.

Parameters

Name Type Description Default
label_or_hash str Label or run_hash to look up. required
output_dir str | Path Directory to write the josh file to. required

Returns

Name Type Description
Path Path to the written file.

Raises

Name Type Description
KeyError If no matching run is found or josh content is not stored.

export_results_df

registry.RunRegistry.export_results_df(session_id)

Export session results as a pandas DataFrame.

Parameters

Name Type Description Default
session_id str The session to export. required

Returns

Name Type Description
Any pandas DataFrame with run results and parameters.

Raises

Name Type Description
ImportError If pandas is not installed.

find_by_attribute

registry.RunRegistry.find_by_attribute(key, value, *, current_only=True)

Find run_hashes carrying attribute key == value.

The run-level, currency-aware counterpart of :meth:find_tagged. “Current” is exactly status = 'active' (NULL read as active); superseded and bad runs are excluded by default. See REGISTRY_PROVENANCE.md.

Parameters

Name Type Description Default
key str The attribute key to match on (e.g. "site"). required
value Any The value to match (compared as text). required
current_only bool When True (default), only active runs are returned. Pass False to include superseded/bad runs. True

Returns

Name Type Description
list[str] List of matching run_hashes, in no particular order.

Examples

>>> registry.set_attributes("hash1", site="JOTR001")
>>> registry.set_attributes("hash2", site="JOTR001")
>>> registry.find_by_attribute("site", "JOTR001")
['hash1', 'hash2']

find_current_by_attribute

registry.RunRegistry.find_current_by_attribute(key, value)

Find current runs by attribute, resolved with label and attributes.

Like :meth:find_by_attribute (active only), but returns fully resolved :class:AttributeMatch rows – (run_hash, label, attributes) – so callers never re-implement the label/attribute cross-reference. See REGISTRY_PROVENANCE.md §7.

Parameters

Name Type Description Default
key str The attribute key to match on (e.g. "site"). required
value Any The value to match (compared as text). required

Returns

Name Type Description
list[AttributeMatch] List of :class:AttributeMatch, in no particular order.

find_tagged

registry.RunRegistry.find_tagged(tag_key, value, *, scope='run_hash')

Find every key in scope whose tags[tag_key] == value.

The reverse of get_tags_by_* / get_custom_tags: given a tag value (e.g. a site code), recover every key (e.g. run_hash) that carries it – the many-to-one direction, since several keys can share the same tag value.

Parameters

Name Type Description Default
tag_key str The tag key to match on (e.g. "site"). required
value Any The value to match (compared as text). required
scope str Scope to search. Defaults to "run_hash". 'run_hash'

Returns

Name Type Description
list[str] List of matching keys (e.g. run_hashes), in no particular order.

Note

This is the general, scope-parameterized primitive and does not filter by run status. For the run-level attributes slice, prefer :meth:find_by_attribute, which defaults to current (active) runs only.

Examples

>>> registry.tag_custom("JOTR001", scope="site", biome="desert")
>>> registry.tag_custom("JOTR002", scope="site", biome="desert")
>>> registry.find_tagged("biome", "desert", scope="site")
['JOTR001', 'JOTR002']

get_attributes

registry.RunRegistry.get_attributes(run_hash)

Get the analysis attributes attached to a run_hash, or {} if none.

get_config_by_hash

registry.RunRegistry.get_config_by_hash(run_hash)

Get config information by run hash.

Parameters

Name Type Description Default
run_hash str The run hash to look up. required

Returns

Name Type Description
ConfigInfo | None ConfigInfo if found, None otherwise.

get_configs_for_session

registry.RunRegistry.get_configs_for_session(session_id)

Get all configs for a session.

Parameters

Name Type Description Default
session_id str The session ID to get configs for. required

Returns

Name Type Description
list[ConfigInfo] List of ConfigInfo objects.

get_custom_tags

registry.RunRegistry.get_custom_tags(key, *, scope)

Get the tags attached to key under a synthetic scope.

get_data_summary

registry.RunRegistry.get_data_summary(session_id=None)

Get summary of all data in registry.

Provides counts, available variables, parameters, and data ranges for diagnostic purposes.

Parameters

Name Type Description Default
session_id str | None Optional session ID to filter by. None

Returns

Name Type Description
DataSummary DataSummary with counts and metadata.

get_debug_output_files

registry.RunRegistry.get_debug_output_files(
    label_or_hash,
    *,
    run_id=None,
    entity_types=None,
    existing_only=True,
)

Get debug output file paths for a labeled/hashed run.

Parameters

Name Type Description Default
label_or_hash str Run label or run_hash. required
run_id str | None Optional explicit run execution ID. If omitted, uses the latest execution for the run hash. None
entity_types list[str] | None Optional debug entity types to include (e.g., [“organism”, “patch”]). If omitted, includes all. None
existing_only bool If True, return only paths that exist on disk. True

Returns

Name Type Description
list[Path] List of debug file paths for the selected run execution.

Raises

Name Type Description
KeyError If the run or run execution is not found.
ValueError If the explicit run_id does not belong to the run hash.

get_design

registry.RunRegistry.get_design(name)

Load a registered :class:TargetDesign, or None if absent.

get_file_mappings

registry.RunRegistry.get_file_mappings(label_or_hash)

Get the external data file mappings for a run.

Parameters

Name Type Description Default
label_or_hash str Run label or run_hash. required

Returns

Name Type Description
dict[str, Path] | None Dict mapping data names to file paths, or None if no
dict[str, Path] | None file mappings were registered for this run.

Raises

Name Type Description
KeyError If the label or hash is not found.

get_output_uris

registry.RunRegistry.get_output_uris(
    label_or_hash=None,
    *,
    output_type='patch',
    current_only=True,
)

Resolve registered export URIs for runs, jar-free from run_outputs.

The registry records the resolved export URI of every registry-attached run (on any load_results setting), so it is the current-URI index — no filename regex, no hand-maintained label→hash dict. See REGISTRY_PROVENANCE.md §8a.

Parameters

Name Type Description Default
label_or_hash str | None Restrict to one run (by label or hash). None (the default) returns outputs across all matching runs. None
output_type str Export type. A bare name ("patch") maps to the stored export.<name>; pass a dotted name ("debug.organism") to target that namespace directly. 'patch'
current_only bool When True (default), only active runs are included. True

Returns

Name Type Description
list[OutputURI] A list of :class:OutputURI, ordered by run_hash then URI.

get_replicate_count

registry.RunRegistry.get_replicate_count(run_hash)

Get the number of distinct replicates for a run hash from cell_data.

This is the source-of-truth count, derived from actual loaded data rather than from job_runs metadata. Returns 0 if no data has been loaded yet.

The replicate index is the identity of a replicate: counting distinct replicate values gives the number of replicates loaded for this run, regardless of which execution (run_id) produced each one. Pooled runs dispatch fresh, non-colliding indices, so distinct replicate == total replicates; re-ingesting an already-loaded index is a no-op (see :meth:loaded_replicates).

Parameters

Name Type Description Default
run_hash str The run hash to count replicates for. required

Returns

Name Type Description
int Number of distinct replicates in cell_data.

get_run

registry.RunRegistry.get_run(run_id)

Get run information by ID.

Parameters

Name Type Description Default
run_id str The run ID to look up. required

Returns

Name Type Description
RunInfo | None RunInfo if found, None otherwise.

get_run_info

registry.RunRegistry.get_run_info(label_or_hash)

Get aggregated structured detail for a single run.

Combines :meth:get_config_by_hash, :meth:get_runs_for_hash, and :meth:get_replicate_count into one :class:RunDetail. This is the structured, data-layer counterpart to :meth:describe_run, which formats this same information as a human-readable string.

Parameters

Name Type Description Default
label_or_hash str Label or run_hash of the run. required

Returns

Name Type Description
A RunDetail class:RunDetail aggregating the config, recorded runs, and
RunDetail replicate count.

Raises

Name Type Description
KeyError If the label or hash is not found.

Examples

>>> detail = registry.get_run_info("baseline")
>>> detail.parameters
{'survivalProbAdult': 85}
>>> detail.succeeded, detail.failed, detail.pending
(3, 0, 0)

get_run_status

registry.RunRegistry.get_run_status(label_or_hash)

Get a run’s lifecycle status.

Parameters

Name Type Description Default
label_or_hash str Label or run_hash of the run. required

Returns

Name Type Description
A RunStatus class:RunStatus. Unmarked runs report status=None, which
RunStatus attr:RunStatus.effective_status normalizes to "active".

Raises

Name Type Description
KeyError If the label or hash is not found.

get_runs_by_parameters

registry.RunRegistry.get_runs_by_parameters(**params)

Query runs by parameter values.

Parameters

Name Type Description Default
**params Any Parameter name-value pairs to filter by. {}

Returns

Name Type Description
list[dict[str, Any]] List of dicts containing run info and parameters.

get_runs_for_hash

registry.RunRegistry.get_runs_for_hash(run_hash)

Get all runs for a run hash.

Parameters

Name Type Description Default
run_hash str The run hash to get runs for. required

Returns

Name Type Description
list[RunInfo] List of RunInfo objects.

get_session

registry.RunRegistry.get_session(session_id)

Get session information by ID.

Parameters

Name Type Description Default
session_id str The session ID to look up. required

Returns

Name Type Description
SessionInfo | None SessionInfo if found, None otherwise.

get_session_summary

registry.RunRegistry.get_session_summary(session_id)

Get aggregated statistics for a session.

Parameters

Name Type Description Default
session_id str The session ID to summarize. required

Returns

Name Type Description
SessionSummary | None SessionSummary with counts, or None if session not found.

get_tags_by_run_id

registry.RunRegistry.get_tags_by_run_id(run_id)

Get the tags attached to a run_id, or {} if none.

get_tags_by_session_id

registry.RunRegistry.get_tags_by_session_id(session_id)

Get the tags attached to a session_id, or {} if none.

label_run

registry.RunRegistry.label_run(
    run_hash,
    label,
    force=False,
    on_collision=None,
    reason=None,
)

Assign a human-readable label to a run configuration.

A label is a pure alias — the one handle you resolve to a run. It is not where currency or run attributes live: currency is :meth:mark_run/status and attributes are tags (see REGISTRY_PROVENANCE.md). Labels are unique within a registry; on collision the behavior depends on force and on_collision:

  • Default: raise ValueError.
  • force=True: silently drop the old label and reassign, leaving the old run’s status untouched. For “I mislabeled it, just fix it.”
  • on_collision="supersede": the old run releases the label (label = NULL) and is marked status = 'superseded' with superseded_by = run_hash and the given reason; the new run takes the label. This records real provenance instead of mangling the old label with a timestamp suffix (the retired "timestamp" mode).

Parameters

Name Type Description Default
run_hash str The run hash to label. required
label str Human-readable label (e.g., “baseline”, “high_mortality”). required
force bool If True, reassign the label even if already taken. False
on_collision str | None Collision strategy. "supersede" archives the old run via supersession. Mutually exclusive with force. None
reason str | None Free-text explanation stored on the superseded run. Only meaningful with on_collision="supersede". None

Raises

Name Type Description
KeyError If run_hash does not exist.
ValueError If label is already assigned to a different run and neither force nor on_collision is set, or if both force and on_collision are set, or if on_collision has an invalid value.

list_attribute_keys

registry.RunRegistry.list_attribute_keys()

List all distinct run-level attribute keys in use.

The run-level (run_hash scope) counterpart of :meth:list_tag_keys.

Returns

Name Type Description
list[str] Sorted list of attribute keys (e.g. ["biome", "site"]).

list_config_columns

registry.RunRegistry.list_config_columns()

List all parameter column names in config_parameters.

Returns the dynamically-added parameter columns. Column names preserve original names with special characters (e.g., ‘soil.moisture’).

Returns

Name Type Description
list[str] Sorted list of parameter column names.

Examples

>>> registry.list_config_columns()
['maxGrowth', 'scenario', 'soil.moisture']

list_config_parameters

registry.RunRegistry.list_config_parameters(session_id=None)

List all config parameter names from sweep configurations.

These are the parameters you defined in your JobConfig sweep, stored as typed columns in the config_parameters table.

Parameters

Name Type Description Default
session_id str | None Optional session ID to filter by. None

Returns

Name Type Description
list[str] Sorted list of parameter names.

Examples

>>> registry.list_config_parameters()
['maxGrowth', 'scenario', 'survivalProb']

list_designs

registry.RunRegistry.list_designs()

List the names of all registered target designs, sorted.

list_entity_types

registry.RunRegistry.list_entity_types(session_id=None)

List all entity types found in cell_data.

Parameters

Name Type Description Default
session_id str | None Optional session ID to filter by. None

Returns

Name Type Description
list[str] Sorted list of entity type names.

list_export_variables

registry.RunRegistry.list_export_variables(session_id=None)

List all export variable names from simulation outputs.

These are the variables exported by Josh simulations, stored as typed columns in the cell_data table. Variable names preserve original .josh names (e.g., ‘avg.height’).

When session_id is provided, only returns variables that have at least one non-NULL value for runs in that session.

Parameters

Name Type Description Default
session_id str | None Optional session ID to filter by. If provided, only returns variables with data in that session. None

Returns

Name Type Description
list[str] Sorted list of variable column names.

Examples

>>> registry.list_export_variables()
['averageAge', 'avg.height', 'treeCount']
>>> registry.list_export_variables(session_id="abc123")
['treeCount']  # Only variables with data in this session

list_labels

registry.RunRegistry.list_labels()

List all labeled runs.

Returns

Name Type Description
list[tuple[str, str]] List of (label, run_hash) tuples, sorted by label.

list_parameters

registry.RunRegistry.list_parameters(session_id=None)

Alias for list_config_parameters(). Deprecated, use list_config_parameters().

list_sessions

registry.RunRegistry.list_sessions(experiment_name=None, limit=100)

List sessions, optionally filtered by experiment name.

Parameters

Name Type Description Default
experiment_name str | None Filter by experiment name (optional). None
limit int Maximum number of sessions to return. 100

Returns

Name Type Description
list[SessionInfo] List of SessionInfo objects, ordered by creation time (newest first).

list_tag_keys

registry.RunRegistry.list_tag_keys(scope)

List all distinct tag keys in use for a scope.

Parameters

Name Type Description Default
scope str Scope to inspect (e.g. "run_hash", or a custom scope like "site"). required

Returns

Name Type Description
list[str] Sorted list of tag keys (e.g. ["biome", "site"]).

list_variable_columns

registry.RunRegistry.list_variable_columns()

List all variable column names in cell_data.

Returns the dynamically-added variable columns. Column names preserve original names with special characters (e.g., ‘avg.height’).

Returns

Name Type Description
list[str] Sorted list of variable column names.

Examples

>>> registry.list_variable_columns()
['averageAge', 'avg.height', 'treeCount']

list_variables

registry.RunRegistry.list_variables(session_id=None)

Alias for list_export_variables(). Deprecated, use list_export_variables().

load_debug

registry.RunRegistry.load_debug(
    label_or_hash,
    *,
    run_id=None,
    entity_types=None,
    existing_only=True,
)

Load debug messages for a run from registered debug output files.

Parameters

Name Type Description Default
label_or_hash str Run label or run_hash. required
run_id str | None Optional explicit run execution ID. If omitted, uses latest. None
entity_types list[str] | None Optional debug entity types to include. None
existing_only bool If True, only load files that currently exist. True

Returns

Name Type Description
Any DebugMessageStore with messages merged across all selected files.

Raises

Name Type Description
KeyError If run/run execution is not found.
ValueError If no matching debug files are available.
FileNotFoundError If existing_only=False and any file is missing.

loaded_replicates

registry.RunRegistry.loaded_replicates(run_hash)

Return the set of replicate indices already loaded for a run hash.

The single source of truth for “what’s already ingested”. Ingestion skips any replicate index already in this set (idempotent re-ingest); the replicate index is the dedup identity.

Parameters

Name Type Description Default
run_hash str The run hash to inspect. required

Returns

Name Type Description
set[int] Set of distinct replicate indices present in cell_data.

mark_run

registry.RunRegistry.mark_run(
    run_hash,
    status,
    *,
    superseded_by=None,
    reason=None,
)

Set a run’s lifecycle status.

status is a closed enum — "active", "superseded", or "bad" — and is the single source of truth for whether a run should be used. “Current” is exactly status == "active" (see REGISTRY_PROVENANCE.md); there is no separate currency flag.

Parameters

Name Type Description Default
run_hash str The run to mark. Also accepts a label (resolved first). required
status str One of {"active", "superseded", "bad"}. required
superseded_by str | None The run_hash that replaces this one. Required when status == "superseded" and rejected otherwise. The target must exist. None
reason str | None Free-text explanation, stored alongside the status. None

Raises

Name Type Description
KeyError If run_hash (or superseded_by) does not exist.
ValueError If status is not in the enum, if superseded_by is given without status="superseded" (or vice versa), or if a run is superseded by itself.

pull_from_s3

registry.RunRegistry.pull_from_s3(
    bucket,
    prefix=None,
    mode='restore',
    endpoint=None,
    access_key=None,
    secret_key=None,
    use_ssl=None,
    tables=None,
)

Pull a registry’s Parquet export from S3 back into this registry.

Parameters

Name Type Description Default
bucket str S3/MinIO bucket the registry was published to. required
prefix str | None S3 key prefix. Defaults to run-registries/<name>, matching :meth:push_to_s3’s default. Required if this registry is ":memory:". None
mode str "restore" (default) or "merge": - "restore": this registry’s tables are emptied and replaced with exactly what’s at prefix. Use this to rehydrate a local registry from its own prior push_to_s3 export – e.g. on a new machine, or after deleting the local file. The table schemas (constraints, the cell_id sequence) are preserved; only the rows change. - "merge": adds rows from prefix that this registry doesn’t already have (by primary key, or for cell_data by (run_hash, replicate) since cell_id is a local surrogate with no meaning across registries); existing local rows are never touched. Only use this to bring in more runs of the same experiment (e.g. a teammate’s machine or a batch worker publishing to the same prefix) – not to combine genuinely different experiments into one registry. Per the one-registry-per-experiment guidance, merging unrelated experiments risks the same hash-collision ambiguity a reused registry already warns about. To analyze multiple experiments together without merging their data, use :func:open_s3_registries instead. 'restore'
endpoint str | None S3 endpoint. Falls back to MINIO_ENDPOINT env var. None
access_key str | None S3 access key. Falls back to MINIO_ACCESS_KEY. None
secret_key str | None S3 secret key. Falls back to MINIO_SECRET_KEY. None
use_ssl bool | None Use HTTPS. See :func:configure_s3. None
tables tuple[str, …] | None Tables to pull. Defaults to all of :data:REGISTRY_SYNC_TABLES. None

Returns

Name Type Description
dict[str, int] Dict mapping table name -> number of rows loaded from S3 (for
dict[str, int] "merge", only the newly-inserted rows; for "restore",
dict[str, int] the full row count now in the table).

Raises

Name Type Description
ValueError If mode is not "restore" or "merge".

push_to_s3

registry.RunRegistry.push_to_s3(
    bucket,
    prefix=None,
    endpoint=None,
    access_key=None,
    secret_key=None,
    use_ssl=None,
    tables=None,
)

Publish this registry’s tables to S3 as Parquet, one file per table.

Overwrites whatever is currently at the destination prefix with this registry’s current state. This publishes this registry only – it does not read or touch any other registry. Pair with :meth:pull_from_s3 (same registry, restoring or adding replicates) or :func:open_s3_registries (querying several published registries together, read-only, without merging them).

Parameters

Name Type Description Default
bucket str S3/MinIO bucket to publish under. required
prefix str | None S3 key prefix. Defaults to run-registries/<name> where <name> is this registry’s own filename stem – matching the “one registry file per experiment, named after it” convention already used locally. Required if this registry is ":memory:". None
endpoint str | None S3 endpoint. Falls back to MINIO_ENDPOINT env var. None
access_key str | None S3 access key. Falls back to MINIO_ACCESS_KEY. None
secret_key str | None S3 secret key. Falls back to MINIO_SECRET_KEY. None
use_ssl bool | None Use HTTPS. See :func:configure_s3. None
tables tuple[str, …] | None Tables to publish. Defaults to all of :data:REGISTRY_SYNC_TABLES. None

Returns

Name Type Description
str The s3://bucket/prefix/ URI published to.

Examples

>>> registry.push_to_s3(bucket="josh-batch-storage")
's3://josh-batch-storage/run-registries/jotr_sensitivity/'

query

registry.RunRegistry.query(sql, params=None)

Execute a SQL query with parameters.

This provides direct access to DuckDB for custom queries beyond the pre-built methods. Use this when you need to run complex queries or explore the data in ways not covered by the API.

Parameters

Name Type Description Default
sql str SQL query with ? placeholders for parameters. required
params list | None List of parameter values. None

Returns

Name Type Description
Any DuckDB relation (call .df() for DataFrame, .fetchall() for tuples).

Examples

>>> # Get DataFrame
>>> df = registry.query(
...     "SELECT * FROM cell_data WHERE step BETWEEN ? AND ?",
...     [0, 10]
... ).df()
>>> # Get raw results
>>> rows = registry.query(
...     "SELECT COUNT(*) FROM cell_data WHERE run_hash = ?",
...     ["abc123"]
... ).fetchone()

query_remote

registry.RunRegistry.query_remote(
    variable,
    *,
    agg='mean',
    group_by=('label', 'step', 'replicate'),
    output_type='patch',
    current_only=True,
    label_or_hash=None,
    where=None,
    cache=None,
    endpoint=None,
    access_key=None,
    secret_key=None,
    use_ssl=None,
)

Aggregate a variable directly against bucket-resident CSVs, no ingest.

Builds a URI manifest of the current runs (:meth:get_output_uris), scans exactly those CSVs once with DuckDB, and attaches provenance by joining on the (registry-supplied) filename — never by parsing the path. Nothing touches cell_data; this is the read path for the load_results=False batch (REGISTRY_PROVENANCE.md §8b).

Parameters

Name Type Description Default
variable str CSV column to aggregate (e.g. "treeCount"). required
agg str One of mean/avg/sum/min/max/count/median/stddev. 'mean'
group_by Sequence[str] Columns to group by. label/run_hash come from the registry; any other name is a CSV column (step, replicate, position, …). ('label', 'step', 'replicate')
output_type str Export type (see :meth:get_output_uris). 'patch'
current_only bool Aggregate active runs only (default). Archived URIs are simply absent from the manifest, so stale files in the same folder are excluded for free. True
label_or_hash str | None Restrict to one run. None
where str | None Optional raw SQL predicate on the CSV columns (a passthrough, like :meth:query). None
cache str | Path | None Optional path to also write the result to (.parquet or .csv by extension). None
endpoint str | None S3 endpoint; falls back to MINIO_ENDPOINT. None
access_key str | None S3 access key; falls back to MINIO_ACCESS_KEY. None
secret_key str | None S3 secret key; falls back to MINIO_SECRET_KEY. None
use_ssl bool | None Use HTTPS (see :func:configure_s3). None

Returns

Name Type Description
Any A pandas DataFrame: the group_by columns, value (the
Any aggregate), and n_rows.

Raises

Name Type Description
ValueError If agg is unknown or no output URIs are found.

register_design

registry.RunRegistry.register_design(design)

Persist (or replace) a :class:TargetDesign by name.

Idempotent on design.name: re-registering replaces the stored requirements wholesale. See REGISTRY_PROVENANCE.md §12.

Parameters

Name Type Description Default
design TargetDesign The design to store. required

Raises

Name Type Description
ValueError If the design has no name, no requirements, a requirement with no attributes, or a min_active < 1.

register_output

registry.RunRegistry.register_output(
    run_id,
    output_type,
    file_path,
    file_size=None,
    row_count=None,
)

Register an output file from a run.

Parameters

Name Type Description Default
run_id str The run this output belongs to. required
output_type str Type of output (e.g., ‘csv’, ‘log’, ‘error’). required
file_path str Path to the output file. required
file_size int | None Size of the file in bytes. None
row_count int | None Number of rows (for tabular data). None

Returns

Name Type Description
str The generated output ID.

register_run

registry.RunRegistry.register_run(
    session_id,
    run_hash,
    josh_path,
    config_content,
    file_mappings,
    parameters,
    josh_content=None,
)

Register a job configuration (run specification).

Parameters

Name Type Description Default
session_id str Session this config belongs to. required
run_hash str MD5 hash of josh + config + file_mappings (12 chars). required
josh_path str Path to the .josh script file. required
config_content str Full text of the rendered configuration. required
file_mappings dict[str, dict[str, str]] | None Dict mapping names to {“path”: “…”, “hash”: “…”}. required
parameters dict[str, Any] Parameter values used to generate this config. required
josh_content str | None Rendered .josh source content (optional). None

reset_run

registry.RunRegistry.reset_run(label_or_hash)

Clear a run’s executions/results and reactivate it, keeping its config.

The in-place redo primitive behind the bad -> re-dispatch rule (REGISTRY_PROVENANCE.md §11.1). Deletes the run’s cell_data, run_outputs and job_runs — so a re-dispatch replaces rather than appends — and resets status to active (clearing any bad / superseded marks).

Unlike :meth:drop_run, the job_configs row (and config_parameters / session_configs) is kept. A re-dispatch of the identical config produces the same run_hash and reuses it; keeping the row also preserves referential integrity when a sweep has already registered the config up front, so the fresh executions can attach to it.

Parameters

Name Type Description Default
label_or_hash str Label or run_hash of the run to reset. required

Raises

Name Type Description
KeyError If the label or hash is not found.

resolve_config_source

registry.RunRegistry.resolve_config_source(run_hash)

Locate the original .jshc file on disk and check if it still matches.

Looks up the session metadata to find the original config_path, then checks whether the file exists and whether its content has changed since it was registered.

Parameters

Name Type Description Default
run_hash str The run hash to look up. required

Returns

Name Type Description
A ConfigSourceInfo class:ConfigSourceInfo describing the file’s status.

resolve_josh_source

registry.RunRegistry.resolve_josh_source(run_hash)

Locate the original .josh file on disk and check if it still matches.

Compares the file at josh_path against the stored josh_content.

Parameters

Name Type Description Default
run_hash str The run hash to look up. required

Returns

Name Type Description
A ConfigSourceInfo class:ConfigSourceInfo describing the file’s status.

resolve_label

registry.RunRegistry.resolve_label(label)

Get the run_hash for a labeled run.

Parameters

Name Type Description Default
label str The label to look up. required

Returns

Name Type Description
str The run_hash associated with the label.

Raises

Name Type Description
KeyError If no run has this label.

run_history

registry.RunRegistry.run_history(label_or_hash)

Walk the supersession chain for a run, newest (current) first.

Replaces the retired resolve_latest() prefix-matching. Starting from the given run, follows superseded_by backwards to reconstruct the lineage. Because supersession points from old → new, the chain is recovered by finding, at each step, the run that the previous entry supersedes.

Parameters

Name Type Description Default
label_or_hash str Label or run_hash of any run in the lineage. Typically the current (active) run. required

Returns

Name Type Description
list[RunDetail] A list of :class:RunDetail, current run first, then each run it
list[RunDetail] superseded, oldest last. Length 1 when nothing was superseded.

Raises

Name Type Description
KeyError If the label or hash is not found.

set_attributes

registry.RunRegistry.set_attributes(run_hash, **attributes)

Attach analysis attributes (factors, join keys) to a run_hash.

Attributes are the sanctioned home for what a run is about – the factors carried into analysis (site, treatment, scenario) and the join keys linking registry runs to Josh’s CSV output. They are the run-level slice of the registry’s tag store, keyed on the validated run_hash scope; the general :meth:tag_by_session_id / :meth:tag_by_run_id / :meth:tag_custom facility remains for non-run metadata. See REGISTRY_PROVENANCE.md.

Joins job_configs.run_hash / config_parameters.run_hash / job_runs.run_hash / cell_data.run_hash – all the same value. DiagnosticQueries.get_parameter_comparison(variable, param_name) picks these up automatically for any param_name that isn’t a declared sweep parameter.

Calling this again for the same run_hash merges into the existing attributes (like dict.update) rather than replacing them.

Parameters

Name Type Description Default
run_hash str The run to attribute. required
**attributes Any Attribute values to set, in whatever shape you like. {}

Raises

Name Type Description
KeyError If run_hash isn’t a registered run.
ValueError If no attributes are given.

Examples

>>> registry.set_attributes(run_hash, site="JOTR001", biome="desert")

spatial_filter

registry.RunRegistry.spatial_filter(bbox=None, geojson=None)

Context manager for spatial filtering of queries.

All DiagnosticQueries within this context will be spatially filtered. Can be nested with time_filter().

Parameters

Name Type Description Default
bbox tuple[float, float, float, float] | None Bounding box as (min_lon, max_lon, min_lat, max_lat). None
geojson str | dict | None GeoJSON polygon string or dict. None

Raises

Name Type Description
ValueError If both bbox and geojson are provided.

Examples

>>> with registry.spatial_filter(bbox=(-116, -115, 33.5, 34.0)):
...     df = queries.get_timeseries("height", run_hash="abc123")
>>> # Nested with time filter
>>> with registry.spatial_filter(geojson=park_boundary):
...     with registry.time_filter(step_range=(0, 50)):
...         df = queries.get_timeseries("height", run_hash="abc123")

start_run

registry.RunRegistry.start_run(
    run_hash,
    *,
    session_id,
    replicate=0,
    output_path=None,
    metadata=None,
)

Record the start of a job run.

Parameters

Name Type Description Default
run_hash str Run hash for this run. required
session_id str Session that initiated this run. required
replicate int Replicate number (0-indexed). 0
output_path str | None Path where output will be written. None
metadata dict[str, Any] | None Additional metadata. None

Returns

Name Type Description
str The generated run ID.

supersede

registry.RunRegistry.supersede(run_hash, replaces, reason=None)

Mark run_hash as the replacement for an existing run.

Convenience wrapper over :meth:mark_run for the partial-rerun story: the replaced run becomes status='superseded' pointing at run_hash. If the replaced run held a label, that label is released so it no longer resolves to the stale run — attach it to the new run with :meth:label_run if desired.

Parameters

Name Type Description Default
run_hash str The new, replacing run. required
replaces str Label or run_hash of the run being retired. required
reason str | None Free-text explanation stored on the superseded run. None

Raises

Name Type Description
KeyError If either run is not found.
ValueError If a run would supersede itself.

tag_by_run_id

registry.RunRegistry.tag_by_run_id(run_id, **tags)

Attach free-form JSON metadata to a specific run execution.

Distinct from set_attributes (run-level): a run_hash is what was run and can have several run_ids (e.g. under the pool collision policy); a run_id is which execution produced a given replicate. Joins job_runs.run_id / cell_data.run_id / run_outputs.run_id (the latter via job_runs).

Parameters

Name Type Description Default
run_id str The run execution to tag. required
**tags Any Tag values to set, in whatever shape you like. {}

Raises

Name Type Description
KeyError If run_id isn’t a recorded execution.
ValueError If no tags are given.

tag_by_session_id

registry.RunRegistry.tag_by_session_id(session_id, **tags)

Attach free-form JSON metadata to a sweep session.

Joins sweep_sessions.session_id / job_runs.session_id / session_configs.session_id.

Parameters

Name Type Description Default
session_id str The session to tag. required
**tags Any Tag values to set, in whatever shape you like. {}

Raises

Name Type Description
KeyError If session_id isn’t a registered session.
ValueError If no tags are given.

tag_custom

registry.RunRegistry.tag_custom(key, *, scope, **tags)

Attach free-form JSON metadata under a synthetic scope.

For groupings that don’t correspond to any column in the schema – e.g. a site code shared by many run_hashes. Unlike set_attributes etc., there’s no existence check (nothing to check against) and no automatic join anywhere: recover matching keys with find_tagged(), then use them as a plain filter (e.g. run_hash IN (...)) against whatever table you’re actually querying.

Parameters

Name Type Description Default
key str The key to tag (e.g. "JOTR001"). required
scope str Name for this synthetic grouping (e.g. "site"). Must not be one of the validated scopes (run_hash, session_id, run_id) – use the matching tag_by_* method for those instead. required
**tags Any Tag values to set, in whatever shape you like. {}

Raises

Name Type Description
ValueError If scope is a validated scope, or no tags are given.

Examples

>>> registry.tag_custom("JOTR001", scope="site", n_plots=12)

time_filter

registry.RunRegistry.time_filter(step_range)

Context manager for temporal filtering of queries.

All DiagnosticQueries within this context will be filtered to the specified step range. Can be nested with spatial_filter().

Parameters

Name Type Description Default
step_range tuple[int, int] Tuple of (min_step, max_step) inclusive. required

Examples

>>> with registry.time_filter(step_range=(0, 50)):
...     df = queries.get_timeseries("height", run_hash="abc123")
>>> # Nested with spatial filter
>>> with registry.time_filter(step_range=(10, 20)):
...     with registry.spatial_filter(bbox=(-116, -115, 33.5, 34.0)):
...         df = queries.get_comparison("height", group_by="maxGrowth")

to_csv

registry.RunRegistry.to_csv(path, table='cell_data')

Export a table to CSV format.

Parameters

Name Type Description Default
path str | Path Output file path. required
table str Table name to export (default: cell_data). 'cell_data'

Examples

>>> registry.to_csv("results.csv")

In R:

>>> # df <- readr::read_csv("results.csv")

to_parquet

registry.RunRegistry.to_parquet(path, table='cell_data')

Export a table to Parquet format.

Parquet is recommended for R/Python analysis due to compression and type preservation.

Parameters

Name Type Description Default
path str | Path Output file path. required
table str Table name to export (default: cell_data). 'cell_data'

Examples

>>> registry.to_parquet("results.parquet")

In R:

>>> # df <- arrow::read_parquet("results.parquet")

In Python:

>>> import pandas as pd
>>> df = pd.read_parquet("results.parquet")

update_session_status

registry.RunRegistry.update_session_status(session_id, status)

Update the status of a session.

Parameters

Name Type Description Default
session_id str The session to update. required
status str New status (e.g., ‘running’, ‘completed’, ‘failed’). required