Skip to content

molq 0.9.0 Manual

molq

Run local commands and HPC jobs. Submit, wait, and read the results from one API.

molq

Run

A function, a job

Choose a registered destination, decorate a function, and call it.

Quickstart →

import json
from pathlib import Path

from molq import JobSpec, submit

local = submit("local", "local", project_root=Path.cwd())


@local
def hello(name):
    job = yield JobSpec.argv(["echo", f"hello {name}"])
    return job


job = hello("molq")
result = job.wait(timeout=30)
print(json.dumps(job.logs(), ensure_ascii=False))
local.close()

Scale

The same job on a cluster

Choose the allocation and account. Your SSH configuration handles the connection.

Cluster guide →

from molq import JobSpec, Resources, Scheduling, submit

hpc = submit("hpc", project_root="/shared/project")


@hpc
def simulate():
    job = yield JobSpec.argv(
        ["python", "simulate.py"],
        resources=Resources(tasks=1, cpus_per_task=4, time_limit_seconds=600),
        scheduling=Scheduling(account="your-project"),
    )
    return job


job = simulate()
hpc.close()

Manual

Find your next step