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)

Workflow Configuration#

A Workflow’s configuration is available only to jobs based on that Workflow. The workflow configuration is accessible using get_workflow_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_workflow_config

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


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

Attention

A Workflow’s default configuration is defined in OP and can be edited from that Workflow’s settings page in LabOps. When a Workflow is run as a job, the Workflow’s default config is copied into the job’s config.

Once a job has started, changes to the default Workflow config will only affect new jobs created from that Workflow, and changes to the job’s config will only affect that job. Job config can be edited from the job details panel in LabOps.

Defining a Workflow Config#

Workflow config is defined by specifying a dataclass and its members and types. Each member has a corresponding @field decorator, which allows you 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

@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

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