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

V4 - fix: The timeout parameter on the QPU class is now respected. The default has been increased to 30.0 seconds #1615

Merged
merged 10 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ jobs:
coverageFile: coverage.xml
thresholdAll: 0.87
thresholdNew: 0.9
thresholdModified: 0.9
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured this was something like "If a file was modified, 90% of the modified lines must still be covered by unit tests", but it's actually "If a file was modified, the whole file must now have 90% coverage." I don't think that's super helpful, so I removed it.

token: ${{ secrets.PAT }}

test-e2e:
Expand Down
28 changes: 14 additions & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rpcq = "^3.10.0"
pydantic = "^1.10.7"
networkx = ">=2.5"
importlib-metadata = { version = ">=3.7.3,<5", python = "<3.8" }
qcs-sdk-python = "0.10.0"
qcs-sdk-python = "0.10.3-rc.1"
quil = "0.1.1"
tenacity = "^8.2.2"
types-python-dateutil = "^2.8.19"
Expand Down
8 changes: 5 additions & 3 deletions pyquil/api/_qpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(
*,
quantum_processor_id: str,
priority: int = 1,
timeout: float = 10.0,
timeout: Optional[float] = 30.0,
client_configuration: Optional[QCSClient] = None,
endpoint_id: Optional[str] = None,
execution_options: Optional[ExecutionOptions] = None,
Expand All @@ -132,7 +132,8 @@ def __init__(
:param timeout: Time limit for requests, in seconds.
:param client_configuration: Optional client configuration. If none is provided, a default one will be loaded.
:param endpoint_id: Optional endpoint ID to be used for execution.
:param use_gateway: Disable to skip the Gateway server and perform direct execution.
:param execution_options: The ``ExecutionOptions`` to use when executing a program. If provided, the options
take precedence over the `timeout` and `endpoint_id` parameters.
"""
super().__init__()

Expand All @@ -143,7 +144,8 @@ def __init__(
self._memory_results: Dict[str, Optional[np.ndarray]] = defaultdict(lambda: None)
self._quantum_processor_id = quantum_processor_id
if execution_options is None:
execution_options_builder = ExecutionOptionsBuilder()
execution_options_builder = ExecutionOptionsBuilder.default()
execution_options_builder.timeout_seconds = timeout
execution_options_builder.connection_strategy = ConnectionStrategy.default()
if endpoint_id is not None:
execution_options_builder.connection_strategy = ConnectionStrategy.endpoint_id(endpoint_id)
Expand Down
23 changes: 23 additions & 0 deletions test/unit/test_qpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from pyquil.api import ConnectionStrategy, ExecutionOptions
from pyquil.api._qpu import QPU


def test_default_execution_options():
qpu = QPU(quantum_processor_id="test", timeout=15.0, endpoint_id="endpoint-id")

builder = ExecutionOptions.builder()
builder.timeout_seconds = 15.0
builder.connection_strategy = ConnectionStrategy.endpoint_id("endpoint-id")
expected = builder.build()

assert qpu.execution_options == expected


def test_provided_execution_options():
builder = ExecutionOptions.builder()
builder.timeout_seconds = 15.0
builder.connection_strategy = ConnectionStrategy.direct_access()
options = builder.build()

qpu = QPU(quantum_processor_id="test", execution_options=options)
assert qpu.execution_options == options
Loading