Skip to main content

Official Python SDK for the Chemetrian API (Bayesian Optimization, and more).

Project description

chemetrian

Official Python SDK for the Chemetrian API. Drive Bayesian Optimization (and future services) with pandas DataFrames and one API key.

Install

pip install chemetrian

Quickstart

from chemetrian import Chemetrian

client = Chemetrian(api_key="sk_live_…")                 # or set CHEMETRIAN_API_KEY
# QA: Chemetrian(api_key="sk_live_…", base_url="https://qa.chemetrian.com")

features = [
    {"feature_name": "temp",     "feature_type": "CONTINUOUS_NUMERICAL",
     "lower_bound": 20, "upper_bound": 120, "step_size": 10},
    {"feature_name": "catalyst", "feature_type": "CATEGORICAL",
     "feature_values": ["Pd", "Ni", "Cu"]},
]
targets = [{"target_name": "yield", "goal": "maximize", "threshold": 0}]

# 1. Start a campaign → DataFrame of suggested experiments (priority == 1)
df = client.bayesian_optimization.initialize(
    project="amide-coupling", workflow_name="run-1",
    features=features, targets=targets, batch_size=4,
)

# 2. Run the suggested rows, fill in the measured target, submit → next batch
df.loc[df["priority"] == 1, "yield"] = [72.4, 55.1, 38.9, 80.2]
df = client.bayesian_optimization.run_round("amide-coupling", "run-1", df, batch_size=4)

# 3. (Optional) start from existing data instead of step 1
df = client.bayesian_optimization.initialize_with_experiments(
    project="amide-coupling", workflow_name="run-2",
    experiments=historical_df, targets=targets, batch_size=4,   # features auto-detected
)

Each call submits a job and blocks until it finishes (polling under the hood), then returns a DataFrame. priority: 1 = suggested (run it), -1 = completed.

Projects & workflows

client.list_projects()
client.create_project("amide-coupling", description="Q3 scouting")
client.bayesian_optimization.list_workflows("amide-coupling")

Errors

All raise subclasses of chemetrian.ChemetrianError: ValidationError (client-side), AuthError (401), InsufficientCreditsError (402), NotFoundError (404), RateLimitError (429, auto-retried), JobFailedError, JobTimeoutError.

Configuration

arg / env purpose
api_key / CHEMETRIAN_API_KEY your key
base_url / CHEMETRIAN_API_URL API host (QA vs prod)
poll_interval, poll_timeout how long the SDK waits for a job

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

chemetrian-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

chemetrian-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file chemetrian-0.1.0.tar.gz.

File metadata

  • Download URL: chemetrian-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.6 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for chemetrian-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d832aa351680b9cc391910d6d2b517cb41b38fa792f5c45f8b2a687c47368a7
MD5 8798b2446745aef5b7ec4a55bdc4dda0
BLAKE2b-256 2c16d918f3340988ec6ebe0a15e19f8513fd7be7b70fc0ca4fd4d44a631cec89

See more details on using hashes here.

File details

Details for the file chemetrian-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chemetrian-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.6 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for chemetrian-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06f21fa8d657fc1a47083c1e15e0e888362634a3132d761bbac65edc054ef97b
MD5 360b8f46eb16a633dec8930a55acdd29
BLAKE2b-256 6cf18f4efb02839e95fd1cb7f7d1176b87a353825419b4e3048696d9b4e42af1

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