Skip to content

Commit 18f312e

Browse files
Add default values to CLI callback (#349)
* Add default values to CLI callback * Remove try/except when launching jupyverse
1 parent 30479a9 commit 18f312e

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

jupyverse_api/jupyverse_api/cli.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pkg_resources
2-
from typing import List
2+
from typing import List, Tuple
33

44
import rich_click as click
55
from asphalt.core.cli import run
@@ -45,31 +45,31 @@
4545
help="Disable plugin.",
4646
)
4747
def main(
48-
open_browser: bool,
49-
host: str,
50-
port: int,
51-
set_: List[str],
52-
disable: List[str],
53-
allow_origin: List[str],
48+
open_browser: bool = False,
49+
host: str = "127.0.0.1",
50+
port: int = 8000,
51+
set_: Tuple[str, ...] = (),
52+
disable: Tuple[str, ...] = (),
53+
allow_origin: Tuple[str, ...] = (),
5454
) -> None:
55-
set_ = list(set_)
56-
for i, s in enumerate(set_):
57-
set_[i] = f"component.components.{s}"
58-
set_.append(f"component.open_browser={open_browser}")
59-
set_.append(f"component.host={host}")
60-
set_.append(f"component.port={port}")
61-
set_.append(f"component.allow_origin={allow_origin}")
55+
set_list: List[str] = list(set_)
56+
for i, s in enumerate(set_list):
57+
set_list[i] = f"component.components.{s}"
58+
set_list.append(f"component.open_browser={open_browser}")
59+
set_list.append(f"component.host={host}")
60+
set_list.append(f"component.port={port}")
61+
set_list.append(f"component.allow_origin={allow_origin}")
6262
config = get_config(disable)
6363
run.callback(
6464
unsafe=False,
6565
loop=None,
66-
set_=set_,
66+
set_=set_list,
6767
service=None,
6868
configfile=[config],
6969
) # type: ignore
7070

7171

72-
def get_config(disable: List[str]) -> str:
72+
def get_config(disable: Tuple[str, ...]) -> str:
7373
jupyverse_components = [
7474
ep.name
7575
for ep in pkg_resources.iter_entry_points(group="jupyverse.components")

jupyverse_api/jupyverse_api/main/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(
4040
app: FastAPI | str | None = None,
4141
host: str = "127.0.0.1",
4242
port: int = 8000,
43-
allow_origin: Tuple = (),
43+
allow_origin: Tuple[str, ...] = (),
4444
open_browser: bool = False,
4545
query_params: Dict[str, Any] | None = None,
4646
debug: bool | None = None,

plugins/auth_jupyterhub/fps_auth_jupyterhub/launch.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
def launch():
88
service_url = unquote(os.environ.get("JUPYTERHUB_SERVICE_URL"))
99
url = urlparse(service_url)
10-
try:
11-
return main.callback(
12-
open_browser=True,
13-
host=url.hostname,
14-
port=url.port,
15-
set_=[
16-
f"frontend.base_url={url.path}",
17-
f"app.mount_path={url.path}",
18-
],
19-
disable=[],
20-
)
21-
except Exception:
22-
return
10+
return main.callback(
11+
open_browser=True,
12+
host=url.hostname,
13+
port=url.port,
14+
set_=(
15+
f"frontend.base_url={url.path}",
16+
f"app.mount_path={url.path}",
17+
),
18+
disable=[],
19+
)

0 commit comments

Comments
 (0)