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

Add user config file for local settings #2122

Merged
merged 22 commits into from
Apr 30, 2019

Conversation

mtreinish
Copy link
Member

Summary

This commit adds the concept of a user config file to set local defaults
when using qiskit-terra. This enables the end user to override the
default values for some commonly used terra functions in their local
environment. Right now this only includes the backend used by the
circuit drawer, but it will be expanded in the future as more settings
with opinionated defaults are exposed. To set a config file you can
either create one in the default location
'~/.config/qiskit/settings.conf' or use the QISKIT_SETTINGS environment
variable to specify an alternative location.

Details and comments

This commit adds the concept of a user config file to set local defaults
when using qiskit-terra. This enables the end user to override the
default values for some commonly used terra functions in their local
environment. Right now this only includes the backend used by the
circuit drawer, but it will be expanded in the future as more settings
with opinionated defaults are exposed. To set a config file you can
either create one in the default location
'~/.config/qiskit/settings.conf' or use the QISKIT_SETTINGS environment
variable to specify an alternative location.
@nonhermitian
Copy link
Contributor

Why is this not in the .qiskit dir and why are we not taking advantage of the runtime config stuff we already have?

@mtreinish
Copy link
Member Author

Why is this not in the .qiskit dir and why are we not taking advantage of the runtime config stuff we already have?

It's a typo/mistake in the commit message, I copied the directory from the ibmq provider code and just changed the file name. The directory is ~/.qiskit: https://github.com/Qiskit/qiskit-terra/blob/4353b20bf87aa8b329aab64462d6ca89f9380913/qiskit/user_config.py#L15-L16

The reason It's not using the same file is after looking at the same qiskitrc is that the way the ibmq provider parses that is it uses any section name as a different set of credentials. So adding anything to it will be interpreted as a new set of credentials. Instead of trying to change the contract there it felt better to just make it a distinct file.

@nonhermitian
Copy link
Contributor

Yes, it is unfortunate that that design choice was made. I was mentioning reusing the runtime config functionally we already have, but I think they were moved out of terra to the provider, so that answers that question.

@mtreinish
Copy link
Member Author

Yes, it is unfortunate that that design choice was made. I was mentioning reusing the runtime config functionally we already have, but I think they were moved out of terra to the provider, so that answers that question.

Ah that's what you were asking about, yeah that was moved out of the repo with the split of the qiskit-ibmq-provider: https://github.com/Qiskit/qiskit-ibmq-provider/blob/master/qiskit/providers/ibmq/credentials/configrc.py

@mtreinish mtreinish changed the title [WIP] Add user config file for local settings Add user config file for local settings Apr 15, 2019
jaygambetta
jaygambetta previously approved these changes Apr 19, 2019
Since I can't figure out a reliable way to mock open on python 3.5 and
3.6 (it works fine on 3.7) this commit just skips the tests that used to
use tempfile and sets them to skip on windows environments, since they
don't work on appveyor.
@mtreinish mtreinish added this to the 0.8 milestone Apr 24, 2019
@jaygambetta jaygambetta merged commit beeff75 into Qiskit:master Apr 30, 2019
@mtreinish mtreinish deleted the config-files branch April 30, 2019 12:42
mtreinish added a commit to mtreinish/qiskit that referenced this pull request Apr 30, 2019
In Qiskit/qiskit#2122 a new feature was added for having user
config files that let local environments override some default settings
for functions in terra. Right now this is just the circuit drawer
backend, but this will grow in the future. This commit adds
documentation on how to use this feature.
jaygambetta pushed a commit to Qiskit/qiskit-metapackage that referenced this pull request May 1, 2019
In Qiskit/qiskit#2122 a new feature was added for having user
config files that let local environments override some default settings
for functions in terra. Right now this is just the circuit drawer
backend, but this will grow in the future. This commit adds
documentation on how to use this feature.
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Add user config file for local settings

This commit adds the concept of a user config file to set local defaults
when using qiskit-terra. This enables the end user to override the
default values for some commonly used terra functions in their local
environment. Right now this only includes the backend used by the
circuit drawer, but it will be expanded in the future as more settings
with opinionated defaults are exposed. To set a config file you can
either create one in the default location
'~/.config/qiskit/settings.conf' or use the QISKIT_SETTINGS environment
variable to specify an alternative location.

* Updates

* Fix lint issues

* Fix tests on windows

* Fix lint

* Try to fix tests on python <3.7

* More testing updates

* Fix lint

* Skip tempfile tests on windows

Since I can't figure out a reliable way to mock open on python 3.5 and
3.6 (it works fine on 3.7) this commit just skips the tests that used to
use tempfile and sets them to skip on windows environments, since they
don't work on appveyor.

* Remove unused import
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.

4 participants