Skip to content

Commit

Permalink
Support None services in server-info
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Apr 14, 2021
1 parent d859b47 commit 64e4f8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dandi/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def test_get_instance_dandi():
"services": {
"girder": {"url": "https://girder.dandi"},
"webui": {"url": "https://gui.dandi"},
"api": None,
"jupyterhub": {"url": "https://hub.dandi"},
},
},
Expand All @@ -191,6 +192,7 @@ def test_get_instance_dandi_with_api():
"cli-minimal-version": "0.5.0",
"cli-bad-versions": [],
"services": {
"girder": None,
"webui": {"url": "https://gui.dandi"},
"api": {"url": "https://api.dandi"},
"jupyterhub": {"url": "https://hub.dandi"},
Expand Down Expand Up @@ -218,6 +220,7 @@ def test_get_instance_url():
"services": {
"girder": {"url": "https://girder.dandi"},
"webui": {"url": "https://gui.dandi"},
"api": None,
"jupyterhub": {"url": "https://hub.dandi"},
},
},
Expand All @@ -243,6 +246,7 @@ def test_get_instance_cli_version_too_old():
"services": {
"girder": {"url": "https://girder.dandi"},
"webui": {"url": "https://gui.dandi"},
"api": None,
"jupyterhub": {"url": "https://hub.dandi"},
},
},
Expand All @@ -267,6 +271,7 @@ def test_get_instance_bad_cli_version():
"services": {
"girder": {"url": "https://girder.dandi"},
"webui": {"url": "https://gui.dandi"},
"api": None,
"jupyterhub": {"url": "https://hub.dandi"},
},
},
Expand Down Expand Up @@ -333,6 +338,7 @@ def test_get_instance_bad_version_from_server():
"services": {
"girder": {"url": "https://girder.dandi"},
"webui": {"url": "https://gui.dandi"},
"api": None,
"jupyterhub": {"url": "https://hub.dandi"},
},
},
Expand Down
6 changes: 3 additions & 3 deletions dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,15 +618,15 @@ def get_instance(dandi_instance_id):
raise CliVersionTooOldError(our_version, minversion, bad_versions)
if our_version in bad_versions:
raise BadCliVersionError(our_version, minversion, bad_versions)
if "girder" in server_info["services"]:
if server_info["services"].get("girder"):
return dandi_instance(
metadata_version=0,
girder=server_info["services"]["girder"]["url"],
gui=server_info["services"]["webui"]["url"],
redirector=redirector_url,
api=None,
)
elif "api" in server_info["services"]:
elif server_info["services"].get("api"):
return dandi_instance(
metadata_version=1,
girder=None,
Expand All @@ -637,7 +637,7 @@ def get_instance(dandi_instance_id):
else:
raise RuntimeError(
"redirector's server-info returned unknown set of services keys: "
+ ", ".join(server_info["services"].keys())
+ ", ".join(k for k, v in server_info["services"].items() if v is not None)
)


Expand Down

0 comments on commit 64e4f8e

Please sign in to comment.