Skip to content

Commit 4f3cae3

Browse files
add webserver address definition (#62)
1 parent 52d1e71 commit 4f3cae3

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

configs/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FLOWKIT_PYTHON_API_KEY: flowkit-python-api-key
2-
FLOWKIT_PYTHON_ENDPOINT: http://0.0.0.0:50052
1+
FLOWKIT_PYTHON_API_KEY: "flowkit-python-api-key"
2+
FLOWKIT_PYTHON_ADDRESS: "0.0.0.0:50052"
33
FLOWKIT_PYTHON_WORKERS: 2
44
USE_SSL: False
55
#SSL_CERT_PUBLIC_KEY_FILE:

src/aali/flowkit/__main__.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,19 @@ def parse_cli_args():
4444
return args
4545

4646

47+
def handle_legacy_port_config():
48+
"""Handle legacy port configuration."""
49+
if CONFIG.flowkit_python_address != "":
50+
return CONFIG.flowkit_python_address
51+
if CONFIG.flowkit_python_endpoint != "":
52+
return CONFIG.flowkit_python_endpoint
53+
54+
4755
def substitute_empty_values(args):
4856
"""Substitute the empty values with configuration values."""
49-
port = args.port or urlparse(CONFIG.flowkit_python_endpoint).port
50-
CONFIG.flowkit_python_endpoint = f"http://0.0.0.0:{port}"
57+
CONFIG.flowkit_python_address = (
58+
f"{args.host}:{args.port}" if args.host is not None and args.port is not None else CONFIG.flowkit_python_address
59+
)
5160
CONFIG.flowkit_python_workers = args.workers or CONFIG.flowkit_python_workers
5261
CONFIG.use_ssl = (args.use_ssl.lower() == "true") if args.use_ssl is not None else CONFIG.use_ssl
5362
CONFIG.ssl_cert_private_key_file = args.ssl_keyfile or CONFIG.ssl_cert_private_key_file
@@ -64,12 +73,17 @@ def main():
6473
# Substitute the empty values with configuration values
6574
substitute_empty_values(args)
6675

67-
port = urlparse(CONFIG.flowkit_python_endpoint).port
76+
address = handle_legacy_port_config()
77+
# Add scheme if missing
78+
if not address.startswith(("http://", "https://")):
79+
address = "http://" + address
80+
host = urlparse(address).hostname
81+
port = urlparse(address).port
6882

6983
# Run the service
7084
uvicorn.run(
7185
"aali.flowkit.flowkit_service:flowkit_service",
72-
host="0.0.0.0",
86+
host=host,
7387
port=port,
7488
workers=CONFIG.flowkit_python_workers,
7589
ssl_keyfile=CONFIG.ssl_cert_private_key_file if CONFIG.use_ssl else None,

src/aali/flowkit/config/_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(self):
6565

6666
# Define the configuration variables to be parsed from the YAML file
6767
self.flowkit_python_api_key = str(self._yaml.get("FLOWKIT_PYTHON_API_KEY", ""))
68+
self.flowkit_python_address = str(self._yaml.get("FLOWKIT_PYTHON_ADDRESS"))
6869
self.flowkit_python_endpoint = str(self._yaml.get("FLOWKIT_PYTHON_ENDPOINT", "http://localhost:50052"))
6970
self.flowkit_python_workers = int(self._yaml.get("FLOWKIT_PYTHON_WORKERS", 4))
7071
self.use_ssl = bool(self._yaml.get("USE_SSL", False))

0 commit comments

Comments
 (0)