Skip to content

Enforces specifying run_name and device_config_name on Engine interfaces #6649

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

Merged
merged 7 commits into from
Jun 25, 2024

Conversation

senecameeks
Copy link
Collaborator

Removes default values and enforces specifying run_name and device_config_name

Special note that this does not disrupt the workflow

sampler = processor.get_sampler(  
        run_name="run_name", device_config_name="config_alias"
    )

sampler.run_batch([circuit] * 20, repetitions=500) 
## or
sampler.run_sweep(circuit, params=[...], repetitions=500) 

…sweep). Enforce requirement on Engine service.
@CirqBot CirqBot added the size: M 50< lines changed <250 label Jun 21, 2024
@senecameeks senecameeks marked this pull request as ready for review June 21, 2024 16:44
@senecameeks senecameeks requested review from wcourtney, vtomole, cduck, verult and a team as code owners June 21, 2024 16:44
Copy link
Collaborator

@NoureldinYosri NoureldinYosri left a comment

Choose a reason for hiding this comment

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

Shouldn't this PR have the BREAKING CHANGE tag?

@@ -64,8 +64,9 @@ async def run_async(
program_labels: Optional[Dict[str, str]] = None,
job_description: Optional[str] = None,
job_labels: Optional[Dict[str, str]] = None,
run_name: str = "",
device_config_name: str = "",
*,
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need the * here and elsewhere? what is the purpose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mainly for readability and convenience. This preserves parameter ordering and keeps the number of required changes low.

Copy link
Collaborator

Choose a reason for hiding this comment

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

On a second look, it is a bit strange to have optional positional arguments followed by mandatory kw arguments run_name, device_config_name. I tried to move the added *, just before the first optional arguments and the tests pass.

Can we do so and also move the run_name, device_name as the first arguments after *,?
The order of kw-only arguments does not matter, but for code readability it is nicer to have
mandatory arguments followed by optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! Moved.

Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

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

LGTM with a small change to docstrings.

@senecameeks senecameeks added the BREAKING CHANGE For pull requests that are important to mention in release notes. label Jun 24, 2024
@senecameeks
Copy link
Collaborator Author

@NoureldinYosri added Breaking Change tag for posterity

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.81%. Comparing base (0aae3c1) to head (0497c85).
Report is 1 commits behind head on main.

Current head 0497c85 differs from pull request most recent head ee4ae61

Please upload reports for the commit ee4ae61 to get more accurate results.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6649   +/-   ##
=======================================
  Coverage   97.81%   97.81%           
=======================================
  Files        1066     1066           
  Lines       91779    91779           
=======================================
  Hits        89773    89773           
  Misses       2006     2006           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -56,6 +56,9 @@ class AbstractProcessor(abc.ABC):
async def run_async(
self,
program: cirq.Circuit,
*,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: try to remove the * and see what breaks. if a few things break then we can fix them

Copy link
Collaborator

@pavoljuhas pavoljuhas Jun 25, 2024

Choose a reason for hiding this comment

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

nit: try to remove the * and see what breaks. if a few things break then we can fix them

This may be dangerous, because the main-branch version had 2 optional string arguments at those positions.
Requiring everything to be a kwarg will make sure that string arguments are not mixed up.

@pavoljuhas
Copy link
Collaborator

@senecameeks - please wait for #6650 to make it in and then merge it here.

@senecameeks senecameeks enabled auto-merge (squash) June 25, 2024 18:01
@senecameeks senecameeks merged commit 4b8e8e4 into quantumlib:main Jun 25, 2024
32 checks passed
BichengYing pushed a commit to BichengYing/Cirq that referenced this pull request Jun 20, 2025
…ces (quantumlib#6649)

* Remove default values from client interfaces (e.g. EngineProgram.run_sweep). Enforce requirement on Engine service.

* fix

* more test files changes

* address nits

* mv args

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGE For pull requests that are important to mention in release notes. size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants