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

Return processor_id and project_id in get_qcs_objects_for_notebooks #5759

Merged
merged 7 commits into from
Jul 14, 2022

Conversation

dstrain115
Copy link
Collaborator

This adds two fields in the QCSObjectForNotebook

This will allow us some flexibility in google notebooks so as not to specify the processor_id. This will also be a step in enabling tests for these notebooks.

@dstrain115 dstrain115 requested review from wcourtney, a team, vtomole, cduck and verult as code owners July 13, 2022 21:49
@CirqBot CirqBot added the size: S 10< lines changed <50 label Jul 13, 2022
@@ -17,11 +17,13 @@


def test_get_device_sampler():
result = get_qcs_objects_for_notebook()
assert result.device is cg.Sycamore
result = get_qcs_objects_for_notebook('not_a_valid_project_name')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add tests using the new fields, or would that break some QCS behavior?

@@ -17,11 +17,13 @@


def test_get_device_sampler():
result = get_qcs_objects_for_notebook()
assert result.device is cg.Sycamore
result = get_qcs_objects_for_notebook('not_a_valid_project_name')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it'd be good for the tests to continue to exercise the no-arguments call variant. Perhaps we can do both? (We already exercise passing both arguments on line 28 below.)

@dstrain115
Copy link
Collaborator Author

Ok. This is really tricky to test, since it involves authentication. If you test it locally and you have application default credentials, you are signed in as well, which further complicates things. Let me see what I can do.

@dstrain115
Copy link
Collaborator Author

Tweaked the tests a bit. PTAL

@@ -63,8 +63,7 @@ def get_qcs_objects_for_notebook(
# Check for Google Application Default Credentials and run
# interactive login if the notebook is executed in Colab. In
# case the notebook is executed in Jupyter notebook or other
# IPython runtimes, no interactive login is provided, it is
# assumed that the `GOOGLE_APPLICATION_CREDENTIALS` env var is

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unintended deletion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed..

@@ -96,17 +100,18 @@ def get_qcs_objects_for_notebook(
print(f"Available processors: {[p.processor_id for p in processors]}")
print(f"Using processor: {processor.processor_id}")
if not project_id:
project_id = processor.project_id
project_id = getattr(processor, 'project_id', getattr(processor, '_project_name', None))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this instead use is_virtual to determine the default project_id?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added this to AbstractLocalProcessor instead.

Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

Couple of nits but I'm happy with the new tests.

@dstrain115
Copy link
Collaborator Author

Tweaked things a bit so that it only returns virtual or prod, not the PhasedFSim simulator. Also upped the tests so that it covers all the lines and fixes the pylint stuff.

@dstrain115 dstrain115 added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 14, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 14, 2022
@CirqBot CirqBot merged commit c7234ae into quantumlib:master Jul 14, 2022
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jul 14, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…uantumlib#5759)

This adds two fields in the QCSObjectForNotebook

This will allow us some flexibility in google notebooks so as not to specify the processor_id.  This will also be a step in enabling tests for these notebooks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants