Accessing Org/Lab/Job Configuration#

There are three levels of configuration you can access in Orchestration Python. Each level has different uses and scopes to which it applies.

Organization Configuration#

Organization configuration is available to all of the labs and workflows in your organization.

Organization configuration values are set in the Artificial UI in your Org Settings page. Once set, these values can be accessed in orchestration python using get_org_config().

from artificial.workflows.decorators import workflow
from artificial.workflows.util import get_org_config

@workflow('Org Config', 'wf_org_config', 'lab_c9eae09e-ceed-46d1-8390-87ff7dd8586d')
async def org_config() -> None:
    plate_type = get_org_config().configuration['biorad']
    show_info(plate_type)

Lab Configuration#

Lab configuration is available inside of a single lab, and to all the jobs running within that lab.

Lab configuration values are set in the Artificial UI in a specific Lab’s Settings page. Once set, these values can be accessed in orchestration python using get_lab_config().

from artificial.workflows.decorators import workflow
from artificial.workflows.util import get_lab_config

@workflow('Lab Config', 'wf_lab_config', 'lab_c9eae09e-ceed-46d1-8390-87ff7dd8586d')
async def lab_config() -> None:
    liquid_handler = get_lab_config().configuration['liquid_handler_id']
    show_info(liquid_handler_id)

Job Configuration#

A job’s configuration is specific to that job. The job’s configuration is accessible using get_job_config().

from dataclasses import dataclass

from artificial.workflows.decorators import config_type, field, workflow
from artificial.workflows.runtime import show_info
from artificial.workflows.util import get_job_config

@dataclass
@field('num_samples', config={'uiTitle': 'Number of Samples'})
class ExampleWorkflowConfig:
   num_samples: int = 5


@workflow("Workflow Config", "wf_config", "lab_c9eae09e-ceed-46d1-8390-87ff7dd8586d")
@config_type(ExampleWorkflowConfig)
async def wf_config() -> None:
    samples = get_job_config().num_samples
    await show_info(f"Samples: {samples}")

Attention

The Workflow configuration is the starting config for a job run from that workflow. The Workflow configuration can be edited from the Workflow’s settings page in LabOps. When a new Job is created, its Workflow’s config is copied into the job’s config. Further changes to the Workflow’s config will only affect new jobs created from that Workflow, and changes to the job’s config will only affect that job. Once a Job is created, its config can be edited from the job details panel in LabOps.

Defining Job Config#

Job config is defined by specifying a dataclass and its members and types.

Each member can have a corresponding @field decorator to configure the display name when viewed in the Artificial UI as well as many other options. It is possible to nest configs and assign default values, as shown in the code snippet below.

from dataclasses import dataclass
from artificial.workflows.decorators import field
from artificial.workflows.utils import get_job_config

@dataclass
@field('num_samples', config={'uiTitle': 'Number of Samples'})
@field('sample_name', config={'uiTitle': 'Sample Name'})
class WellConfig:
    num_samples: int = 5
    sample_name: str = 'Example Sample'

@dataclass
@field('plate', config={'uiTitle': 'Plate'})
@field('barcode', config={'uiTitle': 'Barcode'})
class PlateConfig:
    plate: WellConfig
    barcode: str

@workflow("Workflow Config", "wf_config", "lab_c9eae09e-ceed-46d1-8390-87ff7dd8586d")
@config_type(PlateConfig)
async def wf_config() -> None:
    samples = get_job_config().plate.num_samples
    await show_info(f"Samples: {samples}")