Skip to content

Commit

Permalink
feat: Use pipeline.endpoint as default for pipeline.frontend-endpoint (
Browse files Browse the repository at this point in the history
…#1972)

Co-authored-by: Kyujin Cho <kyujin.cho@lablup.com>
  • Loading branch information
rapsealk and kyujin-cho committed Mar 29, 2024
1 parent cfaafdd commit 6c80e04
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions changes/1972.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use `config["pipeline"]["endpoint"]` as default value of `config["pipeline"]["frontend-endpoint"]` when not provided
9 changes: 9 additions & 0 deletions src/ai/backend/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,12 @@ def merge(table: Mapping[str, Any], updates: Mapping[str, Any]) -> Mapping[str,
else:
result[k] = v
return result


def set_if_not_set(table: MutableMapping[str, Any], key_path: Tuple[str, ...], value: Any) -> None:
for k in key_path[:-1]:
if k not in table:
return
table = table[k]
if table.get(key_path[-1]) is None:
table[key_path[-1]] = value
6 changes: 1 addition & 5 deletions src/ai/backend/web/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
_config_defaults: Mapping[str, Any] = {
"pipeline": {
"endpoint": yarl.URL("http://127.0.0.1:9500"),
"frontend-endpoint": yarl.URL("http://127.0.0.1:3000"),
"jwt": {
"secret": "7<:~[X,^Z1XM!*,Pe:PHR!bv,H~Q#l177<7gf_XHD6.<*<.t<[o|V5W(=0x:jTh-",
},
Expand Down Expand Up @@ -92,10 +91,7 @@
t.Key("pipeline", default=_config_defaults["pipeline"]): t.Dict(
{
t.Key("endpoint", default=_config_defaults["pipeline"]["endpoint"]): tx.URL,
tx.AliasedKey(
["frontend_endpoint", "frontend-endpoint"],
default=_config_defaults["pipeline"]["frontend-endpoint"],
): tx.URL,
t.Key("frontend-endpoint", default=None): t.Null | tx.URL,
t.Key("jwt", default=_config_defaults["pipeline"]["jwt"]): t.Dict(
{
t.Key(
Expand Down
1 change: 1 addition & 0 deletions src/ai/backend/web/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ def main(
config.override_key(raw_cfg, ("logging", "pkg-ns", "ai.backend"), log_level)

cfg = config.check(raw_cfg, config_iv)
config.set_if_not_set(cfg, ("pipeline", "frontend-endpoint"), cfg["pipeline"]["endpoint"])

if ctx.invoked_subcommand is None:
cfg["webserver"]["pid-file"].write_text(str(os.getpid()))
Expand Down
2 changes: 1 addition & 1 deletion src/ai/backend/web/templates/config.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ connectionMode = "SESSION"

[pipeline]
{% toml_field "endpoint" config["pipeline"]["endpoint"]|string %}
{% toml_field "frontendEndpoint" config["pipeline"]["frontend_endpoint"]|string %}
{% toml_field "frontendEndpoint" config["pipeline"]["frontend-endpoint"]|string %}

0 comments on commit 6c80e04

Please sign in to comment.