Skip to main content

Simulate linked Gen3 metadata JSON files from a bundled Gen3 JSON schema

Project description

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

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.

Everything is validated with gen3-validator first; if validation 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.

Project details


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.3.0.tar.gz (25.3 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.3.0-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gen3_metadata_simulator-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a2a5fd5bc4f29d644ab4e71190bdd9f1e5acdda885a6a84feb7f2607ca9af557
MD5 8fe257c929bbc59512bb83e8b0a37436
BLAKE2b-256 e2a14862013c9bd98b1727f5b4bf5573985615cb86e3388f4d7303946f21e259

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gen3_metadata_simulator-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a005dd96430593083668f3fe44906bb9effb90de4bfcf07383942ae1b782e4e
MD5 f9ff19ef7b8acfa775b3151a30fc8f55
BLAKE2b-256 51c69024cffe07e1bfbe2a89bc3b50c6731956a96e541cb774fa1f4dac94e41c

See more details on using hashes here.

Supported by

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