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

Feature/config system #350

Merged
merged 23 commits into from
Oct 25, 2016
Merged

Feature/config system #350

merged 23 commits into from
Oct 25, 2016

Conversation

giulioungaretti
Copy link
Contributor

@giulioungaretti giulioungaretti commented Oct 4, 2016

See #341 .

It's not 100% done yet, and I think that maybe we should allow live updating the configs.
But also maybe not :/
@MerlinSmiles @eendebakpt !

  • nice error message
  • only save user changed settings
  • dot notation for configure object (+ docstrings???)
  • sharing cofigs (f.ex. size of figures, but not path)
    • f.ex. head of experiment decides that files should have common naming so creates a config file with the defaults and voila all the students/researchers have it
  • better names, config.json sucks

@AdriaanRol
Copy link
Contributor

@giulioungaretti This looks pretty interesting, I'd definately be interested in using this.

I read through the readme of the config (didn't look at the acual code) but it was not clear how to use this. Do you think it would make sense to include use of the config in the example ipython notebook and also add an example of how to use it in the config readme?

I'm talking about a piece of code that can be executed or very explicit some file that needs to be present. Configs usually tend to be the things that I break :)

@giulioungaretti
Copy link
Contributor Author

giulioungaretti commented Oct 5, 2016

@AdriaanRol ah, I assumed the doc was enough, but maybe it's not.

@peendebak
Copy link
Contributor

@giulioungaretti Config system looks good. It is a bit more complex that some of the default python systems (e.g. configparser), but then it also has some more functionality.

Maybe we should consider adding some convenience functions such as .get_float which would get a config value and convert it to float (or generate an error if conversion is not possible).

@giulioungaretti
Copy link
Contributor Author

@peendebak json does not know the difference between float and int, if type is number then they are the same.
Python will get the float though.

@qcodes-bot
Copy link

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 2


Complexity increasing per file
==============================
- qcodes/tests/test_config.py  2
- qcodes/config/config.py  7


Clones added
============
- qcodes/tests/test_config.py  20

See the complete overview on Codacy

@giulioungaretti
Copy link
Contributor Author

@AdriaanRol
Copy link
Contributor

@giulioungaretti I like the new config explanation notebook. It indeed explains how to make a new config file and how to use it 👍

I cannot say I am a fan of helper functions but that's a matter of personal preference and I'll acknowledge that I don't have to use those.

Other points where I think it can be improved is a good template settings file (you can abuse the default config file for that). If you want a good example of what I am talking about think the sublime config files.
I did find the default config file which is rather limited (only 2 options are so are set). And the other one could use improved comments.

Hope this helps.

@giulioungaretti
Copy link
Contributor Author

giulioungaretti commented Oct 24, 2016

@AdriaanRol sweet, there's not much to configure as of v0.1.
And surely you may want to not use the helper, but then you also need the validation files.
Which of course are not required, but it will warn you that you are doing it wrong.

@MerlinSmiles
Copy link
Contributor

@giulioungaretti I took a look at the config system too, and I'm quite happy with it.

@AdriaanRol I do like the sublime way of config files too. Especially the comments. However, that is not standard json and if I recall correctly is kindof annoying to implement. (There is commentjson though)

Another thing I like about the sublime config is the file naming *.sublime-config it is very clear, and it does allow for several config files. I would like if we adopt something similar, then we could have different config files like plotting.qcodes-config, file_system.qcodes-config, setup.qcodes-config, merlin.qcodes-config and so on, that would allow for organizing, sharing, and enforcing (i.e. filenames) of configs, while still allowing for user specific changes.

In this PR the home config file is saved as ~/qcodesrc.json I would like if all the user qcodes files jump into a ~/.qcodes/ directory, in the case of several config files they would be organized in one place. Not sure what could be added there in the future, maybe templates for logbooks...

@giulioungaretti
Copy link
Contributor Author

@MerlinSmiles it's a very cool idea, and I see the use of it! For now I think this is it, and we'll work out how to make it super shiny in the next versions!
@MerlinSmiles also, nothing stops you from hacking your way and have a custom location set in your env_variables, which you could also define in a notebook :P

@MerlinSmiles
Copy link
Contributor

@giulioungaretti I was just thinking that those changes would break the current config in the future, so it might be useful to implement the pattern now, without the fancyness. But thats of course totally up to you.

Of course nothing stops me from hacking, I always edit in master thats so much easier 😍

@giulioungaretti
Copy link
Contributor Author

@MerlinSmiles actually they won't break :D It's just a matter of implementing the priority and filenames :D

@MerlinSmiles
Copy link
Contributor

@giulioungaretti another reason for a ~/.qcodes/ folder is the schema.json file, not sure why that nonunique file should sit directly in home, without any connection to qcodes...

@giulioungaretti
Copy link
Contributor Author

@MerlinSmiles but are people familiar enough with hidden files/directories ?
But you are right, schema.json should be called qcodesrc_schema.json!

@MerlinSmiles
Copy link
Contributor

@giulioungaretti I'm not sure about the hidden files/dirs, but it seems to be semi standard among package configs, no? At least I have some of those folders.

Actually trying to find info about that, its like a broken way of using unix apps on windows and %APPDATA%\qcodes\ would be the right place.
http://stackoverflow.com/questions/2243895/location-to-put-user-configuration-files-in-windows/2243910#2243910
Funny enough but %APPDATA% is hidden by default in windows, which has annoyed me for years :)

@MerlinSmiles
Copy link
Contributor

MerlinSmiles commented Oct 24, 2016

also this suggests %APPDATA%, maybe that is also where logfiles should go at some point?

@giulioungaretti giulioungaretti merged commit 94c6dd1 into master Oct 25, 2016
@giulioungaretti giulioungaretti deleted the feature/config_system branch October 31, 2016 14:22
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.

5 participants