diff --git a/lincbrain/move.py b/lincbrain/move.py index 9996212bb..fb40d34e2 100644 --- a/lincbrain/move.py +++ b/lincbrain/move.py @@ -801,6 +801,10 @@ def move( if dandiset is None: dandiset = Path() with ExitStack() as stack: + client = DandiAPIClient.for_dandi_instance(dandi_instance) + client.dandi_authenticate() + stack.enter_context(client) + mover: Mover client: DandiAPIClient | None = None if work_on is MoveWorkOn.AUTO: @@ -811,8 +815,6 @@ def move( if isinstance(dandiset, str): raise TypeError("`dandiset` must be a Path when work_on='both'") local_ds, subpath = find_dandiset_and_subpath(dandiset) - client = DandiAPIClient.for_dandi_instance(dandi_instance) - stack.enter_context(client) remote_ds = client.get_dandiset( local_ds.identifier, version_id="draft", lazy=False ) @@ -833,6 +835,7 @@ def move( if not isinstance(url, DandisetURL): raise ValueError("URL does not point to a Dandiset") client = url.get_client() + client.dandi_authenticate() stack.enter_context(client) rds = url.get_dandiset(client, lazy=False) assert rds is not None @@ -840,8 +843,6 @@ def move( subpath = Path() else: local_ds, subpath = find_dandiset_and_subpath(dandiset) - client = DandiAPIClient.for_dandi_instance(dandi_instance) - stack.enter_context(client) remote_ds = client.get_dandiset( local_ds.identifier, version_id="draft", lazy=False )