|
| 1 | +"""Tests related to running jobs.""" |
| 2 | + |
| 3 | +import uuid |
| 4 | +from datetime import datetime |
| 5 | + |
| 6 | +import pytest |
| 7 | +from quantinuum_schemas.models.backend_config import SeleneConfig |
| 8 | + |
| 9 | +import qnexus as qnx |
| 10 | +from qnexus.models.annotations import Annotations |
| 11 | +from qnexus.models.references import ( |
| 12 | + HUGRRef, |
| 13 | + ProjectRef, |
| 14 | +) |
| 15 | + |
| 16 | + |
| 17 | +@pytest.mark.parametrize( |
| 18 | + "n_shots, max_cost, n_qubits, error_param", |
| 19 | + [ |
| 20 | + ([10], [10, 20], [5, 10], "n_shots"), |
| 21 | + ([10, 20], [10], [5, 10], "max_cost"), |
| 22 | + ([10, 20], [10, 20], [5], "n_qubits"), |
| 23 | + ], |
| 24 | +) |
| 25 | +def test_job_parameterization( |
| 26 | + n_shots: list[int], |
| 27 | + max_cost: list[float], |
| 28 | + n_qubits: list[int], |
| 29 | + error_param: str, |
| 30 | +) -> None: |
| 31 | + """Test that we can parameterize max_cost and n_qubits for a Hugr program submission.""" |
| 32 | + |
| 33 | + my_proj = ProjectRef( |
| 34 | + id=uuid.uuid4(), annotations=Annotations(), contents_modified=datetime.now() |
| 35 | + ) |
| 36 | + |
| 37 | + hugr_ref = HUGRRef( |
| 38 | + id=uuid.uuid4(), |
| 39 | + annotations=Annotations(), |
| 40 | + project=my_proj, |
| 41 | + ) |
| 42 | + |
| 43 | + with pytest.raises( |
| 44 | + ValueError, match=f"Number of programs must equal number of {error_param}." |
| 45 | + ): |
| 46 | + qnx.start_execute_job( |
| 47 | + programs=[hugr_ref, hugr_ref], |
| 48 | + n_shots=n_shots, |
| 49 | + backend_config=SeleneConfig(), |
| 50 | + project=my_proj, |
| 51 | + name="This job will never run", |
| 52 | + max_cost=max_cost, |
| 53 | + n_qubits=n_qubits, |
| 54 | + ) |
0 commit comments