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

app: handle configs that are not LazyConfigValue objects #616

Merged
merged 4 commits into from
Jul 29, 2024
Merged
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
28 changes: 20 additions & 8 deletions cylc/uiserver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@
the environment variable ``CYLC_SITE_CONF_PATH``.
"""

from concurrent.futures import ProcessPoolExecutor
import getpass
import os
from pathlib import Path, PurePath
import sys
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path, PurePath
from textwrap import dedent
from typing import List, Optional
from types import SimpleNamespace
from typing import List, Optional, Union

from jupyter_server.extension.application import ExtensionApp
from pkg_resources import parse_version
from tornado import ioloop
from tornado.web import RedirectHandler
Expand All @@ -76,9 +78,7 @@
default,
validate,
)
from types import SimpleNamespace

from jupyter_server.extension.application import ExtensionApp
from traitlets.config.loader import LazyConfigValue

from cylc.flow.network.graphql import (
CylcGraphQLBackend, IgnoreFieldMiddleware
Expand Down Expand Up @@ -109,6 +109,7 @@
from cylc.uiserver.websockets.tornado import TornadoSubscriptionServer
from cylc.uiserver.workflows_mgr import WorkflowsManager


INFO_FILES_DIR = Path(USER_CONF_ROOT / "info_files")


Expand Down Expand Up @@ -553,10 +554,21 @@ def set_auth(self) -> Authorization:
"""Create authorization object.
One for the lifetime of the UIServer.
"""
user_auth: Union[LazyConfigValue, dict] = (
self.config.CylcUIServer.user_authorization
)
site_auth: Union[LazyConfigValue, dict] = (
self.config.CylcUIServer.site_authorization
)
if isinstance(user_auth, LazyConfigValue):
user_auth = user_auth.to_dict()
if isinstance(site_auth, LazyConfigValue):
site_auth = site_auth.to_dict()

return Authorization(
getpass.getuser(),
self.config.CylcUIServer.user_authorization.to_dict(),
self.config.CylcUIServer.site_authorization.to_dict(),
user_auth,
site_auth,
self.log,
)

Expand Down
Loading