Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default values to CLI callback #349

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 10 additions & 13 deletions plugins/auth_jupyterhub/fps_auth_jupyterhub/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
def launch():
service_url = unquote(os.environ.get("JUPYTERHUB_SERVICE_URL"))
url = urlparse(service_url)
try:
return main.callback(
open_browser=True,
host=url.hostname,
port=url.port,
set_=[
f"frontend.base_url={url.path}",
f"app.mount_path={url.path}",
],
disable=[],
)
except Exception:
return
return main.callback(
open_browser=True,
host=url.hostname,
port=url.port,
set_=(
f"frontend.base_url={url.path}",
f"app.mount_path={url.path}",
),
disable=[],
)
Loading