Skip to content

get_cards(pathspec_string) silently resets the global client namespace to None #3395

Open

Description

@devteamaegis

metaflow.cards.get_cards() calls namespace(None) when it's given a task pathspec string (metaflow/plugins/cards/card_client.py, in get_cards). The call is global and never undone, so after get_cards("MyFlow/123/start/4") the caller's namespace is None. Every later client query in that notebook or script (Flow(...).latest_run, .runs(), Run(...)) then returns objects from all namespaces instead of the one the user picked.

Repro (local metadata/datastore), after running any flow with a @card step as another user:

from metaflow import Flow, namespace, get_namespace
from metaflow.cards import get_cards

namespace("user:someone-else")
get_cards("CardNsFlow/<run_id>/start/1")   # run owned by another user
print(get_namespace())                     # -> None (expected "user:someone-else")
print(Flow("CardNsFlow").latest_run)       # -> Run(...) instead of MetaflowNamespaceMismatch

Expected: get_cards finds the card but leaves the caller's namespace unchanged.

Proposed fix: replace the global namespace(None) with Task(task_str, _namespace_check=False), and pass _namespace_check=False on the two origin-task lookups used for resumed runs (get_cards and card_resolver._chase_origin). Those two lookups currently depend on the global None. This matches how Task.metadata already follows origin tasks. I have a small fix with a regression test and will link a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions