Fix docs/google snippet error and add to snippets_test#7803
Fix docs/google snippet error and add to snippets_test#7803pavoljuhas merged 14 commits intoquantumlib:mainfrom
Conversation
1. Use test substitution to replace undefined variables 2. Use test substitution to replace cloud APIs with mock class 3. Fix EngineJob constructor Partially fix quantumlib#7787.
1. Use test substitution to replace undefined variables 2. Use test substitution to replace cloud APIs with mock class 3. Fix unexpected indent and import Partially fix quantumlib#7787.
1. Use test substitution to replace undefined variables 2. Use test substitution to replace cloud APIs with mock class 3. Fix outdated import paths Partially fix quantumlib#7787.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7803 +/- ##
=======================================
Coverage 99.62% 99.62%
=======================================
Files 1104 1104
Lines 99317 99325 +8
=======================================
+ Hits 98943 98951 +8
Misses 374 374 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add all md files under docs/google to run the snippets_test, also add necessary import (like cirq_google).
Allow more mockery than just MagicMock.
- use `create_autospec` so mocked objects fail when asked for attributes or passed arguments that are invalid in real objects - remove non-existing `gate_set` argument from engine.run_sweep
- fix typo in `EngineProcessor.list_calibrations` name - disable and add a TODO note for obsolete example that uses the deleted `Engine.get_job` function
Adjust example to use qubits present on the willow_pink device.
pavoljuhas
left a comment
There was a problem hiding this comment.
I have adjusted the mocks to mimic interfaces of real objects which allows to find cases when calling non-existing function or passing wrong number of arguments. For the specification.md it was possible to use virtual engine instead a mock.
@ToastCheng - can you please take a quick look if the PR is good with you? Otherwise LGTM.
No change in actual content.
No change in actual content.
ToastCheng
left a comment
There was a problem hiding this comment.
Just one minor comment. Please check, thanks!
| def find_markdown_test_overrides(content: str) -> list[tuple[Pattern, str]]: | ||
| test_sub_text = find_code_snippets("<!---test_substitution\n(.*?)--->", content) | ||
| substitutions = [line.split('\n')[:-1] for line, _ in test_sub_text] | ||
| substitutions = [line.rstrip().split('\n', maxsplit=1) for line, _ in test_sub_text] |
There was a problem hiding this comment.
Since the behavior changed, maybe add a short explanation?
"""This function finds all the `<!---test_substitution-->` blocks in `content`, and replace `pattern` with `substitutions`:
```
<!---test_substitution
pattern
substitutions
-->
```
noted that `substitutions` could be a multi-line string because `maxsplit` is set to 1, while `pattern` is strictly to be a single line string.
"""
And also note expansion of the `re.sub` escape sequences.
Similar to quantumlib#7803, this commit fix the errors from the temporarily excluded md files. 1. Use mocked Service instance for ionq documents 2. Remove the outdated Circuit initialization in pasqal doc, the device argument has been removed since quantumlib#5189.
Similar to #7803, this commit fix the errors from the temporarily excluded md files. 1. Use mocked Service instance for ionq documents 2. Remove the outdated Circuit initialization in pasqal doc, the device argument has been removed since #5189. Fixes #7787 --------- Co-authored-by: Pavol Juhas <juhas@google.com>
The PR fixes the md files' snippet errors under docs/google by adding test substitution and MagicMock, also fixing some outdated APIs. On the test side, adding necessary imports for cirq_google to let the tests being able to find necessary variables.
This also extends the
test_substitutionmarkup to allow multi-line replacement text.Partially implements #7787