Datasets¶
Spilling large values to disk as references.
datasets
¶
Dataset references: moving large data payloads between agents via disk pointers.
When agents return large arrays or DataFrames, storing them inline in trace.json would produce unwieldy traces. Large payloads are spilled to disk into data/ and replaced with structured pointers ($dataset), which are transparently hydrated when read by downstream agents.
is_reference
¶
Returns True if value is a dataset reference pointer dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The object to inspect. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if value is a dataset reference dictionary; False otherwise. |
Source code in python/src/science_adk/datasets.py
should_spill
¶
Determines whether a value should be saved to an external file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to inspect. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the value exceeds the spill threshold or is tabular/array data. |
Source code in python/src/science_adk/datasets.py
save
¶
Persists a value to data_dir and returns its reference pointer dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The data object to persist. |
required |
data_dir
|
Path
|
Directory where the file should be saved. |
required |
name
|
str
|
Base name for the saved file. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A reference pointer dictionary. |
Source code in python/src/science_adk/datasets.py
load
¶
Rehydrates a dataset reference pointer into an in-memory object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pointer
|
dict[str, Any]
|
Dataset pointer dictionary containing $dataset path. |
required |
run_dir
|
Path
|
Path to the run directory. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Rehydrated data object. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the target file is missing. |
ImportError
|
If required libraries (pandas, numpy) are missing. |
Source code in python/src/science_adk/datasets.py
hydrate
¶
Recursively hydrates dataset pointers in nested data structures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Object or nested structure that may contain dataset pointers. |
required |
run_dir
|
Path
|
Path to the active run directory. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Data structure with all pointers rehydrated into real objects. |
Source code in python/src/science_adk/datasets.py
externalize
¶
Spills large objects to disk or converts small objects to JSON-ready form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to process. |
required |
data_dir
|
Path
|
Destination data directory. |
required |
name
|
str
|
Base file name for externalized data. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Either a dataset pointer dictionary or a JSON-ready Python primitive. |
Source code in python/src/science_adk/datasets.py
describe
¶
Generates a concise single-line description of a value or dataset pointer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to describe. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A short human-readable string summary. |