Skip to content

Commit

Permalink
DATA-1813 Add method to get fromDataManagement value from extra map i…
Browse files Browse the repository at this point in the history
…n python SDK (#416)
  • Loading branch information
kaywux authored Aug 31, 2023
1 parent 93293e0 commit 04b5868
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/viam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,12 @@ async def to_thread(func: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs)
ctx = contextvars.copy_context()
func_call = functools.partial(ctx.run, func, *args, **kwargs)
return await loop.run_in_executor(None, func_call) # type: ignore


def from_dm_from_extra(extra: Optional[Dict[str, Any]]) -> bool:
"""Used in modular filter components to get the 'fromDataManagement' value from an extra map.
"""
if extra is None:
return False

return bool(extra["fromDataManagement"])

0 comments on commit 04b5868

Please sign in to comment.