Skip to content

Commit 585997a

Browse files
authored
Amended config changes to address to run uvicorn (#63)
1 parent 4f3cae3 commit 585997a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/aali/flowkit/__main__.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@
3434
def parse_cli_args():
3535
"""Parse the command line arguments."""
3636
parser = argparse.ArgumentParser()
37-
parser.add_argument("--host", type=str, required=False, help="The host to run the service on. By default 0.0.0.0")
38-
parser.add_argument("--port", type=int, required=False, help="The port to run the service on. By default 50052")
39-
parser.add_argument("--workers", type=int, required=False, help="The number of workers to use. By default 4")
40-
parser.add_argument("--use-ssl", required=False, help="Enable SSL for the service. By default False")
37+
parser.add_argument(
38+
"--host", type=str, required=False, default="0.0.0.0", help="The host to run the service on. By default 0.0.0.0"
39+
)
40+
parser.add_argument(
41+
"--port", type=int, required=False, default="50052", help="The port to run the service on. By default 50052"
42+
)
43+
parser.add_argument(
44+
"--workers", type=int, required=False, default="4", help="The number of workers to use. By default 4"
45+
)
46+
parser.add_argument("--use-ssl", required=False, default=False, help="Enable SSL for the service. By default False")
4147
parser.add_argument("--ssl-keyfile", type=str, required=False, help="The SSL key file path")
4248
parser.add_argument("--ssl-certfile", type=str, required=False, help="The SSL certificate file path")
4349
args, _ = parser.parse_known_args()
@@ -46,9 +52,9 @@ def parse_cli_args():
4652

4753
def handle_legacy_port_config():
4854
"""Handle legacy port configuration."""
49-
if CONFIG.flowkit_python_address != "":
55+
if CONFIG.flowkit_python_address != "" or CONFIG.flowkit_python_address:
5056
return CONFIG.flowkit_python_address
51-
if CONFIG.flowkit_python_endpoint != "":
57+
if CONFIG.flowkit_python_endpoint != "" or CONFIG.flowkit_python_endpoint:
5258
return CONFIG.flowkit_python_endpoint
5359

5460

@@ -58,7 +64,7 @@ def substitute_empty_values(args):
5864
f"{args.host}:{args.port}" if args.host is not None and args.port is not None else CONFIG.flowkit_python_address
5965
)
6066
CONFIG.flowkit_python_workers = args.workers or CONFIG.flowkit_python_workers
61-
CONFIG.use_ssl = (args.use_ssl.lower() == "true") if args.use_ssl is not None else CONFIG.use_ssl
67+
CONFIG.use_ssl = args.use_ssl or CONFIG.use_ssl
6268
CONFIG.ssl_cert_private_key_file = args.ssl_keyfile or CONFIG.ssl_cert_private_key_file
6369
CONFIG.ssl_cert_public_key_file = args.ssl_certfile or CONFIG.ssl_cert_public_key_file
6470
return
@@ -74,11 +80,11 @@ def main():
7480
substitute_empty_values(args)
7581

7682
address = handle_legacy_port_config()
77-
# Add scheme if missing
83+
# # Add scheme if missing
7884
if not address.startswith(("http://", "https://")):
7985
address = "http://" + address
80-
host = urlparse(address).hostname
81-
port = urlparse(address).port
86+
host = urlparse(address).hostname or args.host
87+
port = urlparse(address).port or args.port
8288

8389
# Run the service
8490
uvicorn.run(

0 commit comments

Comments
 (0)