Workspace files
Sometimes a scenario needs reference data (a CSV of real product SKUs, a JSON map of country codes to currencies, an Excel sheet of postcode-to-region) or needs to produce a file (a report, an exported dataset). Workspace files ride along with a run: inputs are synced in before it starts, outputs are persisted after it finishes.
How files reach a run
- UI: in any chat or scenario, click the paperclip → upload. Drag a CSV, JSON, YAML, XLSX, or TXT.
- REST: see the REST API for the upload endpoint.
Before a run, uploaded files are synced into the directory DATAMAKER_WORKSPACE_UPLOADS.
Anything written under DATAMAKER_WORKSPACE_OUTPUTS is persisted to object storage after the
run and shows up in the run’s Assets view.
Read inputs
The simplest path is plain Python against the uploads directory:
import os, csv, json
uploads = os.environ["DATAMAKER_WORKSPACE_UPLOADS"]
with open(os.path.join(uploads, "currency_rates.csv")) as f: rates = {row["code"]: float(row["rate"]) for row in csv.DictReader(f)}
with open(os.path.join(uploads, "postcodes.json")) as f: postcodes = json.load(f)pandas is preinstalled if you’d rather load a spreadsheet:
import pandas as pddf = pd.read_excel(os.path.join(uploads, "regions.xlsx"), sheet_name="DACH")Or reach files through the SDK:
dm.get_scenario_files() # list files attached to this runcontent = dm.read_file_by_path("lookups/postcodes.json")Write outputs
Write deliverables under the outputs directory; they’re persisted and downloadable from Assets:
import osoutputs = os.environ["DATAMAKER_WORKSPACE_OUTPUTS"]
with open(os.path.join(outputs, "regression_report.csv"), "w") as f: f.write(report_csv)Or persist a local file / a string through the SDK:
dm.save_file(local_path, folder="outputs")dm.create_scenario_file("summary.json", json.dumps(summary))Manage files
dm.get_scenario_files() # listdm.download_scenario_file(file_id)dm.delete_scenario_file(file_id) # immediate; no soft deleteYou can also manage them from the UI. If a scenario references a file that’s since been deleted, it fails at runtime, so prefer the idempotent pattern of writing fresh outputs each run.
Fail fast on missing inputs
If an input file might be missing, check for it and print() a clear message rather than
crashing deep in the script:
path = os.path.join(uploads, "currency_rates.csv")if not os.path.exists(path): raise SystemExit("Upload currency_rates.csv to the run before running this scenario.")