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

Migrate config to toml #2981

Merged
merged 57 commits into from
Jan 21, 2021
Merged

Conversation

cphyc
Copy link
Member

@cphyc cphyc commented Nov 25, 2020

PR Summary

PR Checklist

  • pass black --check yt/
  • pass isort . --check --diff
  • pass flake8 yt/
  • pass flynt yt/ --fail-on-change --dry-run -e yt/extern
  • New features are documented, with docstrings and narrative docs
  • Adds a test for any bugs fixed. Adds tests for new features.

@neutrinoceros
Copy link
Member

looks like a lot of the changes are just flynt running lose on documentation (which was not done already, to my surprise ?). It's nice but I maybe it's out of scope here, or am I missing something ?

Copy link
Member

@matthewturk matthewturk left a comment

Choose a reason for hiding this comment

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

I like this. One question I had, since we're in a mood to add the occasional dependency, is if there is a config library out there (that perhaps we even have a transitive dependence on) that would be a good idea to migrate to.

yt/config.py Outdated
def get(self, section, *path, strict=True, **kwargs):
config = self.values[section]

# This works as follow: if we try to access
Copy link
Member

Choose a reason for hiding this comment

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

Does this leave open the opportunity to do frontend-specific config?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does! You can actually do something like
image

yt/config.py Outdated
if len(path) == 0:
return config

ok = False
Copy link
Member

Choose a reason for hiding this comment

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

wow this statement is a real mood, I have to say

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it, sorry!

yt/config.py Outdated
ytcfg.read(CURRENT_CONFIG_FILE)
cwd = Path(".").absolute()
while cwd.parent != cwd:
cfg_file = cwd / "yt.toml"
Copy link
Member

Choose a reason for hiding this comment

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

love pathlib

yt/config.py Outdated
if cfg_file.exists():
ytcfg.read(cfg_file)
break
cwd = cwd.parent
Copy link
Member

Choose a reason for hiding this comment

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

I'm looking at this and trying to figure out if it's possible to get to the root, or to get into an infinite loop, and I can't quite tell. Is it ever possible we'll see an exception for trying to get to the parent of a non-parented path?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the code is correct, but I'll let others weigh in.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated this bit as it was causing me headache to make sure it will work in any case.

yt/config.py Outdated Show resolved Hide resolved
yt/config.py Outdated Show resolved Hide resolved
@cphyc cphyc force-pushed the migrate-config-to-toml branch from c37e1e5 to 4b708ef Compare November 25, 2020 16:39
@cphyc
Copy link
Member Author

cphyc commented Nov 25, 2020

looks like a lot of the changes are just flynt running lose on documentation (which was not done already, to my surprise ?). It's nice but I maybe it's out of scope here, or am I missing something ?

I've moved them to #2983

@cphyc cphyc force-pushed the migrate-config-to-toml branch from 0623390 to e980756 Compare November 25, 2020 16:55
@cphyc
Copy link
Member Author

cphyc commented Nov 25, 2020

I like this. One question I had, since we're in a mood to add the occasional dependency, is if there is a config library out there (that perhaps we even have a transitive dependence on) that would be a good idea to migrate to.

I could not find any library that was relying on toml, but given the size of our configuration, this may be a bit overkill. Currently, the config manager repropduces part of the ConfigParser API.

@cphyc cphyc added backwards incompatible This change will change behavior enhancement Making something better infrastructure Related to CI, versioning, websites, organizational issues, etc yt-4.0 feature targeted for the yt-4.0 release labels Nov 25, 2020
@cphyc cphyc marked this pull request as ready for review November 25, 2020 17:18
@neutrinoceros
Copy link
Member

I have a general question here: is it still relevant to store the global config file in $HOME/.config/yt/yt.toml rather than $HOME/.config/yt.toml ? what else is expected to be there ?

@cphyc cphyc mentioned this pull request Nov 26, 2020
6 tasks
Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

Still 2 files to go but here are my first comments. I'll finish this tomorrow !

doc/source/reference/command-line.rst Outdated Show resolved Hide resolved
doc/source/reference/command-line.rst Outdated Show resolved Hide resolved
doc/source/reference/configuration.rst Outdated Show resolved Hide resolved
doc/source/reference/configuration.rst Outdated Show resolved Hide resolved
yt/config.py Show resolved Hide resolved
yt/mods.py Outdated Show resolved Hide resolved
yt/utilities/parallel_tools/parallel_analysis_interface.py Outdated Show resolved Hide resolved
yt/utilities/command_line.py Outdated Show resolved Hide resolved
yt/utilities/command_line.py Outdated Show resolved Hide resolved
yt/utilities/command_line.py Outdated Show resolved Hide resolved
Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

some more minor comments. I'll approve when we converge on the global VS local config file discussion :-)

yt/utilities/configuration_tree.py Outdated Show resolved Hide resolved
yt/utilities/configuration_tree.py Outdated Show resolved Hide resolved
yt/utilities/configuration_tree.py Outdated Show resolved Hide resolved
yt/utilities/configuration_tree.py Show resolved Hide resolved
yt/utilities/configuration_tree.py Show resolved Hide resolved
yt/utilities/configuration_tree.py Show resolved Hide resolved
@Xarthisius
Copy link
Member

@yt-fido test this please

@cphyc cphyc force-pushed the migrate-config-to-toml branch from 8670ee1 to fc943de Compare December 16, 2020 16:35
yt/config.py Show resolved Hide resolved
yt/config.py Show resolved Hide resolved
yt/utilities/command_line.py Show resolved Hide resolved
yt/utilities/command_line.py Outdated Show resolved Hide resolved
yt/utilities/command_line.py Outdated Show resolved Hide resolved
yt/__init__.py Outdated Show resolved Hide resolved
@cphyc cphyc force-pushed the migrate-config-to-toml branch from b51bf77 to 1ba0398 Compare January 5, 2021 11:59
@cphyc
Copy link
Member Author

cphyc commented Jan 11, 2021

@munkm any chance you review this? Otherwise, I'm fine with it being merged in.

@cphyc cphyc closed this Jan 19, 2021
@cphyc cphyc reopened this Jan 19, 2021
Base automatically changed from master to main January 20, 2021 15:27
@pep8speaks
Copy link

pep8speaks commented Jan 21, 2021

Hello @cphyc! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-01-21 13:11:09 UTC

@cphyc
Copy link
Member Author

cphyc commented Jan 21, 2021

The Jenkins failure are due to the fact Jenkins does not install the requirements listed in setup.py, which now include toml as a dependency. This should probably be fixed on Jenkins' side rather than in this PR (by installing those requirements).

@matthewturk
Copy link
Member

@Xarthisius Can that be fixed without your intervention?

I think otherwise this may be ready to go, once the tests pass.

@neutrinoceros
Copy link
Member

Following the merging of #2981 , I need to patch this with the new deprecation utilities. Then I believe it will finally be ready for going in :)

@brittonsmith
Copy link
Member

I'll merge this when the tests finish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards incompatible This change will change behavior enhancement Making something better infrastructure Related to CI, versioning, websites, organizational issues, etc yt-4.0 feature targeted for the yt-4.0 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants