Python API

Getting Started

Installation

To get started, install rowan-python from the Python Package Index:

pip install rowan-python

Authentication

Usage of the Python API requires generation of an API key at labs.rowansci.com. This guide walks through the process of generating a new API key.

Use your API key by assigning it to rowan.api_key:

import rowan
rowan.api_key = "my_secret_api_key"

Equivalently, you can set the environment variable ROWAN_API_KEY:

export ROWAN_API_KEY=my_secret_api_key

Your API keys allow authentication to your account, so keep them secure! Don't store API keys in places where others could access them, like GitHub or shared scripts.

Data Structures

In Rowan, data is stored in the open-source stjames format.


High-Level compute API

Workflows can be submitted using rowan.compute(). This function submits a workflow, automatically monitors its status, and returns the result when complete.

res = rowan.compute(
    name="benzene redox",
    molecule="c1ccccc1",
    workflow_type="redox_potential",
)

print(res["object_data"]["oxidation_potential"])  # 2.7466429

Parameters

molecule (str | cctk.Molecule | stjames.Molecule)

The initial molecule for the workflow. Molecules can be specified as a SMILES string, a cctk.Molecule, or a stjames.Molecule.

workflow_type (str)

The workflow to run on the molecule.

name ('str')

The name of the workflow.

folder_uuid ('str | None')

The folder to submit the calculation to. If left blank, calculations will be submitted into the user's root folder.

blocking (bool)

Whether or not the function should wait until complete to return. Defaults to True.

ping_interval (int)

The interval at which to check calculation status, in seconds. Defaults to 5.

**kwargs (dict)

Additional arguments will be passed as workflow-specific parameters.


Folder API

The Folder object

This object represents a folder in Rowan, which can hold other folders or workflows.

{
  "name": "example folder",
  "parent_uuid": "64b01a92-e52d-45ac-9768-3cc9430eaa6e",
  "notes": "This is a folder",
  "starred": false,
  "public": false,
  "created_at": "2024-09-10T13:58:39.500Z",
  "updated_at": "2024-09-10T13:58:39.500Z",
  "is_root": false,
  "uuid": "6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
}

Attributes

name (str)

The name of the folder.

parent_uuid (str)

The UUID of this folder's parent (the folder which contains this folder).

notes (str)

Any notes associated with this folder.

starred (bool)

Whether or not this folder is starred.

public (bool)

Whether or not this folder is publicly viewable. This will propagate to all contained workflows and folders.

created_at (datetime.datetime)

The date and time at which this folder was created.

updated_at (datetime.datetime)

The date and time at which this folder was most recently updated.

is_root (bool)

Whether or not this folder is the user's root folder.

uuid (str)

The UUID of this folder.

Create a folder

This function creates a new folder and returns the folder object.

rowan.Folder.create(
  name="new folder",
  parent_uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
)

Parameters

name (str)

The name of the folder.

parent_uuid (str)

The UUID of this folder's parent (the folder which contains this folder).

notes (str)

Any notes associated with this folder.

starred (bool)

Whether or not this folder is starred.

public (bool)

Whether or not this folder is publicly viewable. This will propagate to all contained workflows and folders.

Returns

The folder object.

Retrieve a folder

This function retrieves a folder.

folder = rowan.Folder.retrieve(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
)

Parameters

uuid (str)

The UUID of this folder.

Returns

The folder object.

Update a folder

This function updates a folder and returns the new object.

rowan.Folder.update(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
  name="renaming this folder",
  public=True,
)

Parameters

uuid (str)

The UUID of this folder.

name (str)

The name of the folder.

parent_uuid (str)

The UUID of this folder's parent (the folder which contains this folder).

notes (str)

Any notes associated with this folder.

starred (bool)

Whether or not this folder is starred.

public (bool)

Whether or not this folder is publicly viewable. This will propagate to all contained workflows and folders.

Returns

The new folder object.

Delete a folder

This function deletes a folder. This action cannot be undone!

rowan.Folder.delete(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
)

Parameters

uuid (str)

The UUID of this folder.

Returns

Nothing.

List all folders

This function returns all folders that meet specified criteria.

folder_res = rowan.Folder.list(
  name_contains="redox",
)

Parameters

name_contains (str)

Return folders whose name contains a specified string.

parent_uuid (str)

The UUID of the folders' parent (the folder which contains these folders).

starred (bool)

Whether or not the folders are starred.

public (bool)

Whether or not the folders are public.

page (int)

Which page of results to return.

size (int)

How many results to return per page.

Returns

folders (list[dict])

A list of the folders that match the specified criteria.

num_pages (int)

The total number of pages.


Workflow API

The Workflow object

This object represents a workflow in Rowan.

{
  "name": "water pka",
  "parent_uuid": "824f1db1-e7ff-4d3f-a102-62c365d0fb80",
  "notes": "",
  "starred": false,
  "public": false,
  "object_type": "pka",
  "object_data": {
    "pka_range": [-5, 25],
    "deprotonate_elements": ["8"],
    "deprotonate_atoms": [],
    "protonate_elements": ["8"],
    "protonate_atoms": [],
    "mode": "careful",
    "initial_molecule": {
      "charge": 0,
      "multiplicity": 1,
      "atoms": [
        {
          "atomic_number": 8,
          "position": [-0.011994152329862118, 0.3976341784000397, 0]
        },
        {
          "atomic_number": 1,
          "position": [-0.7571237087249756, -0.2218356728553772, 0]
        },
        {
          "atomic_number": 1,
          "position": [0.7691178917884827, -0.17579850554466248, 0]
        }
      ],
    }
  },
  "email_when_complete": false,
  "created_at": "2024-09-11T14:34:49.085669Z",
  "updated_at": null,
  "started_at": null,
  "completed_at": null,
  "uuid": "b834ab26-8533-489c-97a5-bd915f00a6c2",
  "elapsed": 0,
  "credits_charged": 0,
  "object_status": 0,
  "object_logfile": "",
  "is_free": true
}

