Tools · Custom Modeling
Python Script Sandbox
On this page
Prices, workflows, and method papersOpen in the app
Run it from the API
Submit with Submit a job and the job_type below. Price it first with Estimate job reservation cost: submitting reserves that amount from your wallet, and the charge settles at the actual runtime.
python-sandbox python-sandbox
- Job type
python-sandbox- Hardware
cpu(default)- Typical runtime
- 3 min on CPU
Payload
| Field | Type | Description |
|---|---|---|
coderequired | string | The Python 3.12 script. It reads /work/in, writes /work/out, and has no network or package installs. Limits: |
inputs | map<string, artifactRef> | Named result artifacts, each copied into /work/in/<name>/ (at most 100 MB in total). Default: |
timeout_seconds | integer | Wall-clock limit for the script. The wallet hold covers the full timeout. Default: |
summary | string | One line on what the script does. Limits: |
Example
from cognichem_client import CogniChem
client = CogniChem.from_env() # reads COGNICHEM_API_KEY
payload = {
"code": "import csv\nfrom pathlib import Path\n\nrows = [(\"CCO\", 46.07),… (295 characters)",
"inputs": {},
"timeout_seconds": 30,
"summary": "Write a two-row table of molecular weights",
}
estimate = client.jobs.estimate(job_type="python-sandbox", payload=payload, resource="cpu")
print(f"Reserves ${estimate.cost:.2f}")
job = client.jobs.submit(
job_name="my-python-sandbox-run",
job_type="python-sandbox",
payload=payload,
resource="cpu",
)
status = client.jobs.wait(job.process_id)
if status.status == "completed":
client.jobs.result(job.process_id, save_path=".")curl -X POST "https://api.cognichem.com/api/v1/jobs/submit" \
-H "X-Api-Key: $COGNICHEM_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"job_name": "my-python-sandbox-run",
"job_type": "python-sandbox",
"payload": {
"code": "import csv\nfrom pathlib import Path\n\nrows = [(\"CCO\", 46.07),… (295 characters)",
"inputs": {},
"timeout_seconds": 30,
"summary": "Write a two-row table of molecular weights"
},
"resource": "cpu"
}'{
"code": "import csv\nfrom pathlib import Path\n\nrows = [(\"CCO\", 46.07),… (295 characters)",
"inputs": {},
"timeout_seconds": 30,
"summary": "Write a two-row table of molecular weights"
}Sample data from the job catalog; long values are shortened here. Each job_name must be unique among your jobs.