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

🐛 OSPARC_API_BASE_URL variable ends with / #7042

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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
NoAuthentication,
)
from pydantic import (
AfterValidator,
AliasChoices,
AnyHttpUrl,
AnyUrl,
Expand Down Expand Up @@ -251,10 +252,14 @@ class AppSettings(BaseApplicationSettings, MixinLoggingSettings):
description="resource usage tracker service client's plugin",
)

DIRECTOR_V2_PUBLIC_API_BASE_URL: AnyHttpUrl = Field(
...,
description="Base URL used to access the public api e.g. http://127.0.0.1:6000 for development or https://api.osparc.io",
)
DIRECTOR_V2_PUBLIC_API_BASE_URL: Annotated[
AnyHttpUrl | str,
AfterValidator(lambda v: f"{v}".rstrip("/")),
Field(
...,
description="Base URL used to access the public api e.g. http://127.0.0.1:6000 for development or https://api.osparc.io",
),
]
DIRECTOR_V2_TRACING: TracingSettings | None = Field(
json_schema_extra={"auto_default_from_env": True},
description="settings for opentelemetry tracing",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
""" Substitution of osparc variables and secrets

"""
"""Substitution of osparc variables and secrets"""

import functools
import logging
Expand All @@ -24,6 +22,7 @@
from pydantic import BaseModel
from servicelib.fastapi.app_state import SingletonInAppStateMixin
from servicelib.logging_utils import log_context
from simcore_service_director_v2.core.settings import get_application_settings

from ...utils.db import get_repository
from ...utils.osparc_variables import (
Expand Down Expand Up @@ -194,6 +193,7 @@ async def resolve_and_substitute_session_variables_in_model(
# if it raises an error vars need replacement
raise_if_unresolved_osparc_variable_identifier_found(model)
except UnresolvedOsparcVariableIdentifierError:
app_settings = get_application_settings(app)
table = OsparcSessionVariablesTable.get_from_app_state(app)
identifiers = await resolve_variables_from_context(
table.copy(),
Expand All @@ -204,7 +204,7 @@ async def resolve_and_substitute_session_variables_in_model(
project_id=project_id,
node_id=node_id,
run_id=service_run_id,
api_server_base_url=app.state.settings.DIRECTOR_V2_PUBLIC_API_BASE_URL,
api_server_base_url=app_settings.DIRECTOR_V2_PUBLIC_API_BASE_URL,
),
)
_logger.debug("replacing with the identifiers=%s", identifiers)
Expand Down Expand Up @@ -238,6 +238,7 @@ async def resolve_and_substitute_session_variables_in_specs(
identifiers_to_replace,
)
if identifiers_to_replace:
app_settings = get_application_settings(app)
environs = await resolve_variables_from_context(
table.copy(include=identifiers_to_replace),
context=ContextDict(
Expand All @@ -247,7 +248,7 @@ async def resolve_and_substitute_session_variables_in_specs(
project_id=project_id,
node_id=node_id,
run_id=service_run_id,
api_server_base_url=app.state.settings.DIRECTOR_V2_PUBLIC_API_BASE_URL,
api_server_base_url=app_settings.DIRECTOR_V2_PUBLIC_API_BASE_URL,
),
)

Expand Down
Loading