From 1d5db727c2b134fd1c1fd9d09b4672027a3084c8 Mon Sep 17 00:00:00 2001 From: Aaron Kanzer Date: Mon, 12 Feb 2024 15:55:26 -0500 Subject: [PATCH] Update DANDI_API_KEY to LINCBRAIN_API_KEY --- DEVELOPMENT.md | 2 +- lincbrain/cli/tests/test_service_scripts.py | 4 +- lincbrain/dandiapi.py | 6 +- lincbrain/tests/fixtures.py | 2 +- lincbrain/tests/test_dandiapi.py | 6 +- lincbrain/tests/test_delete.py | 30 ++++----- lincbrain/tests/test_keyring.py | 2 +- lincbrain/tests/test_move.py | 68 ++++++++++----------- tools/update-assets-on-server | 2 +- 9 files changed, 61 insertions(+), 61 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 293586ae3..dfda31b2e 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -55,7 +55,7 @@ development command line options. otherwise be hidden from the user-visible (`--help`) interface, unless this env variable is set to a non-empty value -- `DANDI_API_KEY` -- avoids using keyrings, thus making it possible to +- `LINCBRAIN_API_KEY` -- avoids using keyrings, thus making it possible to "temporarily" use another account etc for the "API" version of the server. - `DANDI_LOG_LEVEL` -- set log level. By default `INFO`, should be an int (`10` - `DEBUG`). diff --git a/lincbrain/cli/tests/test_service_scripts.py b/lincbrain/cli/tests/test_service_scripts.py index d779baea4..a76d84a93 100644 --- a/lincbrain/cli/tests/test_service_scripts.py +++ b/lincbrain/cli/tests/test_service_scripts.py @@ -28,7 +28,7 @@ def test_reextract_metadata( asset_id = nwb_dandiset.dandiset.get_asset_by_path( "sub-mouse001/sub-mouse001.nwb" ).identifier - monkeypatch.setenv("DANDI_API_KEY", nwb_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", nwb_dandiset.api.api_key) r = CliRunner().invoke( service_scripts, ["reextract-metadata", "--when=always", nwb_dandiset.dandiset.version_api_url], @@ -71,7 +71,7 @@ def test_update_dandiset_from_doi( ) -> None: dandiset_id = new_dandiset.dandiset_id repository = new_dandiset.api.instance.gui - monkeypatch.setenv("DANDI_API_KEY", new_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", new_dandiset.api.api_key) if os.environ.get("DANDI_TESTS_NO_VCR", ""): ctx = nullcontext() else: diff --git a/lincbrain/dandiapi.py b/lincbrain/dandiapi.py index 314306f69..4f60d57c7 100644 --- a/lincbrain/dandiapi.py +++ b/lincbrain/dandiapi.py @@ -477,7 +477,7 @@ def authenticate(self, token: str, save_to_keyring: bool = False) -> None: def dandi_authenticate(self) -> None: """ Acquire and set the authentication token/API key used by the - `DandiAPIClient`. If the :envvar:`DANDI_API_KEY` environment variable + `DandiAPIClient`. If the :envvar:`LINCBRAIN_API_KEY` environment variable is set, its value is used as the token. Otherwise, the token is looked up in the user's keyring under the service ":samp:`dandi-api-{INSTANCE_NAME}`" [#auth]_ and username "``key``". @@ -488,9 +488,9 @@ def dandi_authenticate(self) -> None: "``dandi-api-dandi-staging``" for the staging server """ # Shortcut for advanced folks - api_key = os.environ.get("DANDI_API_KEY", None) + api_key = os.environ.get("LINCBRAIN_API_KEY", None) if api_key: - lgr.debug("Using api key from DANDI_API_KEY environment variable") + lgr.debug("Using api key from LINCBRAIN_API_KEY environment variable") self.authenticate(api_key) return client_name, app_id = self._get_keyring_ids() diff --git a/lincbrain/tests/fixtures.py b/lincbrain/tests/fixtures.py index dce8e1fed..308b98c93 100644 --- a/lincbrain/tests/fixtures.py +++ b/lincbrain/tests/fixtures.py @@ -505,7 +505,7 @@ def client(self) -> DandiAPIClient: def upload(self, paths: list[str | Path] | None = None, **kwargs: Any) -> None: with pytest.MonkeyPatch().context() as m: - m.setenv("DANDI_API_KEY", self.api.api_key) + m.setenv("LINCBRAIN_API_KEY", self.api.api_key) upload( paths=paths or [self.dspath], dandi_instance=self.api.instance_id, diff --git a/lincbrain/tests/test_dandiapi.py b/lincbrain/tests/test_dandiapi.py index 6c3f5f8f8..226928f9f 100644 --- a/lincbrain/tests/test_dandiapi.py +++ b/lincbrain/tests/test_dandiapi.py @@ -131,7 +131,7 @@ def test_authenticate_bad_key_good_key_input( ) confirm_mock = mocker.patch("click.confirm", return_value=True) - monkeypatch.delenv("DANDI_API_KEY", raising=False) + monkeypatch.delenv("LINCBRAIN_API_KEY", raising=False) client = DandiAPIClient(local_dandi_api.api_url) assert "Authorization" not in client.session.headers @@ -162,7 +162,7 @@ def test_authenticate_good_key_keyring( is_interactive_spy = mocker.spy(dandiapi, "is_interactive") confirm_spy = mocker.spy(click, "confirm") - monkeypatch.delenv("DANDI_API_KEY", raising=False) + monkeypatch.delenv("LINCBRAIN_API_KEY", raising=False) client = DandiAPIClient(local_dandi_api.api_url) assert "Authorization" not in client.session.headers @@ -194,7 +194,7 @@ def test_authenticate_bad_key_keyring_good_key_input( ) confirm_mock = mocker.patch("click.confirm", return_value=True) - monkeypatch.delenv("DANDI_API_KEY", raising=False) + monkeypatch.delenv("LINCBRAIN_API_KEY", raising=False) client = DandiAPIClient(local_dandi_api.api_url) assert "Authorization" not in client.session.headers diff --git a/lincbrain/tests/test_delete.py b/lincbrain/tests/test_delete.py index 310b1205e..8e64f7f13 100644 --- a/lincbrain/tests/test_delete.py +++ b/lincbrain/tests/test_delete.py @@ -67,7 +67,7 @@ def test_delete_paths( remainder: list[Path], ) -> None: monkeypatch.chdir(text_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") @@ -92,7 +92,7 @@ def test_delete_path_confirm( text_dandiset: SampleDandiset, ) -> None: monkeypatch.chdir(text_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") @@ -113,7 +113,7 @@ def test_delete_path_pyout( text_dandiset: SampleDandiset, ) -> None: monkeypatch.chdir(text_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") delete(["subdir2/coconut.txt"], dandi_instance=instance, force=True) @@ -143,7 +143,7 @@ def test_delete_dandiset( paths: list[str], ) -> None: monkeypatch.chdir(text_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") @@ -166,7 +166,7 @@ def test_delete_dandiset_confirm( text_dandiset: SampleDandiset, ) -> None: monkeypatch.chdir(text_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") @@ -187,7 +187,7 @@ def test_delete_dandiset_mismatch( text_dandiset: SampleDandiset, ) -> None: monkeypatch.chdir(text_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id not_dandiset = str(int(dandiset_id) - 1).zfill(6) @@ -216,7 +216,7 @@ def test_delete_instance_mismatch( text_dandiset: SampleDandiset, ) -> None: monkeypatch.chdir(text_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") @@ -242,7 +242,7 @@ def test_delete_instance_mismatch( def test_delete_nonexistent_dandiset( local_dandi_api: DandiAPI, mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch ) -> None: - monkeypatch.setenv("DANDI_API_KEY", local_dandi_api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", local_dandi_api.api_key) instance = local_dandi_api.instance_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") with pytest.raises(NotFoundError) as excinfo: @@ -259,7 +259,7 @@ def test_delete_nonexistent_dandiset( def test_delete_nonexistent_dandiset_skip_missing( local_dandi_api: DandiAPI, mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch ) -> None: - monkeypatch.setenv("DANDI_API_KEY", local_dandi_api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", local_dandi_api.api_key) instance = local_dandi_api.instance_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") delete( @@ -277,7 +277,7 @@ def test_delete_nonexistent_asset( monkeypatch: pytest.MonkeyPatch, text_dandiset: SampleDandiset, ) -> None: - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") @@ -304,7 +304,7 @@ def test_delete_nonexistent_asset_skip_missing( text_dandiset: SampleDandiset, tmp_path: Path, ) -> None: - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") @@ -333,7 +333,7 @@ def test_delete_nonexistent_asset_folder( monkeypatch: pytest.MonkeyPatch, text_dandiset: SampleDandiset, ) -> None: - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") @@ -360,7 +360,7 @@ def test_delete_nonexistent_asset_folder_skip_missing( text_dandiset: SampleDandiset, tmp_path: Path, ) -> None: - monkeypatch.setenv("DANDI_API_KEY", text_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", text_dandiset.api.api_key) instance = text_dandiset.api.instance_id dandiset_id = text_dandiset.dandiset_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") @@ -387,7 +387,7 @@ def test_delete_nonexistent_asset_folder_skip_missing( def test_delete_version( local_dandi_api: DandiAPI, mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch ) -> None: - monkeypatch.setenv("DANDI_API_KEY", local_dandi_api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", local_dandi_api.api_key) instance = local_dandi_api.instance_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") with pytest.raises(NotImplementedError) as excinfo: @@ -430,7 +430,7 @@ def test_delete_zarr_path( tmp_path: Path, ) -> None: monkeypatch.chdir(zarr_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", zarr_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", zarr_dandiset.api.api_key) instance = zarr_dandiset.api.instance_id delete_spy = mocker.spy(RESTFullAPIClient, "delete") delete(["sample.zarr"], dandi_instance=instance, devel_debug=True, force=True) diff --git a/lincbrain/tests/test_keyring.py b/lincbrain/tests/test_keyring.py index c2568bfca..3d54cae48 100644 --- a/lincbrain/tests/test_keyring.py +++ b/lincbrain/tests/test_keyring.py @@ -29,7 +29,7 @@ def ensure_keyring_backends() -> None: def test_dandi_authenticate_no_env_var( local_dandi_api: DandiAPI, monkeypatch: pytest.MonkeyPatch, mocker: MockerFixture ) -> None: - monkeypatch.delenv("DANDI_API_KEY", raising=False) + monkeypatch.delenv("LINCBRAIN_API_KEY", raising=False) monkeypatch.setenv("PYTHON_KEYRING_BACKEND", "keyring.backends.null.Keyring") inputmock = mocker.patch( "lincbrain.dandiapi.input", return_value=local_dandi_api.api_key diff --git a/lincbrain/tests/test_move.py b/lincbrain/tests/test_move.py index 3f1eb5e0d..e568328e7 100644 --- a/lincbrain/tests/test_move.py +++ b/lincbrain/tests/test_move.py @@ -172,7 +172,7 @@ def test_move( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( *srcs, dest=dest, @@ -194,7 +194,7 @@ def test_move_skip( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "file.txt", "subdir4/foo.json", @@ -221,7 +221,7 @@ def test_move_error( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( "file.txt", @@ -248,7 +248,7 @@ def test_move_overwrite( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "file.txt", "subdir4/foo.json", @@ -275,7 +275,7 @@ def test_move_no_srcs( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( dest="nowhere", @@ -291,7 +291,7 @@ def test_move_regex_multisrcs( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( r"\.txt", @@ -317,7 +317,7 @@ def test_move_multisrcs_file_dest( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( "file.txt", @@ -343,7 +343,7 @@ def test_move_folder_src_file_dest( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( "subdir1", @@ -365,7 +365,7 @@ def test_move_nonexistent_src( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(NotFoundError) as excinfo: move( "file.txt", @@ -391,7 +391,7 @@ def test_move_file_slash_src( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( "file.txt", @@ -417,7 +417,7 @@ def test_move_file_slash_dest( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( "file.txt", @@ -437,7 +437,7 @@ def test_move_regex_no_match( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( "no-match", @@ -458,7 +458,7 @@ def test_move_regex_collision( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( r"^\w+/foo\.json$", @@ -486,7 +486,7 @@ def test_move_regex_some_to_self( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( r"(.+[123])/([^.]+)\.(.+)", dest=r"\1/\2.dat", @@ -528,7 +528,7 @@ def test_move_from_subdir( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath / "subdir1") - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "../file.txt", "apple.txt", @@ -558,7 +558,7 @@ def test_move_in_subdir( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath / "subdir1") - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "apple.txt", dest="macintosh.txt", @@ -584,7 +584,7 @@ def test_move_from_subdir_abspaths( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath / "subdir1") - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(NotFoundError) as excinfo: move( "file.txt", @@ -610,7 +610,7 @@ def test_move_from_subdir_as_dot( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath / "subdir1") - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(ValueError) as excinfo: move( ".", @@ -633,7 +633,7 @@ def test_move_from_subdir_regex( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath / "subdir1") - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( r"\.txt", dest=".dat", @@ -661,7 +661,7 @@ def test_move_from_subdir_regex_no_changes( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath / "subdir1") - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( r"\.txt", dest=".txt", @@ -685,7 +685,7 @@ def test_move_dandiset_path( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(tmp_path) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "file.txt", "subdir2/banana.txt", @@ -715,7 +715,7 @@ def test_move_dandiset_url( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(tmp_path) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "file.txt", "subdir2/banana.txt", @@ -740,7 +740,7 @@ def test_move_work_on_auto( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "file.txt", "subdir2/banana.txt", @@ -777,7 +777,7 @@ def test_move_local_delete_empty_dirs( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath / "subdir4") - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "../subdir1/apple.txt", "../subdir2/banana.txt", @@ -807,7 +807,7 @@ def test_move_both_src_path_not_in_local( (moving_dandiset.dspath / "subdir2" / "banana.txt").unlink() starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(AssetMismatchError) as excinfo: move( "subdir2", @@ -832,7 +832,7 @@ def test_move_both_src_path_not_in_remote( (moving_dandiset.dspath / "subdir2" / "mango.txt").write_text("Mango\n") starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(AssetMismatchError) as excinfo: move( "subdir2", @@ -857,7 +857,7 @@ def test_move_both_dest_path_not_in_remote( (moving_dandiset.dspath / "subdir2" / "file.txt").write_text("This is a file.\n") starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(AssetMismatchError) as excinfo: move( "file.txt", @@ -884,7 +884,7 @@ def test_move_both_dest_path_not_in_local( (moving_dandiset.dspath / "subdir2" / "banana.txt").unlink() starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(AssetMismatchError) as excinfo: move( "file.txt", @@ -913,7 +913,7 @@ def test_move_both_dest_mismatch( (moving_dandiset.dspath / "subdir1" / "apple.txt" / "seeds").write_text("12345\n") starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) with pytest.raises(AssetMismatchError) as excinfo: move( "file.txt", @@ -943,7 +943,7 @@ def test_move_pyout( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "file.txt", "subdir4/foo.json", @@ -975,7 +975,7 @@ def test_move_pyout_dry_run( ) -> None: starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "file.txt", "subdir4/foo.json", @@ -1001,7 +1001,7 @@ def test_move_path_to_self( (moving_dandiset.dspath / "newdir").mkdir() starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath / "subdir1") - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "apple.txt", dest="../subdir1", @@ -1029,7 +1029,7 @@ def test_move_remote_dest_is_local_dir_sans_slash( (moving_dandiset.dspath / "newdir").mkdir() starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "file.txt", dest="newdir", @@ -1048,7 +1048,7 @@ def test_move_both_dest_is_local_dir_sans_slash( (moving_dandiset.dspath / "newdir").mkdir() starting_assets = list(moving_dandiset.dandiset.get_assets()) monkeypatch.chdir(moving_dandiset.dspath) - monkeypatch.setenv("DANDI_API_KEY", moving_dandiset.api.api_key) + monkeypatch.setenv("LINCBRAIN_API_KEY", moving_dandiset.api.api_key) move( "file.txt", dest="newdir", diff --git a/tools/update-assets-on-server b/tools/update-assets-on-server index 1bbeb190a..1fd4a28f6 100755 --- a/tools/update-assets-on-server +++ b/tools/update-assets-on-server @@ -59,7 +59,7 @@ def get_meta(path, digest=None): "-a", "--api_key", type=str, - default=os.environ.get("DANDI_API_KEY", ""), + default=os.environ.get("LINCBRAIN_API_KEY", ""), help="API key to use", ) def process_dandiset(dandiset, update, api_key):