MCPcopy Create free account
hub / github.com/NVIDIA/NeMo-Relay / push

Function push

python/nemo_relay/scope.py:86–147  ·  view source on GitHub ↗

Push a new child scope and return its handle. Args: name: Human-readable name for the new scope. scope_type: Semantic scope type, such as ``ScopeType.Agent`` or ``ScopeType.Function``. handle: Optional parent scope handle. When omitted, the current

(
    name: str,
    scope_type: ScopeType,
    *,
    handle: ScopeHandle | None = None,
    attributes: ScopeAttributes | None = None,
    data: Json | None = None,
    metadata: Json | None = None,
    input: Json | None = None,
    timestamp: datetime | None = None,
)

Source from the content-addressed store, hash-verified

84
85
86def push(
87 name: str,
88 scope_type: ScopeType,
89 *,
90 handle: ScopeHandle | None = None,
91 attributes: ScopeAttributes | None = None,
92 data: Json | None = None,
93 metadata: Json | None = None,
94 input: Json | None = None,
95 timestamp: datetime | None = None,
96) -> ScopeHandle:
97 """Push a new child scope and return its handle.
98
99 Args:
100 name: Human-readable name for the new scope.
101 scope_type: Semantic scope type, such as ``ScopeType.Agent`` or
102 ``ScopeType.Function``.
103 handle: Optional parent scope handle. When omitted, the current
104 top-of-stack scope becomes the parent.
105 attributes: Optional native scope attributes attached to the emitted
106 start event.
107 data: Optional JSON application payload stored on the scope handle.
108 metadata: Optional JSON metadata recorded on the scope start event.
109 input: Optional JSON payload exported as the semantic scope input.
110 timestamp: Optional timezone-aware ``datetime`` recorded as the handle
111 start time and on the scope start event. When omitted, the current
112 runtime time is used.
113
114 Returns:
115 ScopeHandle: Handle for the newly pushed scope.
116
117 Notes:
118 A scope stack is created automatically if the current context does not
119 yet have one. ``timestamp`` must be a timezone-aware ``datetime``;
120 strings and naive datetimes are rejected.
121
122 Example::
123
124 import nemo_relay
125
126 with nemo_relay.scope.scope("parent", nemo_relay.ScopeType.Agent) as parent:
127 handle = nemo_relay.scope.push(
128 "worker",
129 nemo_relay.ScopeType.Function,
130 handle=parent,
131 attributes=None,
132 data={"step": 1},
133 metadata={"source": "scope.push"},
134 )
135 nemo_relay.scope.pop(handle)
136 """
137 _ensure_scope_stack()
138 return _native_push_scope(
139 name,
140 scope_type,
141 handle=handle,
142 attributes=attributes,
143 data=data,

Callers

nothing calls this directly

Calls 1

_ensure_scope_stackFunction · 0.85

Tested by

no test coverage detected