Attributes

name (str)

The name of the workflow.

parent_uuid (str)

The UUID of this workflow's parent (the folder which contains this workflow).

notes (str)

Any notes associated with this workflow.

starred (bool)

Whether or not this workflow is starred.

public (bool)

Whether or not this workflow is publicly viewable.

created_at (datetime.datetime)

The date and time at which this workflow was created.

updated_at (datetime.datetime)

The date and time at which this workflow was most recently updated.

started_at (datetime.datetime | None)

The date and time at which this workflow started running.

completed_at (datetime.datetime | None)

The date and time at which this workflow finished.

is_free (bool)

Whether or not this workflow was free.

uuid (str)

The UUID of this workflow.

object_data (dict)

The data associated with this workflow. See stjames for detailed per-workflow descriptions.

object_status (int)

The status of this workflow, as an integer. Status codes are defined in stjames.

object_logfile (str)

The logfile associated with this workflow.

elapsed (float)

The amount of time this workflow took to run, in seconds.

credits_charged (int)

The number of credits charged to the user for running this workflow.

Submit a workflow

This function creates a new workflow.

rowan.Workflow.submit(
  name="new pka prediction",
  workflow_type="pka",
  initial_molecule=stjames_molecule_dict,
  workflow_data={
    "pka_range": [-5, 25],
  },
)

Parameters

name (str)

The name of the workflow.

folder_uuid (str)

The UUID of the folder where this workflow should go.

workflow_type (str)

What sort of workflow to run.

initial_molecule (dict)

The molecule to run the workflow on, formatted as a stjames.Molecule.

workflow_data (dict)

Any additional data to submit to the workflow. See stjames for detailed per-workflow descriptions.

Returns

The workflow object.

Retrieve a workflow

This function retrieves a workflow.

workflow = rowan.Workflow.retrieve(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
)

Parameters

uuid (str)

The UUID of the workflow.

Returns

The workflow object.

Update a workflow

This function updates a workflow and returns the new object.

rowan.Workflow.update(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
  name="renaming this workflow",
  public=True,
)

Parameters

uuid (str)

The UUID of this workflow.

name (str)

The name of the workflow.

parent_uuid (str)

The UUID of this workflow's parent (the folder which contains this workflow).

notes (str)

Any notes associated with this workflow.

starred (bool)

Whether or not this workflow is starred.

public (bool)

Whether or not this workflow is publicly viewable.

email_when_complete (bool)

Whether or not to send an email update when the workflow is complete.

Returns

The new workflow object.

Stop a workflow

This function stops a workflow that hasn't yet finished.

workflow = rowan.Workflow.stop(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
)

Parameters

uuid (str)

The UUID of the workflow.

Returns

Nothing.

Check the status of a workflow

This function returns the status of a given workflow.

status = rowan.Workflow.status(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
)

Parameters

uuid (str)

The UUID of the workflow.

Returns

The status, as type int.

Check if a workflow is finished

This function returns True if a workflow is finished and False otherwise.

finished_yet = rowan.Workflow.is_finished(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
)

Parameters

uuid (str)

The UUID of the workflow.

Returns

If the workflow, as type bool.

Delete a workflow

This function deletes a workflow. This action cannot be undone!

rowan.Workflow.delete(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
)

Parameters

uuid (str)

The UUID of this workflow.

Returns

Nothing.

List all workflows

This function returns all workflow that meet specified criteria.

workflow_res = rowan.Workflow.list(
  name_contains="Ph",
  object_status=3,
  object_type="redox_potential",
)

Parameters

name_contains (str)

Return workflows whose name contains a specified string.

parent_uuid (str)

The UUID of the workflows' parent (the folder which contains these workflows).

starred (bool)

Whether or not the workflows are starred.

public (bool)

Whether or not the workflows are public.

object_status (int)

The status of the workflows.

object_type (str)

The type of these workflows.

page (int)

Which page of results to return.

size (int)

How many results to return per page.

Returns

workflows (list[dict])

A list of the workflows that match the specified criteria.

num_pages (int)

The total number of pages.


Calculation API

The Calculation object

This object represents a single calculation in Rowan. Calculations are created by workflows, and workflow results often contain the UUIDs of their constituent calculations.

{
  "settings": {
    "method": "aimnet2_wb97md3",
    "basis_set": null,
    "tasks": [
      "optimize",
      "frequencies"
    ],
  },
  "molecules": [...],
  "status": 2,
  "name": "neutral (conformer 1)",
  "elapsed": 0.09688869799998656,
}

The full calculation object is detailed in stjames.

Attributes

settings (dict)

The settings for the calculation (see stjames).

molecules (list[dict])

The molecules in the calculation. Single-point calculations will have only a single molecule, while optimizations will have a list of molecules. Molecules are stored in the stjames.Molecule format.

status (int)

The status of this calculation, as an integer. Status codes are defined in stjames.

elapsed (float)

How long this calculation took to run, in seconds.

name (str)

The name of this calculation.

Retrieve a calculation

This function retrieves a calculation.

folder = rowan.Calculation.retrieve(
  uuid="6dac05de-ce7f-4f6d-b7d2-743981aa1fde",
)

Parameters

uuid (str)

The UUID of this calculation.

Returns

The calculation object.