Data¶
jayrun.Data is Jayrun’s immutable runtime container. It pairs a payload with the placement metadata that describes where the payload resides.
from jayrun import Data
from jayrun.placement import CPU_PLACEMENT
data = Data(value=result)
Data is shared by the whole data model:
artifact inputs and outputs are exposed as
Data;resolved configuration values are exposed as
Data; andresource
setup()returnsData, which is later passed toteardown().
The surrounding declaration gives the payload its meaning. Data itself does not identify an artifact, config field, resource, graph, or context.
Attributes¶
Attribute |
Meaning |
|---|---|
|
The runtime payload |
|
The |
The default placement is CPU_PLACEMENT:
data = Data(value=result)
assert data.placement is CPU_PLACEMENT
The container is frozen, but Jayrun does not copy or freeze value. If the payload is mutable, ordinary Python references can still mutate it.
Automatic and explicit wrapping¶
Application-facing context setters accept raw payloads:
artifacts.set({input_artifact: input_value})
configs.set({operator.batch_size: 32})
jayrun.ArtifactContext.set() and jayrun.ConfigContext.set() wrap those values in CPU Data. Pass the payload itself to these methods, not an existing Data container.
Connected operator outputs may be raw values or explicit Data. A raw output is wrapped automatically with CPU placement:
def execute(self) -> object:
return transform(self.input_data.value)
Return Data explicitly when the result carries non-default placement metadata:
def execute(self) -> Data:
placement = self.placement.cuda(memory_gb=2)
value = move_to_cuda(self.input_data.value, placement.device_id)
return Data(value=value, placement=placement)
An operator with no connected output returns None; that return is completion of the step, not artifact Data. An unbound output position never produces a Data container or an artifact result. See Unbound outputs and unavailable values and Terminal and side-effect operators.
Resource setup is stricter: jayrun.BaseResource.setup() must return exactly one Data instance.
Placement metadata¶
Placement metadata describes location and preserves the corresponding accelerator-capacity lease. It does not move, copy, shard, or otherwise transform the payload. The component creating the payload is responsible for placing it on the reported device.
Attach accelerator placement to every Data whose payload depends on that reservation. See Placement Interface for requesting capacity and Placement and Capacity for lease lifetime.
Lifetime¶
Data lifetime depends on its owner:
artifact data follows artifact clearing and retention rules;
configuration data belongs to one submitted context;
resource data remains cached until safe eviction or runtime shutdown.
See Scope and Lifetime Model for ownership and Artifacts and Data Flow, Configuration, and Resources for the specific lifecycle contracts.
API reference¶
- class jayrun.Data(value, placement=CPU_PLACEMENT)¶
Immutable runtime container pairing a payload with placement metadata.
- Parameters:
value (object) – Runtime payload. Jayrun does not copy or validate the payload.
placement (Placement | PlacementGroup) – Placement associated with the payload.
- Raises:
TypeError – If
placementis not aPlacementorPlacementGroup.
- jayrun.Data.value¶
Runtime payload.
- jayrun.Data.placement: Placement | PlacementGroup¶
Placement metadata associated with the payload.
Next, read Artifacts and Data Flow to see how runtime data is identified and moved through a graph.