From 38cbaf7b904c417511a3cecf42d94e6f863cf832 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Fri, 12 Jul 2024 16:14:45 +0100 Subject: [PATCH 1/3] app: handle configs that are not LazyConfigValue objects --- cylc/uiserver/app.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cylc/uiserver/app.py b/cylc/uiserver/app.py index a10665c1..db5dad63 100644 --- a/cylc/uiserver/app.py +++ b/cylc/uiserver/app.py @@ -76,6 +76,7 @@ default, validate, ) +from traitlets.config.loader import LazyConfigValue from types import SimpleNamespace from jupyter_server.extension.application import ExtensionApp @@ -546,10 +547,17 @@ def set_auth(self) -> Authorization: """Create authorization object. One for the lifetime of the UIServer. """ + user_auth = self.config.CylcUIServer.user_authorization + site_auth = self.config.CylcUIServer.site_authorization + if isinstance(user_auth, LazyConfigValue): + user_auth: dict = user_auth.to_dict() + if isinstance(site_auth, LazyConfigValue): + site_auth: dict = 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, ) From 21a8a6dea1ade5b721160f736a0ff6d436766fe1 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Mon, 15 Jul 2024 12:48:29 +0100 Subject: [PATCH 2/3] Update cylc/uiserver/app.py --- cylc/uiserver/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cylc/uiserver/app.py b/cylc/uiserver/app.py index db5dad63..d1e3b2ce 100644 --- a/cylc/uiserver/app.py +++ b/cylc/uiserver/app.py @@ -547,8 +547,8 @@ def set_auth(self) -> Authorization: """Create authorization object. One for the lifetime of the UIServer. """ - user_auth = self.config.CylcUIServer.user_authorization - site_auth = self.config.CylcUIServer.site_authorization + 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: dict = user_auth.to_dict() if isinstance(site_auth, LazyConfigValue): From 01ca5aa212aa6cf9b048304cc4229400c7a90211 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:31:42 +0100 Subject: [PATCH 3/3] Fix style --- cylc/uiserver/app.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cylc/uiserver/app.py b/cylc/uiserver/app.py index d1e3b2ce..c449822e 100644 --- a/cylc/uiserver/app.py +++ b/cylc/uiserver/app.py @@ -59,7 +59,7 @@ from pathlib import Path, PurePath import sys from textwrap import dedent -from typing import List +from typing import List, Union from pkg_resources import parse_version from tornado import ioloop @@ -547,12 +547,16 @@ 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 + 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: dict = user_auth.to_dict() + user_auth = user_auth.to_dict() if isinstance(site_auth, LazyConfigValue): - site_auth: dict = site_auth.to_dict() + site_auth = site_auth.to_dict() return Authorization( getpass.getuser(),