Scenarios
A scenario is a Python script that runs on DataMaker’s hosted Python workers. Use a scenario when a single template-and-export step isn’t enough. Typical reasons:
- Referential integrity: generate customers first, then orders that reference real customer IDs.
- Conditional logic: different generation strategy per country, per environment.
- Multi-target seeding: push to Postgres, then to a REST API, then validate the result.
- External calls: hit a non-DataMaker API mid-flow.
- Reusable building blocks: turn a multi-step seeding flow into a single button your team can click.
A minimal scenario
from datamaker import DataMaker
dm = DataMaker()
# 1. Generate 100 customers from a saved template.customers = dm.generate_from_template_id("tmpl_customer", quantity=100)
# 2. Generate 500 orders, then point each at a real customer id (plain Python).import randomids = [c["id"] for c in customers]orders = dm.generate_from_template_id("tmpl_order", quantity=500)for o in orders: o["customer_id"] = random.choice(ids)
# 3. Push both into a configured database connection.dm.export_to_database(export_data) # connection id + payload; see the Scenario API
print(f"✓ generated {len(customers)} customers and {len(orders)} orders")Save it from the Scenarios view, click Run, watch the live log stream.
Sub-pages
- Python environment: what’s pre-installed, how to add packages, what’s not there.
- Scenario API: the SDK surface, injected env vars, and workspace I/O available inside a run.
- Workspace files: uploading CSVs, JSON, lookup tables for use inside scenarios.
- Logs & retries: how live logging works, retry policy, idempotency.
Triggering a scenario
Scenarios aren’t just for manual UI runs. Trigger one from CI with its REST endpoint,
POST /scenarios/{id}/run, optionally with parameters:
curl -X POST https://api.datamaker.automators.com/scenarios/$SCN_ID/run \ -H "Authorization: Bearer $DM_API_KEY" \ -d '{"params": {"environment": "regression"}}'Scenarios vs templates
Use a template when:
- One schema generates one shape of row.
- The target system accepts that shape directly (or with a saved mapping).
Use a scenario when:
- More than one template is involved in a coherent unit of work.
- You need to compose results between steps.
- You need network calls, retries, or branching.
- You want a single button (or a single API call) to do all of the above.
Authoring scenarios
You write scenarios in DataMaker’s web Monaco editor, with full Python syntax highlighting,
type completions for the dm SDK, and live console output below the editor. You can
also git pull your scenarios via the REST API if you’d rather keep them
under version control.