From 548aa790e99b9d1cb53102b854e37e10baa63c2e Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 28 Aug 2023 19:12:16 +0530 Subject: [PATCH] dynammic port for gradio --- jhub_apps/examples/gradio_basic.py | 9 ++++----- jhub_apps/spawner/command.py | 2 +- jhub_apps/spawner/spawner.py | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jhub_apps/examples/gradio_basic.py b/jhub_apps/examples/gradio_basic.py index b711e860..4bbe7b74 100644 --- a/jhub_apps/examples/gradio_basic.py +++ b/jhub_apps/examples/gradio_basic.py @@ -10,11 +10,10 @@ def greet(name): parser = argparse.ArgumentParser(description="Process CLI args for gradio") -parser.add_argument("--server-port", type=str, help="server_port for gradio app", default=8500) +parser.add_argument( + "--server-port", type=str, help="server_port for gradio app", default=8500 +) parser.add_argument("--root-path", type=str, help="root_path for gradio", default=None) cli_args = parser.parse_args() -demo.launch( - server_port=8500, - root_path=cli_args.root_path -) +demo.launch(server_port=int(cli_args.server_port), root_path=cli_args.root_path) diff --git a/jhub_apps/spawner/command.py b/jhub_apps/spawner/command.py index 48634c9b..3197fae4 100644 --- a/jhub_apps/spawner/command.py +++ b/jhub_apps/spawner/command.py @@ -19,7 +19,7 @@ COMMANDS = { "gradio": { "args": [ - "--destport=8500", + "--destport=0", "python", f'{EXAMPLES_PATH.get("gradio")}', ], diff --git a/jhub_apps/spawner/spawner.py b/jhub_apps/spawner/spawner.py index b075f4d2..56746768 100644 --- a/jhub_apps/spawner/spawner.py +++ b/jhub_apps/spawner/spawner.py @@ -28,6 +28,7 @@ def get_args(self): argv.append(base_url_param) if framework == "gradio": args = [ + "{--}server-port={port}", "{--}root-path=" + jh_service_prefix, "--ready-check-path=/", ]