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

Adds version hierarchy to config files #301

Merged
merged 16 commits into from
Feb 3, 2022

Conversation

datamel
Copy link
Contributor

@datamel datamel commented Jan 28, 2022

For hub_version 0.6.0, the load order can be seen below:
image

These changes close #199 and #291

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Appropriate tests are included (unit and/or functional).
  • Appropriate change log entry included.
  • I have opened a documentation PR at cylc/cylc-doc/pull/XXXX.
  • No dependency changes.

@datamel datamel self-assigned this Jan 28, 2022
@datamel datamel added this to the cylc-uiserver 1.0.0 milestone Jan 28, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jan 28, 2022

Codecov Report

Merging #301 (3dade03) into master (9ca3cad) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #301      +/-   ##
==========================================
- Coverage   79.61%   79.57%   -0.05%     
==========================================
  Files           9        9              
  Lines         981      979       -2     
  Branches      193      193              
==========================================
- Hits          781      779       -2     
  Misses        165      165              
  Partials       35       35              
Impacted Files Coverage Δ
cylc/uiserver/app.py 85.96% <100.00%> (-0.25%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ca3cad...3dade03. Read the comment docs.

Copy link
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these two be deleted?

# site configuration
SITE_CONF_PATH: Path = SITE_CONF_ROOT / 'jupyter_config.py'
# user configuration
USER_CONF_PATH: Path = USER_CONF_ROOT / 'jupyter_config.py'

@@ -49,21 +55,35 @@ def _load(path):
exec(path.read_text())


def get_conf_dir_hierarchy(config_paths: List[Path]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def get_conf_dir_hierarchy(config_paths: List[Path]):
def get_conf_dir_hierarchy(config_paths: List[Path]) -> List[Path]:

conf_hierarchy.append(Path(x[0], x[1], 'jupyter_config.py'))
return conf_hierarchy


def load():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Type annotations in a function body aren't checked unless the definition has type annotations)

Suggested change
def load():
def load() -> None:

)
else:
site_conf_path: Path = SITE_CONF_PATH
config_paths = [DEFAULT_CONF_PATH, site_conf_path, USER_CONF_PATH]
site_conf_path: Path = SITE_CONF_ROOT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already declared

Suggested change
site_conf_path: Path = SITE_CONF_ROOT
site_conf_path = SITE_CONF_ROOT

@MetRonnie
Copy link
Member

For some reason it's not using the jupyter_config.py I have moved from ~/.cylc/hub/ to ~/.cylc/uiserver/0.6/. I have verified that it gets loaded using breakpoints, but the UI build being used is the bundled one instead of the one specified

c.CylcUIServer.ui_build_dir = '<home>/github/cylc-ui/dist'

@datamel
Copy link
Contributor Author

datamel commented Jan 31, 2022

For some reason it's not using the jupyter_config.py I have moved from ~/.cylc/hub/ to ~/.cylc/uiserver/0.6/. I have verified that it gets loaded using breakpoints, but the UI build being used is the bundled one instead of the one specified

c.CylcUIServer.ui_build_dir = '<home>/github/cylc-ui/dist'

I'll look into this now, thanks @MetRonnie

@MetRonnie
Copy link
Member

Here is the callstack for that breakpoint, in case it's any use
image

@oliver-sanders
Copy link
Member

I have verified that it gets loaded using breakpoints

It could be loading other config files which reset it back, try running in debug mode, you should see a log entry every time something changed.

@MetRonnie
Copy link
Member

cylc hub --debug

I have found no real difference in the log output with this PR or master checked out, other than:

  • the expected ~/.cylc/hub -> ~/.cylc/uiserver
  • -[I CylcUIServer] Serving UI from: ~/github/cylc-ui/dist
    +[I CylcUIServer] Serving UI from: ~/github/cylc-uiserver/cylc/uiserver/ui/0.6.0

In neither was there an indication of what jupyter_config.py was loaded.

@MetRonnie
Copy link
Member

MetRonnie commented Jan 31, 2022

(Updated)

This bit of logging only works for cylc gui --debug, not cylc hub --debug:

self.log.debug(
'CylcUIServer config:\n' + '\n'.join(
f' * {key} = {repr(value)}'
for key, value in self.config['CylcUIServer'].items()
)
)

This doesn't work for either:

LOG.info(f'Loading config file: {path}')

This is also the case on master

@oliver-sanders
Copy link
Member

cylc gui --debug

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should do the trick for JupyterHub, needs a small addition to make it work for the UI Server too.

@@ -49,21 +55,35 @@ def _load(path):
exec(path.read_text())


def get_conf_dir_hierarchy(config_paths: List[Path]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is only loaded by JupyterHub, to open it up to Jupyter Server too need to add it to the list of config_file_paths in cylc.uiserver.CylcUIServer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update?

config_file_paths = list(
map(
str,
[
# user configuration
USER_CONF_ROOT,
# site configuration
SITE_CONF_ROOT,
# base configuration - always used
Path(uis_pkg).parent,
]
)
)

datamel and others added 2 commits February 1, 2022 13:44
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
)
)
config_file_paths.append(str(Path(uis_pkg).parent))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add the path hierarchy here rather than loading the hub config, this lets Jupyter Server take care of loading the files correctly.

Copy link
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hub -> uiserver here?

* ``$CYLC_SITE_CONF_PATH/hub/jupyter_config.py`` (for site-level configuration)
* ``/etc/cylc/hub/jupyter_config.py`` (for system-level configuration)
* ``~/.cylc/hub/jupyter_config.py`` (for user-level configuration)

Copy link
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is correctly loading the moved jupyter_config.py now

Copy link
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait, forgot about the requested change in my earlier comment

hub -> uiserver here?

* ``$CYLC_SITE_CONF_PATH/hub/jupyter_config.py`` (for site-level configuration)
* ``/etc/cylc/hub/jupyter_config.py`` (for system-level configuration)
* ``~/.cylc/hub/jupyter_config.py`` (for user-level configuration)

@datamel
Copy link
Contributor Author

datamel commented Feb 2, 2022

Ah wait, forgot about the requested change in my earlier comment

hub -> uiserver here?

* ``$CYLC_SITE_CONF_PATH/hub/jupyter_config.py`` (for site-level configuration)
* ``/etc/cylc/hub/jupyter_config.py`` (for system-level configuration)
* ``~/.cylc/hub/jupyter_config.py`` (for user-level configuration)

Great, well spotted, that just came in on a rebase.

datamel and others added 3 commits February 2, 2022 09:11
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
@oliver-sanders
Copy link
Member

(flake8 unhappy)

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, could do with shifting the logic out of the hub config, this file is only intended for JupyterHub and is not supposed to be imported directly for normal use because it auto-loads.

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, tested as working, just need to get the test passing.

Co-authored-by: Oliver Sanders <oliver.sanders@metoffice.gov.uk>
@datamel
Copy link
Contributor Author

datamel commented Feb 3, 2022

Looks good to me, tested as working, just need to get the test passing.

Yep thanks! On it now. I can't reproduce locally but I expect a path expansion problem.

Co-authored-by: Oliver Sanders <oliver.sanders@metoffice.gov.uk>
@oliver-sanders oliver-sanders linked an issue Feb 3, 2022 that may be closed by this pull request
@oliver-sanders oliver-sanders merged commit 6029995 into cylc:master Feb 3, 2022
@datamel datamel mentioned this pull request Feb 10, 2022
7 tasks
This was referenced Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

configuration path root conf: hierarchical configuration path
4 participants