Skip to main content

crucible-ingestion

Python classes and framework for parsing metadata out of scientific data files and into the Crucible Data Platform.

Parsing and sending are separate. parse() reads a file and returns an IngestionPacket describing everything that would be sent; push_packet() takes that packet and writes it to Crucible. Nothing is uploaded during parsing, and the file bytes themselves are never sent -- only the parsed metadata.

Install

uv sync

Authentication

Run crucible config init once to store your API url and key. Everything in this package builds its client through get_client(), which picks up that config.

Running

A real run needs a --dsid. Create the dataset in Crucible first. You may want to include fields that you do not expect to be parsable, such as instrument name or project ID:

client.datasets.create(Dataset())

Then pass the id it returns:

uv run crucible-ingest --file {local_file_path} --dsid {dsid} [--ingestor {ingestion-class}] [--output-dir {output_dir}] [--push]
  • --dsid is the dataset the parsed information belongs to.
  • --ingestor names an ingestion class explicitly. Without it, a supported ingestor is auto-detected by find_supported_ingestor.
  • --output-dir defaults to ./dry_run_output/{dsid}.
  • --push sends the parsed packet to Crucible. Without it nothing is written to Crucible and the run is a dry run.

Running --push with neither a --dsid nor --test is an error.

The parsed packet is written to {output_dir}/packet.json and any thumbnails are decoded to {output_dir}/thumbnails/ so they can be inspected.

parse() reads from Crucible when a dataset record with the given dsid already exists, so that values a user set at dataset creation are not overwritten by parsed ones. If no such record exists, parsing starts from scratch.

Testing

Testing does not need a dsid. Without one an mfid is generated locally, and --test creates a persistent dataset under that id in the shared crucible-test project (not automatically cleaned up) for --push to write to, logging the id it picked:

uv run crucible-ingest --file {local_file_path} --push --test

Drop --push to parse only. The packet is written to {output_dir}/packet.json under the generated id and nothing touches Crucible:

uv run crucible-ingest --file {local_file_path}

Passing a --dsid is optional and useful when you want the run to go against a dataset that already exists -- to check that parse() reads the user provided fields back correctly, for instance. With a --dsid, --test creates nothing and the push goes to that dataset.

Using it from Python

This requires an dataset id. Use the mfid package.

from crucible_ingestion import parse, push_packet
from mfid import mfid

packet = parse(path_to_file, dsid=mfid()[0])
if packet is not None:
    # inspect packet.dataset_fields, packet.scientific_metadata,
    # packet.keywords, packet.samples, packet.children, packet.thumbnails
    push_packet(packet)

parse returns None when no ingestor supports the file.

Adding a new ingestor

Ingestor classes live in crucible_ingestion/ingestors/ and subclass CrucibleDatasetIngestor (ingestors/crucible_ingestor.py), which defines the parsing hooks setup_data() calls: get_scientific_metadata, get_dataset_metadata, get_acl_information, parse_batch, parse_samples, parse_children, and get_thumbnails.

A new class needs is_file_supported() and must be added to ingestor_list in crucible_ingestion/ingestors/registry.py. Order matters -- find_supported_ingestor returns the first class in the list that claims the file, so specific ingestors belong above general ones.

Parsing must not post to Crucible. All writes to Crucible should be part of the push_packet function. Anything that needs to be created or linked can be added to the packet during parsing, for example: self.samples, self.children, self.keywords, or self.thumbnails.

Once you are content with your new parser, add an example file to tests/data and generate its schema from the tests folder:

uv run python tests/make_schemas.py --file tests/data/{new_file}

This runs parse() and records the packet's key paths, types, and values as a JSON Schema in tests/schemas/, paired with the data file's hash in tests/schema_registry.json. The test suite checks later parses against it, so a field that stops being parsed shows up as a failure. Files already in the registry are skipped, so running it with no arguments picks up only what is new. Review the generated schema before committing -- it records what the code does today, bugs included.

Test data

The files the tests parse live in GCS, not in this repo. Pull them before running the tests:

gcloud storage rsync -r gs://crucible-ingestion-test-data tests/data

Push new or updated files back up:

gcloud storage rsync -r tests/data gs://crucible-ingestion-test-data

Both directions only transfer what is missing or changed, and neither deletes anything at the destination. Removing a file from the bucket has to be done explicitly.

Running in the cloud

The RabbitMQ consumer that runs this package in GCP lives in a separate repo, ingestion-cloud-consumer.

Metadata

Release files for crucible-ingestion 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crucible-ingestion 0.3.6
File Size Uploaded Provenance Actions
crucible_ingestion-0.3.6.tar.gz 372.6 kB With provenance Details for crucible_ingestion-0.3.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for crucible-ingestion 0.3.6
File Interpreter ABI Platform Actions
crucible_ingestion-0.3.6-py3-none-any.whl Python 3 none any Details for crucible_ingestion-0.3.6-py3-none-any.whl

Total release size: 469.9 kB

Release files / crucible_ingestion-0.3.6.tar.gz

Download URL crucible_ingestion-0.3.6.tar.gz
Size 372.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e3b85a2471ca08a13e65bd08ac35648bd42a8661e5951ccc14848894a3e4f078
BLAKE2b-256 checksum
How to use checksums
bfca5c79638fffd2b1c66801961a5c5c7c504fdbf62a7ecc43252a4b7eb51ac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / crucible_ingestion-0.3.6-py3-none-any.whl

Download URL crucible_ingestion-0.3.6-py3-none-any.whl
Size 97.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28bbd6832f4da33ad41ed3cf52f75a9c45e7efb75e2fe18e63ce5cc1d7f9d5b7
BLAKE2b-256 checksum
How to use checksums
af0f9f248f6b17c50d0c656e026ac35008fdc35e411522347cc8ca2c92f0a48c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for crucible-ingestion 0.3.6

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for crucible_ingestion-0.3.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page