Functions client unification to runtime - part 1\n#2187
Conversation
784a499 to
bff8e15
Compare
abf22b0 to
70a99fe
Compare
70a99fe to
77ae99d
Compare
b53df88 to
8217527
Compare
6243031 to
25071e5
Compare
25071e5 to
071fc64
Compare
c0db364 to
254d10f
Compare
HuangJunye
left a comment
There was a problem hiding this comment.
This looks great! I left a few comments to understand the changes better.
| name=name, | ||
| ) | ||
|
|
||
| channel = channel or Channel.IBM_QUANTUM_PLATFORM.value |
There was a problem hiding this comment.
why do we need or Channel.IBM_QUANTUM_PLATFORM.value?
There was a problem hiding this comment.
That is here because it was behavior _discover_accountused previously. Essentially, it means that it can't be None (even if the user try to force None on it it will be set). We can remove it as it is just to keep the previous behavior.
There was a problem hiding this comment.
I vote for keeping it. When in doubt it's better to respect the former behavior. @ItamarGoldman maybe you could add a comment explaining that this is to maintain backwards compatibility?
| # Mock list of instance crns in the IBM Cloud Global | ||
| mock_list_instances.return_value = [ | ||
| { | ||
| "crn": "my_instance", | ||
| "plan": "test_plan", | ||
| "name": "my_instance", | ||
| "tags": "test_tags", | ||
| "pricing_type": "test_pricing_type", | ||
| } | ||
| ] | ||
|
|
There was a problem hiding this comment.
I am not very familiar with this part. Is the mock_list_instances mocking the instances returned by calling CloudAccount.list_instances?
There was a problem hiding this comment.
yes, essentially, it's avoiding the API calls by CloudAccount.list_instances
There was a problem hiding this comment.
Yes. The method retrieve all crns with the IBM Cloud Global Search API. I made a mock return value for it.
| use_token = "save_token" | ||
|
|
||
| with pytest.raises(ValueError, match=r"Your channel value is not correct"): | ||
| # The error message miss a ' at the end but that is the message in qiskit ibm runtime |
There was a problem hiding this comment.
Hmm, can you file an issue in qiskit-ibm-runtime? Perhaps we should make this more robust. Is it possible to not match exact phrase?
There was a problem hiding this comment.
I think that on our side this test is fine, this code would match the error even if they added the missing '
There was a problem hiding this comment.
I can open an issue regarding the text.
About making the test more robust, I can check the a ValueError is raised but not check the message. Here I wanted to check there is ValueError exception and that it is regarding the channel value (and not for other values).
Maybe this test is redundant since it checks that qiskit_ibm_runtime raise this error. WDYT?
ElePT
left a comment
There was a problem hiding this comment.
Mostly LGTM! I left some minor suggestions and comments to the earlier review.
| name=name, | ||
| ) | ||
|
|
||
| channel = channel or Channel.IBM_QUANTUM_PLATFORM.value |
There was a problem hiding this comment.
I vote for keeping it. When in doubt it's better to respect the former behavior. @ItamarGoldman maybe you could add a comment explaining that this is to maintain backwards compatibility?
| # Mock list of instance crns in the IBM Cloud Global | ||
| mock_list_instances.return_value = [ | ||
| { | ||
| "crn": "my_instance", | ||
| "plan": "test_plan", | ||
| "name": "my_instance", | ||
| "tags": "test_tags", | ||
| "pricing_type": "test_pricing_type", | ||
| } | ||
| ] | ||
|
|
There was a problem hiding this comment.
yes, essentially, it's avoiding the API calls by CloudAccount.list_instances
| use_token = "save_token" | ||
|
|
||
| with pytest.raises(ValueError, match=r"Your channel value is not correct"): | ||
| # The error message miss a ' at the end but that is the message in qiskit ibm runtime |
There was a problem hiding this comment.
I think that on our side this test is fine, this code would match the error even if they added the missing '
| "crn": "crn:v1:bluemix:public:cloud-object-storage:global:a/59bcbfa6ea2f006b4ed7094c1a08dcdd:" | ||
| "1a0ec336-f391-4091-a6fb-5e084a4c56f4:bucket:mybucket", | ||
| "plan": "test_plan", | ||
| "name": "my_instance_crn", | ||
| "tags": "test_tags", | ||
| "pricing_type": "test_pricing_type", |
There was a problem hiding this comment.
if you want to try sth more realistic, instead of a cloud object storage, I think that you should try with a quantum-ish CRN: crn:v1:bluemix:public:quantum-computing:us-east:a/my-crn::
There was a problem hiding this comment.
You are absolutely correct! Thanks!
| "crn": "dummy_hub/dummy_group/dummy_project", | ||
| "plan": "test_plan", | ||
| "name": "dummy_hub/dummy_group/dummy_project", | ||
| "tags": "test_tags", | ||
| "pricing_type": "test_pricing_type", |
There was a problem hiding this comment.
the CRN should not be hub/group/project. this was the old way of doing things (if you find any other reference, you should remove it). The name should also be sth like "test_name" rather than H/G/P
There was a problem hiding this comment.
I will change it. It was written like this because of prior test data. The reason is because when the CRN value doesn't start with crn, it search by name and then it extract the CRN value so:
client.account.instance == use_instanceEssentially checks:
mock_list_instances.return_value["crn"] == mock_list_instances.return_value["name"]
Functions client unification to runtime - part 1\n
Summary
validating instance access to Qiskit IBM Runtime client via authentication process.
Details and comments
IBMServerlessClient.QiskitRuntimeService