Skip to content

Commit

Permalink
app: handle configs that are not LazyConfigValue objects (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders authored Jul 29, 2024
1 parent 0438290 commit 199bbfc
Showing 1 changed file with 20 additions and 8 deletions.
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

0 comments on commit 199bbfc

Please sign in to comment.