Skip to content

Functions client unification to runtime - part 1\n#2187

Open
ItamarGoldman wants to merge 27 commits into
mainfrom
instance_validation_client
Open

Functions client unification to runtime - part 1\n#2187
ItamarGoldman wants to merge 27 commits into
mainfrom
instance_validation_client

Conversation

@ItamarGoldman

@ItamarGoldman ItamarGoldman commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Functions client unification to runtime - part 1\n

Summary

validating instance access to Qiskit IBM Runtime client via authentication process.

Details and comments

  • using runtime client as the service of the client IBMServerlessClient.
  • Add release notes - authentication to the cloud (instance) is done through QiskitRuntimeService

@ItamarGoldman ItamarGoldman self-assigned this Jun 3, 2026
@ItamarGoldman ItamarGoldman force-pushed the instance_validation_client branch from 784a499 to bff8e15 Compare June 8, 2026 10:06
@ItamarGoldman ItamarGoldman force-pushed the instance_validation_client branch from abf22b0 to 70a99fe Compare June 10, 2026 11:31
@ItamarGoldman ItamarGoldman force-pushed the instance_validation_client branch from 70a99fe to 77ae99d Compare June 10, 2026 11:34
@ItamarGoldman ItamarGoldman force-pushed the instance_validation_client branch from b53df88 to 8217527 Compare June 10, 2026 12:51
@ItamarGoldman ItamarGoldman force-pushed the instance_validation_client branch 2 times, most recently from 6243031 to 25071e5 Compare June 10, 2026 14:46
@ItamarGoldman ItamarGoldman force-pushed the instance_validation_client branch from 25071e5 to 071fc64 Compare June 10, 2026 15:03
@ItamarGoldman ItamarGoldman force-pushed the instance_validation_client branch from c0db364 to 254d10f Compare June 11, 2026 08:26
@ItamarGoldman ItamarGoldman marked this pull request as ready for review June 11, 2026 10:52
@ItamarGoldman ItamarGoldman requested a review from a team as a code owner June 11, 2026 10:52
@ItamarGoldman ItamarGoldman changed the title [WIP] Functions client unification to runtime - part 1\n Functions client unification to runtime - part 1\n Jun 11, 2026

@HuangJunye HuangJunye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great! I left a few comments to understand the changes better.

name=name,
)

channel = channel or Channel.IBM_QUANTUM_PLATFORM.value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we need or Channel.IBM_QUANTUM_PLATFORM.value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Comment on lines +32 to +42
# 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",
}
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not very familiar with this part. Is the mock_list_instances mocking the instances returned by calling CloudAccount.list_instances?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yes, essentially, it's avoiding the API calls by CloudAccount.list_instances

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think that on our side this test is fine, this code would match the error even if they added the missing '

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 ElePT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Mostly LGTM! I left some minor suggestions and comments to the earlier review.

name=name,
)

channel = channel or Channel.IBM_QUANTUM_PLATFORM.value

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Comment on lines +32 to +42
# 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",
}
]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think that on our side this test is fine, this code would match the error even if they added the missing '

Comment on lines +74 to +79
"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",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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::

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are absolutely correct! Thanks!

Comment on lines +112 to +116
"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",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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_instance

Essentially checks:

mock_list_instances.return_value["crn"] == mock_list_instances.return_value["name"] 

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.

3 participants