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 cirq specific environment variables to ionq #6216
add cirq specific environment variables to ionq #6216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update unit tests for the new logic with environment variables.
Since you'd be likely changing the tests below, can you please also replace os.environ[...] = ...
with mock.patch.dict(os.environ, {...}
?
Cirq/cirq-ionq/cirq_ionq/service_test.py
Lines 161 to 172 in b6a7087
def test_service_api_key_via_env(): | |
os.environ['IONQ_API_KEY'] = 'tomyheart' | |
service = ionq.Service(remote_host='http://example.com') | |
assert service.api_key == 'tomyheart' | |
del os.environ['IONQ_API_KEY'] | |
def test_service_remote_host_via_env(): | |
os.environ['IONQ_REMOTE_HOST'] = 'http://example.com' | |
service = ionq.Service(api_key='tomyheart') | |
assert service.remote_host == 'http://example.com' | |
del os.environ['IONQ_REMOTE_HOST'] |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #6216 +/- ##
==========================================
- Coverage 97.36% 97.36% -0.01%
==========================================
Files 1115 1116 +1
Lines 95658 95700 +42
==========================================
+ Hits 93141 93179 +38
- Misses 2517 2521 +4
☔ View full report in Codecov by Sentry. |
got it thanks! |
cirq-ionq/cirq_ionq/service_test.py
Outdated
service = ionq.Service(remote_host='http://example.com') | ||
assert service.api_key == 'tomyheart' | ||
del os.environ['IONQ_API_KEY'] | ||
with mock.patch.dict('os.environ', {'IONQ_API_KEY': 'tomyheart'}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pass os.environ
as is instead of as a string.
For these tests you can consider decorating the test method, for example,
@mock.patch.dict(os.environ, {'IONQ_API_KEY': 'tomyheart'})
def test_service_api_key_via_env():
service = ionq.Service(remote_host='http://example.com')
...
Note if needed, you can also modify os.environ
in the test function body. Any changes will be reverted when function returns and exits the patch.dict
context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use os.environ
object instead of "os.environ"
string, it will satisfy the failing lint check.
Also, CIRQ_IONQ_REMOTE_HOST
seems untested.
thanks for the help :) this latest pr should cover the changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thank you!
can specify
CIRQ_IONQ_API_KEY
to override a globalIONQ_API_KEY
environment variable.