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

Function push_scope

crates/python/src/py_api/mod.rs:217–248  ·  view source on GitHub ↗
(
    name: &str,
    scope_type: PyScopeType,
    handle: Option<PyScopeHandle>,
    attributes: Option<PyScopeAttributes>,
    data: Option<&Bound<'_, PyAny>>,
    metadata: Option<&Bound<'_, PyAny>

Source from the content-addressed store, hash-verified

215 timestamp: "datetime.datetime | None"=None
216) -> "ScopeHandle", text_signature = "(name: str, scope_type: ScopeType, *, handle: ScopeHandle | None = None, attributes: ScopeAttributes | None = None, data: object | None = None, metadata: object | None = None, input: object | None = None, timestamp: datetime.datetime | None = None) -> ScopeHandle")]
217fn push_scope(
218 name: &str,
219 scope_type: PyScopeType,
220 handle: Option<PyScopeHandle>,
221 attributes: Option<PyScopeAttributes>,
222 data: Option<&Bound<'_, PyAny>>,
223 metadata: Option<&Bound<'_, PyAny>>,
224 input: Option<&Bound<'_, PyAny>>,
225 timestamp: Option<&Bound<'_, PyAny>>,
226) -> PyResult<PyScopeHandle> {
227 let attrs = attributes
228 .map(|a| a.inner)
229 .unwrap_or(ScopeAttributes::empty());
230 let d = opt_py_to_json(data)?;
231 let meta = opt_py_to_json(metadata)?;
232 let input = opt_py_to_json(input)?;
233 let timestamp = opt_py_to_timestamp(timestamp)?;
234 core_scope_api::push_scope(
235 core_scope_api::PushScopeParams::builder()
236 .name(name)
237 .scope_type(scope_type.into())
238 .parent_opt(handle.as_ref().map(|h| &h.inner))
239 .attributes(attrs)
240 .data_opt(d)
241 .metadata_opt(meta)
242 .input_opt(input)
243 .timestamp_opt(timestamp)
244 .build(),
245 )
246 .map(PyScopeHandle::from)
247 .map_err(to_py_err)
248}
249
250/// Remove a scope from the stack and emit an ``End`` event.
251///

Calls 6

opt_py_to_jsonFunction · 0.85
opt_py_to_timestampFunction · 0.85
buildMethod · 0.45
attributesMethod · 0.45
scope_typeMethod · 0.45
nameMethod · 0.45