Skip to content

Commit

Permalink
Namespace check skip feature from #1271 (#1341)
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-intel authored Apr 3, 2023
1 parent 42f8d37 commit b27f64c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions metaflow/client/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def __init__(
self._parent = _parent
self._path_components = None
self._attempt = attempt
self._namespace_check = _namespace_check

if self._attempt is not None:
if self._NAME not in ["task", "artifact"]:
Expand Down Expand Up @@ -315,7 +316,7 @@ def __init__(
self._user_tags = frozenset(self._object.get("tags") or [])
self._system_tags = frozenset(self._object.get("system_tags") or [])

if _namespace_check and not self.is_in_namespace():
if self._namespace_check and not self.is_in_namespace():
raise MetaflowNamespaceMismatch(current_namespace)

def _get_object(self, *path_components):
Expand All @@ -330,15 +331,17 @@ def __iter__(self) -> Iterable["MetaflowObject"]:
"""
Iterate over all child objects of this object if any.
Note that only children present in the current namespace are returned.
Note that only children present in the current namespace are returned iff
_namespace_check is set.
Returns
-------
Iterable[MetaflowObject]
Iterator over all children
"""
query_filter = {}
if current_namespace:
# skip namespace filtering if _namespace_check is False
if self._namespace_check and current_namespace:
query_filter = {"any_tags": current_namespace}

unfiltered_children = self._metaflow.metadata.get_object(
Expand Down Expand Up @@ -444,7 +447,10 @@ def __getitem__(self, id: str) -> "MetaflowObject":
obj = self._get_child(id)
if obj:
return _CLASSES[self._CHILD_CLASS](
attempt=self._attempt, _object=obj, _parent=self
attempt=self._attempt,
_object=obj,
_parent=self,
_namespace_check=self._namespace_check,
)
else:
raise KeyError(id)
Expand Down

0 comments on commit b27f64c

Please sign in to comment.