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

Switch from config init to BaseSettings #226

Merged
merged 53 commits into from Mar 24, 2020
Merged

Switch from config init to BaseSettings #226

merged 53 commits into from Mar 24, 2020

Conversation

shyamd
Copy link
Contributor

@shyamd shyamd commented Mar 12, 2020

Closes #152

This is going to be a complicated PR since this SeverConfig object is spiderwebed all over the server module. The goal is to swtich to BaseSettings which will make using this as a standalone server given a mongoDB much easier

@codecov
Copy link

codecov bot commented Mar 13, 2020

Codecov Report

Merging #226 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #226   +/-   ##
=======================================
  Coverage   87.11%   87.11%           
=======================================
  Files          43       43           
  Lines        1862     1862           
=======================================
  Hits         1622     1622           
  Misses        240      240           
Flag Coverage Δ
#unittests 87.11% <0.00%> (ø)

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 76d2e37...76d2e37. Read the comment docs.

@shyamd
Copy link
Contributor Author

shyamd commented Mar 13, 2020

Ok, this looks like it works. I've got to add some tests in the morning.

Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Look's great!
I know this is still WIP, I was just curious to see how this was done, and added some comments along the way.
The tests look a bit mangled at this point, but I guess that aligns well with your last comment 👍

optimade/server/routers/utils.py Show resolved Hide resolved
tests/server/test_config.py Outdated Show resolved Hide resolved
optimade/models/jsonapi.py Show resolved Hide resolved
optimade/server/config.py Outdated Show resolved Hide resolved
optimade/server/config.py Outdated Show resolved Hide resolved
optimade/server/config.py Outdated Show resolved Hide resolved
optimade/server/config.py Outdated Show resolved Hide resolved
@ml-evs
Copy link
Member

ml-evs commented Mar 13, 2020

Thanks for this @shyamd, this is certainly better than our current system!

@shyamd
Copy link
Contributor Author

shyamd commented Mar 14, 2020

@CasperWA @ml-evs
What is the purpose of the docker-compose and Dockerfile. Is it just for testing or is it for general use?

@shyamd shyamd requested review from CasperWA and ml-evs March 20, 2020 15:01
@shyamd
Copy link
Contributor Author

shyamd commented Mar 24, 2020

One of the two of you has to review for the merging to become unblocked btw.

ml-evs
ml-evs previously approved these changes Mar 24, 2020
Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

Great work @shyamd, thanks. This definitely simplifies the config and has caught a few other bugs.

I'm happy to approve this as is, my only minor comment is whether you think it makes sense for the example_config file to contain the defaults only? I know it's not much of an ask, but the only other way to see the defaults is to check the code.

We should definitely do a 0.8 release after this (or at least soon).

setup.py Show resolved Hide resolved
@@ -0,0 +1,37 @@
{
"debug": false,
"use_real_mongo": true,
Copy link
Member

Choose a reason for hiding this comment

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

I get that this is just an example config, but does it make more sense for this file to contain the default values?

Suggested change
"use_real_mongo": true,
"use_real_mongo": false,

Copy link
Contributor Author

@shyamd shyamd left a comment

Choose a reason for hiding this comment

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

I'm sorta back and forth on this issue. Part of me agrees with you and part of me wants a more real-world example. Obviously we can't make the defaults real-world example as we want it to just run as-is.

@ml-evs
Copy link
Member

ml-evs commented Mar 24, 2020

I'm sorta back and forth on this issue. Part of me agrees with you and part of me wants a more real-world example. Obviously we can't make the defaults real-world example as we want it to just run as-is.

Perhaps we could include the default config elsewhere?

@shyamd
Copy link
Contributor Author

shyamd commented Mar 24, 2020

Good idea. I've added that for now. The next big PR might be official docs of some sort since there is enough complexity now that they are needed.

@ml-evs
Copy link
Member

ml-evs commented Mar 24, 2020

Good idea. I've added that for now. The next big PR might be official docs of some sort since there is enough complexity now that they are needed.

Great, agreed. I'm happy to help with that as its quite a big task, we have an issue at #176 to start tracking this if we want to delegate the work.

Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

👍

Thanks again @shyamd and @CasperWA for the previous thorough review.

@shyamd shyamd merged commit 8f7d81e into Materials-Consortia:master Mar 24, 2020
@shyamd shyamd deleted the switch-to-basesettings branch March 25, 2020 14:58
@CasperWA
Copy link
Member

I think this should have been squashed in some way - 53 commits is a bit of an extensive addition to the history for a single PR...
It's done now, but maybe for the future we should be more considerate of future colleagues/versions of us, who may want to cherry-pick commits or otherwise try to untangle some piece of code history?

@ml-evs ml-evs mentioned this pull request Mar 31, 2020
@ml-evs ml-evs added this to In progress in Road to optimade-python-tools 1.0 via automation Mar 31, 2020
@ml-evs ml-evs moved this from In progress to Done in Road to optimade-python-tools 1.0 Mar 31, 2020
@CasperWA CasperWA mentioned this pull request Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Switch to pydantic's BaseSettings for the config file?
3 participants