Skip to content

Commit

Permalink
Add default values to CLI callback
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Sep 6, 2023
1 parent 30479a9 commit b86dfc7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions jupyverse_api/jupyverse_api/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pkg_resources
from typing import List
from typing import List, Tuple

import rich_click as click
from asphalt.core.cli import run
Expand Down Expand Up @@ -45,31 +45,31 @@
help="Disable plugin.",
)
def main(
open_browser: bool,
host: str,
port: int,
set_: List[str],
disable: List[str],
allow_origin: List[str],
open_browser: bool = False,
host: str = "127.0.0.1",
port: int = 8000,
set_: Tuple[str, ...] = (),
disable: Tuple[str, ...] = (),
allow_origin: Tuple[str, ...] = (),
) -> None:
set_ = list(set_)
for i, s in enumerate(set_):
set_[i] = f"component.components.{s}"
set_.append(f"component.open_browser={open_browser}")
set_.append(f"component.host={host}")
set_.append(f"component.port={port}")
set_.append(f"component.allow_origin={allow_origin}")
set_list: List[str] = list(set_)
for i, s in enumerate(set_list):
set_list[i] = f"component.components.{s}"
set_list.append(f"component.open_browser={open_browser}")
set_list.append(f"component.host={host}")
set_list.append(f"component.port={port}")
set_list.append(f"component.allow_origin={allow_origin}")
config = get_config(disable)
run.callback(
unsafe=False,
loop=None,
set_=set_,
set_=set_list,
service=None,
configfile=[config],
) # type: ignore


def get_config(disable: List[str]) -> str:
def get_config(disable: Tuple[str, ...]) -> str:
jupyverse_components = [
ep.name
for ep in pkg_resources.iter_entry_points(group="jupyverse.components")
Expand Down
2 changes: 1 addition & 1 deletion jupyverse_api/jupyverse_api/main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
app: FastAPI | str | None = None,
host: str = "127.0.0.1",
port: int = 8000,
allow_origin: Tuple = (),
allow_origin: Tuple[str, ...] = (),
open_browser: bool = False,
query_params: Dict[str, Any] | None = None,
debug: bool | None = None,
Expand Down
4 changes: 2 additions & 2 deletions plugins/auth_jupyterhub/fps_auth_jupyterhub/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def launch():
open_browser=True,
host=url.hostname,
port=url.port,
set_=[
set_=(
f"frontend.base_url={url.path}",
f"app.mount_path={url.path}",
],
),
disable=[],
)
except Exception:
Expand Down

0 comments on commit b86dfc7

Please sign in to comment.