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

Google tutorial docs boilerplate #4260

Closed
mpharrigan opened this issue Jun 24, 2021 · 5 comments · Fixed by #4286
Closed

Google tutorial docs boilerplate #4260

mpharrigan opened this issue Jun 24, 2021 · 5 comments · Fixed by #4286
Labels
area/google/engine good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/health For CI/testing/release process/refactoring/technical debt items

Comments

@mpharrigan
Copy link
Collaborator

There's quite a wall of boilerplate code to go along with the cirq.google tutorials to handle the various cases: [simulator, engine] x [colab, ipython, other] x [explicitly set, environment variable].

We should factor this out into a library function that you can call to do auth and get a device and sampler (and maybe an engine? we don't have a simulator analog of engine)

@mpharrigan mpharrigan added the kind/health For CI/testing/release process/refactoring/technical debt items label Jun 24, 2021
@balopat balopat added area/google/engine good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. labels Jun 24, 2021
@balopat
Copy link
Contributor

balopat commented Jun 25, 2021

I'm totally pro this change, it would cut a lot of the cirq.google notebooks. I think this would be an ideal starter project for someone.

@AnimeshSinha1309
Copy link
Contributor

Can you please give an example of such boilerplate code, I want to pick up this issue, but I am new and not sure of what tutorial exactly is being talked about.

@mpharrigan
Copy link
Collaborator Author

e.g. cell 3 of https://github.com/quantumlib/Cirq/blob/master/docs/tutorials/google/floquet_calibration_example.ipynb

@AnimeshSinha1309
Copy link
Contributor

AnimeshSinha1309 commented Jul 2, 2021

def get_auth_device_sampler(project_id=None, processor_id=None):
    # Body of the function
    return device, sampler, line_length

Are these the tasks I am supposed to perform?

  1. Make a function in the form of the prototype above
  2. Add it to some file, presumably cirq_google/engine/engine.py
  3. Remove all print statements in the body of the function, add logging if necessary, except for Google Colab authentication
  4. Use the new function to update the code in notebooks.

Should the line-length be in the final return type, and are the rest of the steps correct?

@AnimeshSinha1309
Copy link
Contributor

AnimeshSinha1309 commented Jul 5, 2021

I am facing the following issues in executing these plans, I have made a PR of my current state, could someone please let me know if I am on the right track and how to resolve these two issue? Thanks.

The code that was copied from the tutorials includes IPython and google.colab, both of which do not have type hints. I am unable to add my stubs. This is what is making the Type check fail.
The other issue is the coverage, the authenticate_user method actually attempts to authenticate on Google cloud, I cannot provide a test project id and processor.

Rest of the work on the PR seems to be complete to me.

CirqBot pushed a commit that referenced this issue Sep 14, 2021
…ls (#4286)

Code from the tutorial notebooks has been abstracted out into a function in the `cirq_google` library.
The function goes by the name `cirq_google.engine.engine_sampler.get_device_sampler()`
All the notebooks are being refactored to use this abstraction.
Closes #4260.
rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
…ls (quantumlib#4286)

Code from the tutorial notebooks has been abstracted out into a function in the `cirq_google` library.
The function goes by the name `cirq_google.engine.engine_sampler.get_device_sampler()`
All the notebooks are being refactored to use this abstraction.
Closes quantumlib#4260.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/google/engine good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/health For CI/testing/release process/refactoring/technical debt items
Projects
None yet
3 participants