Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace check skip feature from #1271 #1341

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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