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

allow config to update based on specified path #1226

Merged
merged 9 commits into from
Aug 14, 2018

Conversation

nataliejpg
Copy link
Contributor

Fixes #1223 .

allows a config file path to be specified either in initialisation of the Config object or when running update. This path is then used for future updates.

How's this @jenshnielsen? I haven't tested it yet.

@WilliamHPNielsen
Copy link
Contributor

WilliamHPNielsen commented Aug 10, 2018

Judging from the tests, this does not quite work yet; it fails already when trying to import qcodes.

@nataliejpg
Copy link
Contributor Author

nataliejpg commented Aug 10, 2018

@WilliamHPNielsen the bug is a typo, I think you can get the main points from my comment or looking at the code and I was hoping for some feedback on the concept before I put time into testing. I'll assume this means you think the idea is fine?

@WilliamHPNielsen
Copy link
Contributor

@nataliejpg and I was hoping for actually working code before I put time into reviewing... oh, no, now we're stuck in a deadlock 😄
I think the idea of passing a kwarg path to force load from that path is A-OK.

@nataliejpg
Copy link
Contributor Author

@WilliamHPNielsen should work now

config = update(config, cwd_config)
self.config_file_path = path or self.config_file_path
if self.config_file_path is not None:
config_file = "{}/{}".format(self.config_file_path, self.config_file_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

please use os.path.join instead of / and format. let the OS define the file separator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, that would be better, I just copied the original logic from likes 72 and 81 but will update them all now.

Copy link
Contributor

@astafan8 astafan8 left a comment

Choose a reason for hiding this comment

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

great addon! (module my comment about os.path.join)

cwd_config = self.load_config(self.cwd_file_name)
config = update(config, cwd_config)
self.config_file_path = path or self.config_file_path
if self.config_file_path is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

also, what about test? (see qcodes/tests/test_config.py)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately beyond my scope. perhaps someone (the author of the existing test?) could advise me what I need to add and I can put it in this pr? Otherwise realistically I won't be able to do this in the near future.

Copy link
Contributor

Choose a reason for hiding this comment

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

The author is long gone, unfortunately. I agree that test_config.py is not the most immediately readable piece of code. I can help you extend the test to cover the new functionality introduced in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks @WilliamHPNielsen. How about I test this out when I'm next measuring and then we merge it and @WilliamHPNielsen writes the test in another pr for the actual test?

Copy link
Contributor

Choose a reason for hiding this comment

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

just don't throw away the code that you will be writing when you will be "testing this out when you're next measuring" ;)

self.validate(config, self.current_schema,
self.schema_cwd_file_name)

self.current_config = config

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose we still want this method to return the config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why? I guess it would work better in terms of backwards compatibility (if anyone is actually using the update function) but to me it seems a bit weird to have an update function that doesn't actually update the current_config (the last one didn't)

Copy link
Contributor

Choose a reason for hiding this comment

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

this depends on how people use it. Unfortunately, docs/examples/Configuring_QCoDeS.ipynb does not shed light on it... I leave this decision to you.

Copy link
Contributor

Choose a reason for hiding this comment

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

The missing return is the reason that the tests fail. I think we need a pretty strong argument for breaking/changing behaviour that we explicitly test for. We don't have visibility on who uses the software and how, so the golden rule is that we don't suddenly change the API.

But I agree that the old/current API is not very intuitive, so we might deprecate some functions in favour of new ones that act better.

@WilliamHPNielsen
Copy link
Contributor

I guess I volunteered to clean this up. I am going to push one or two commits now, fixing the return and extending the tests.

Another issue is improving the documentation...

@nataliejpg
Copy link
Contributor Author

thanks @WilliamHPNielsen

@codecov
Copy link

codecov bot commented Aug 14, 2018

Codecov Report

Merging #1226 into master will increase coverage by 0.02%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1226      +/-   ##
==========================================
+ Coverage    80.5%   80.53%   +0.02%     
==========================================
  Files          49       49              
  Lines        6807     6816       +9     
==========================================
+ Hits         5480     5489       +9     
  Misses       1327     1327

@WilliamHPNielsen WilliamHPNielsen merged commit 0d51cb3 into microsoft:master Aug 14, 2018
@WilliamHPNielsen
Copy link
Contributor

Note to @QCoDeS/core: Configuring_QCoDeS.ipynb was last updated two years ago. We might want to have another look at that one.

giulioungaretti pushed a commit that referenced this pull request Aug 14, 2018
Merge: 000c451 30dfac0
Author: William H.P. Nielsen <whpn@mailbox.org>

    Merge pull request #1226 from nataliejpg/feat_config_update
@nataliejpg nataliejpg deleted the feat_config_update branch August 15, 2018 07:58
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.

None yet

3 participants