Skip to content

Commit

Permalink
Improve viewer to not look for initialized configuration and only loa…
Browse files Browse the repository at this point in the history
…d from env vars
  • Loading branch information
polyaxon-ci committed Oct 27, 2023
1 parent d9bc390 commit 8d7d825
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion haupt/haupt/cli/runners/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def start(
):
port = port or os.environ.get(ENV_KEYS_PROXY_STREAMS_TARGET_PORT)
path = path or ctx_paths.CONTEXT_OFFLINE_ROOT
settings.set_sandbox_config(path=path)
os.environ[ENV_KEYS_SANDBOX_ROOT] = path
settings.set_sandbox_config(path=path, env_only_config=True)
start_app(
app="haupt.polyconf.asgi.viewer:application",
app_name=PolyaxonServices.STREAMS,
Expand Down
6 changes: 4 additions & 2 deletions haupt/haupt/polyconf/asgi/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
"""

import logging
import os

from django.core.asgi import get_asgi_application
Expand All @@ -26,7 +26,9 @@
os.environ[ENV_KEYS_SERVICE] = PolyaxonServices.STREAMS
os.environ[ENV_KEYS_SERVICE_MODE] = PolyaxonServices.VIEWER
os.environ[ENV_KEYS_UI_IN_SANDBOX] = "true"
logging.warning(os.environ.get(ENV_KEYS_SANDBOX_ROOT, ctx_paths.CONTEXT_OFFLINE_ROOT))
settings.set_sandbox_config(
path=os.environ.get(ENV_KEYS_SANDBOX_ROOT, ctx_paths.CONTEXT_OFFLINE_ROOT)
path=os.environ.get(ENV_KEYS_SANDBOX_ROOT, ctx_paths.CONTEXT_OFFLINE_ROOT),
env_only_config=True,
)
application = get_asgi_application()
7 changes: 6 additions & 1 deletion haupt/haupt/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def set_sandbox_config(
config: Optional[SandboxConfig] = None,
path: Optional[str] = None,
persist: bool = False,
env_only_config: bool = True,
):
from haupt.managers.sandbox import SandboxConfigManager
from polyaxon.settings import HOME_CONFIG, set_agent_config
Expand All @@ -34,7 +35,11 @@ def set_sandbox_config(
global SANDBOX_CONFIG

try:
SANDBOX_CONFIG = config or SandboxConfigManager.get_config_or_default()
SANDBOX_CONFIG = (
config or SandboxConfigManager.get_config_from_env()
if env_only_config
else SandboxConfigManager.get_config_or_default()
)
SANDBOX_CONFIG.mount_sandbox(path=path or HOME_CONFIG.path)
SANDBOX_CONFIG.set_default_artifacts_store()
if persist:
Expand Down

0 comments on commit 8d7d825

Please sign in to comment.