This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
forked from dandi/dandi-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dandi#804 from dandi/public-instance
Make `--dandi-instance` public and add "instances" command
- Loading branch information
Showing
10 changed files
with
101 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sys | ||
|
||
import click | ||
import ruamel.yaml | ||
|
||
from .base import map_to_click_exceptions | ||
from ..consts import known_instances | ||
|
||
|
||
@click.command() | ||
@map_to_click_exceptions | ||
def instances(): | ||
"""List known Dandi Archive instances that the CLI can interact with""" | ||
yaml = ruamel.yaml.YAML(typ="safe") | ||
yaml.default_flow_style = False | ||
# Convert _asdict() with dict() so that ruamel doesn't tag the results with | ||
# "!!omap" on Python 3.7 | ||
yaml.dump({k: dict(v._asdict()) for k, v in known_instances.items()}, sys.stdout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
|
||
from click.testing import CliRunner | ||
|
||
from ..command import instances | ||
|
||
|
||
def test_cmd_instances(monkeypatch): | ||
redirector_base = os.environ.get( | ||
"DANDI_REDIRECTOR_BASE", "https://dandiarchive.org" | ||
) | ||
instancehost = os.environ.get("DANDI_INSTANCEHOST", "localhost") | ||
r = CliRunner().invoke(instances, []) | ||
assert r.exit_code == 0 | ||
assert r.output == ( | ||
"dandi:\n" | ||
" api: https://api.dandiarchive.org/api\n" | ||
" gui: https://gui.dandiarchive.org\n" | ||
f" redirector: {redirector_base}\n" | ||
"dandi-api-local-docker-tests:\n" | ||
f" api: http://{instancehost}:8000/api\n" | ||
" gui: null\n" | ||
" redirector: null\n" | ||
"dandi-devel:\n" | ||
" api: null\n" | ||
" gui: https://gui-beta-dandiarchive-org.netlify.app\n" | ||
" redirector: null\n" | ||
"dandi-staging:\n" | ||
" api: https://api-staging.dandiarchive.org/api\n" | ||
" gui: https://gui-staging.dandiarchive.org\n" | ||
" redirector: null\n" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
:program:`dandi instances` | ||
========================== | ||
|
||
:: | ||
|
||
dandi [<global options>] instances | ||
|
||
List known Dandi Archive instances that can be passed to the | ||
``-i``/``--dandi-instance`` option of other subcommands for the CLI to | ||
interact with. Output is in YAML. | ||
|
||
Example output: | ||
|
||
.. code:: yaml | ||
dandi: | ||
api: https://api.dandiarchive.org/api | ||
gui: https://gui.dandiarchive.org | ||
redirector: https://dandiarchive.org | ||
dandi-api-local-docker-tests: | ||
api: http://localhost:8000/api | ||
gui: null | ||
redirector: null | ||
dandi-devel: | ||
api: null | ||
gui: https://gui-beta-dandiarchive-org.netlify.app | ||
redirector: null | ||
dandi-staging: | ||
api: https://api-staging.dandiarchive.org/api | ||
gui: https://gui-staging.dandiarchive.org | ||
redirector: null |