Skip to content

Enforces specifying run_name and device_config_name on Engine interfaces#6649

Merged
senecameeks merged 7 commits into
quantumlib:mainfrom
senecameeks:u/smeeks/rm_defaults
Jun 25, 2024
Merged

Enforces specifying run_name and device_config_name on Engine interfaces#6649
senecameeks merged 7 commits into
quantumlib:mainfrom
senecameeks:u/smeeks/rm_defaults

Conversation

@senecameeks

Copy link
Copy Markdown
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 a team, cduck, verult, vtomole and wcourtney as code owners June 21, 2024 16:44

@NoureldinYosri NoureldinYosri 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.

Shouldn't this PR have the BREAKING CHANGE tag?

job_labels: Optional[Dict[str, str]] = None,
run_name: str = "",
device_config_name: str = "",
*,

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.

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@pavoljuhas pavoljuhas 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.

LGTM with a small change to docstrings.

Comment thread cirq-google/cirq_google/engine/engine_program.py Outdated
@senecameeks senecameeks added the BREAKING CHANGE For pull requests that are important to mention in release notes. label Jun 24, 2024
@senecameeks

Copy link
Copy Markdown
Collaborator Author

@NoureldinYosri added Breaking Change tag for posterity

@codecov

codecov Bot commented Jun 25, 2024

Copy link
Copy Markdown

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.

async def run_async(
self,
program: cirq.Circuit,
*,

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.

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

@pavoljuhas pavoljuhas Jun 25, 2024

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.

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
Copy Markdown
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
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