Primitives¶
The seven specialised scientific agent primitives.
primitives
¶
Agent primitives — specialized roles for scientific workflow nodes.
AlgorithmAgent
¶
CompositeAgent
¶
Bases: Agent
A node that executes an entire nested workflow DAG.
Attributes:
| Name | Type | Description |
|---|---|---|
workflow |
str
|
Relative path to the nested workflow.json file. |
execute
async
¶
Executes the nested workflow and surfaces its terminal outputs.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of outputs mapped to declared output ports. |
Raises:
| Type | Description |
|---|---|
AgentError
|
If the workflow path is missing, not in runtime, or outputs mismatch. |
Source code in python/src/science_adk/primitives/composite.py
ConfigAgent
¶
Bases: Agent
Emits configuration settings, hyperparameters, and physical constants.
settings
¶
Merges default values with workflow params overrides.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**defaults
|
Any
|
Default configuration key-value pairs. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Combined settings dictionary. |
Source code in python/src/science_adk/primitives/config.py
DataAgent
¶
Bases: Agent
Produces or ingests dataset payloads for experiment workflows.
Attributes:
| Name | Type | Description |
|---|---|---|
source_kind |
str
|
ClassVar string indicating data provenance ('measured', 'simulated', 'synthetic'). |
check_frame
¶
Validates that a DataFrame has required columns and minimum row count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
Any
|
The DataFrame object to validate. |
required |
columns
|
list[str]
|
List of required column names. |
required |
min_rows
|
int
|
Minimum required number of rows. |
1
|
Returns:
| Type | Description |
|---|---|
Any
|
The validated DataFrame. |
Raises:
| Type | Description |
|---|---|
AgentError
|
If columns are missing or row count is insufficient. |
Source code in python/src/science_adk/primitives/data.py
EvaluationAgent
¶
Bases: Agent
Measures the experiment's quantitative outcome.
report
¶
Constructs standardized evaluation output port dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
str
|
Name of the evaluated metric. |
required |
value
|
float
|
Quantitative numeric result. |
required |
detail
|
dict[str, Any] | None
|
Optional supporting dictionary of details. |
None
|
higher_is_better
|
bool
|
Optimization direction indicator. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Output port dictionary for execute(). |
Raises:
| Type | Description |
|---|---|
AgentError
|
If the value is non-numeric or NaN. |
Source code in python/src/science_adk/primitives/evaluation.py
TrainingAgent
¶
Bases: Agent
Fits models to data and manages reproducible train/test splits.
Attributes:
| Name | Type | Description |
|---|---|---|
seed |
int | None
|
Seed for reproducible random splitting and initialization. |
split
¶
Splits dataset into (train, test) subsets deterministically under seed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Data sequence or DataFrame. |
required |
test_fraction
|
float
|
Fraction of rows allocated to the test set (0 < frac < 1). |
0.2
|
shuffle
|
bool
|
Whether to shuffle before splitting. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[Any, Any]
|
Tuple of (train_data, test_data). |
Raises:
| Type | Description |
|---|---|
AgentError
|
If test_fraction is invalid or data has fewer than 2 elements. |
Source code in python/src/science_adk/primitives/training.py
seed_everything
¶
Sets random seed across Python standard library, NumPy, and PyTorch.
Source code in python/src/science_adk/primitives/training.py
VisualizationAgent
¶
Bases: Agent
Renders visual plots and figures from results produced upstream.
figure_path
¶
Reserves a path for a figure file inside this run's data directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Base figure name. |
required |
extension
|
str
|
File extension without leading dot. |
'png'
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the reserved figure file. |
Source code in python/src/science_adk/primitives/visualization.py
save_figure
¶
Saves a matplotlib figure and returns its run-relative path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
figure
|
Any
|
Matplotlib Figure object. |
required |
name
|
str
|
Name of the figure. |
required |
dpi
|
int
|
Resolution in dots per inch. |
150
|
Returns:
| Type | Description |
|---|---|
str
|
Run-relative path string. |