Skip to main content

gen3-metadata-simulator

PyPI Python

Generate realistic, linked, schema-valid Gen3 metadata from a Gen3 data dictionary. Point it at a bundled Gen3 JSON schema and it produces one JSON file per node — every foreign key resolving to a real parent — then self-validates with gen3-validator before writing.

Its headline feature: a lightweight LLM fills each field with believable clinical values — numeric distributions with real-world limits, valid calendar dates, and domain-appropriate text — that still pass validation. So month_birth lands in [1, 12], dates are real, and an assay description reads like one.

Install

pip install gen3-metadata-simulator      # Python ≥ 3.9

Quickstart — realistic data with an LLM

The core feature. Three steps:

1. Configure the model + key. Put your API key in its own file and lock it down (works with OpenAI or Anthropic):

mkdir -p ~/.config/gen3-sim
printf 'sk-...' > ~/.config/gen3-sim/openai_key   # your key, in its own file
chmod 600 ~/.config/gen3-sim/openai_key           # readable only by you

Then create a .env in the directory you'll run from, pointing at that key file:

# .env  — works with OpenAI or Anthropic
LLM_PROVIDER=openai                            # or: anthropic
LLM_MODEL=gpt-4o-mini                          # or e.g. claude-haiku-4-5
LLM_API_KEY_FILE=/absolute/path/to/openai_key

.env holds only the path, never the key — keep it untracked (add it to your .gitignore). This keeps the secret out of your shell history, out of every child process's environment, and out of anything you commit; see docs/usage.md for the full rationale and resolution rules. (Working in a clone of this repo? cp .env.example .env for a ready template.)

2. Generate (provider + model come from .env):

gen3-metadata-simulator generate --schema your-gen3-schema.json --provider llm --num-records 30

Cloned this repo to try it out? Use the bundled schema examples/jsonschema/acdc_schema_v1.1.5.json.

3. You get a self-validated ./output/ — realistic numbers within real limits, valid dates, sensible text. Field estimates are cached (.cache/distributions.json), so reruns make no API calls and --seed is reproducible.

In CI or a quick one-off? Skip the file and let the SDK read the vendor's standard env var instead — ephemeral and the native choice for CI/containers:

export OPENAI_API_KEY=sk-...   # injected as a secret in CI; avoid persisting it locally
gen3-metadata-simulator generate -s your-gen3-schema.json --provider llm --llm-provider openai --llm-model gpt-4o-mini -n 30

No API key? Random placeholder values

Drop the LLM flags for schema-valid (but non-realistic) random data — no key needed:

gen3-metadata-simulator generate --schema your-gen3-schema.json --num-records 30

Need a property held constant everywhere (e.g. a release tag)? Add --set data_release=2024-R1 — every node declaring that property emits the value. Repeatable; see docs/usage.md.

What you get

  • <node>.json — a JSON array of N linked records per node.
  • project.json — the single project object.
  • DataImportOrder.txt — node order for sequential Gen3 submission.

core_metadata_collection is skipped by default (no records, no links to it, not in DataImportOrder.txt) — it is administrative file bookkeeping with no value in simulated data. Pass --include-node core_metadata_collection to restore it, or --exclude-node <name> to skip additional nodes.

Every record's submitter_id is <node>_<guid>, so ids are always unique within a run (and reproducible under --seed).

Everything is validated with gen3-validator first — per-record schema validation plus a referential link check (every link must point at a record that was actually generated); if either fails, nothing is written.

Documentation

  • docs/usage.md — every command and flag, LLM configuration, logging, and interpreting output.
  • docs/dev-notes.md — how it works: the pipeline, value providers, design decisions, and how to extend it.

Development

poetry install
poetry run python3 -m pytest          # fully offline

New to the codebase? Start with docs/dev-notes.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gen3_metadata_simulator-0.5.0.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gen3_metadata_simulator-0.5.0-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

File details

Details for the file gen3_metadata_simulator-0.5.0.tar.gz.

File metadata

  • Download URL: gen3_metadata_simulator-0.5.0.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1022-azure

File hashes

Hashes for gen3_metadata_simulator-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8295173c1408fa339ea5fec1cd21df30760a89f478f34f46ce62012453c756fb
MD5 e88e555647c2060892609ca4a27754c0
BLAKE2b-256 cbe34f1f7b0d61b334ab85d37970db9c6b4f6b316e52f4137fdbdc8c992e50c7

See more details on using hashes here.

File details

Details for the file gen3_metadata_simulator-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gen3_metadata_simulator-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 175df0cbdf17c22c2f34087a32f77f47c38a55e5c018be1a4bdec2c28ce11611
MD5 17511ab88207cc0edefd27dde8258bba
BLAKE2b-256 0e018f29808cedfb38b2b90ed7f4fe85e792ecf16fdd125c509e3a1d9d394db6

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.2

2 files

0.5.1

2 files

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page