Context Interface¶
self.context addresses the graph submission that owns the current execution. It exposes context identity, stored values, and self-lifecycle requests.
Context identity¶
context_id = self.context.id
This ID matches the corresponding ContextRun.context_id and is useful for external logs. Control APIs do not require user code to pass it back to Jayrun.
Stored values¶
Context records are visible across operators, repetitions, and graph iterations in the same run:
def execute(self):
previous = self.context.get_value("best_score")
score = evaluate(self.model.value)
if previous is None or score > previous:
self.context.store("best_score", score)
return self.model.value
Available methods are:
Method |
Result |
|---|---|
|
Append a value and its provenance |
|
Whether at least one record exists |
|
Latest value, or |
|
All values in recording order |
|
Latest |
|
All records in recording order |
Stored values do not trigger operators or satisfy dependencies. Use an artifact when a value is part of declared graph data flow.
After finalization, the same records remain available through the caller’s ContextRun methods.
Pause¶
self.context.pause()
self.context.pause(duration_seconds=30)
Without a duration, the pause is indefinite and another authorized ContextRun must call resume(). With a duration, Jayrun schedules automatic resumption.
Pause takes effect at a scheduling boundary. It is not a sleep, an await, or forced suspension of the current Python instruction.
Abort¶
self.context.abort()
Abort prevents further dispatch and drains accepted work toward ABORTED. The current invocation is not forcefully killed, so return promptly after requesting it.
Stop iteration¶
self.context.stop()
Stop means stop iteration. Accepted work drains, and no next graph iteration begins. Use abort when remaining work should be abandoned; use stop when an iterative graph has reached its orderly completion condition.
API summary¶
- ContextInterface.pause(duration_seconds=None) None¶
Request a pause at a scheduling boundary.
Nonemeans indefinite.
Lifecycle calls enqueue messages and return immediately. Use a ContextRun wait when another participant must observe the transition.
Continue with Runtime Interface for graph-scoped supervision.