Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yi Gu committed Dec 17, 2024
1 parent 5b1cd6b commit 28c7020
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 17 deletions.
14 changes: 1 addition & 13 deletions azure-quantum/azure/quantum/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,6 @@ def list_session_jobs(
self,
session_id: str,
name_match: Optional[str] = None,
job_type: Optional[str]= None,
provider: Optional[list[str]]= None,
target: Optional[list[str]]= None,
status: Optional[list[JobStatus]] = None
) -> List[Job]:
"""
Expand All @@ -821,10 +818,7 @@ def list_session_jobs(
"""
paginator = self.list_session_jobs_paginated(
session_id=session_id,
name_match=name_match,
job_type=job_type,
provider=provider,
target=target,
name_match=name_match,
status=status)

result = [Job(workspace=self, job_details=job_details)
Expand All @@ -835,9 +829,6 @@ def list_session_jobs_paginated(
self,
session_id: str,
name_match: Optional[str] = None,
job_type: Optional[str]= None,
provider: Optional[list[str]]= None,
target: Optional[list[str]]= None,
status: Optional[list[JobStatus]] = None,
skip: Optional[int] = 0,
page_size: Optional[int]=100,
Expand All @@ -857,9 +848,6 @@ def list_session_jobs_paginated(

session_job_filter = self._create_filter(
job_name=name_match,
job_type=job_type,
provider_ids=provider,
target=target,
status=status
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- testapp azsdk-python-quantum/1.0.0b1 Python/3.9.20 (Windows-10-10.0.26100-SP0)
x-ms-quantum-api-key:
- PLACEHOLDER
method: GET
uri: https://eastus.quantum.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Quantum/workspaces/myworkspace/sessions/00000000-0000-0000-0000-000000000001/jobs?api-version=2024-10-01-preview&filter=%28State%20eq%20%27Succeeded%27%29&skip=0&top=100&test-sequence-id=1
response:
body:
string: '{"value": [{"containerUri": "https://mystorage.blob.core.windows.net/job-aac2262b-f786-11ee-a6fd-aa03815e5e6b?sv=PLACEHOLDER&sig=PLACEHOLDER&se=2050-01-01T00%3A00%3A00Z&srt=co&ss=b&sp=racwl",
"inputDataUri": "https://mystorage.blob.core.windows.net/job-aac2262b-f786-11ee-a6fd-aa03815e5e6b/inputData?sv=PLACEHOLDER&sr=b&sig=PLACEHOLDER&se=2050-01-01T00%3A00%3A00Z&sp=rcw",
"inputDataFormat": "qir.v1", "inputParams": {"entryPoint": "ENTRYPOINT__main",
"arguments": [], "targetCapability": "AdaptiveExecution"}, "metadata": null,
"sessionId": "00000000-0000-0000-0000-000000000001", "status": "Succeeded",
"jobType": "QuantumComputing", "outputDataFormat": "microsoft.quantum-results.v1",
"outputDataUri": "https://mystorage.blob.core.windows.net:443/job-aac2262b-f786-11ee-a6fd-aa03815e5e6b/outputData?sv=PLACEHOLDER&sig=PLACEHOLDER&se=2050-01-01T00%3A00%3A00Z&srt=co&ss=b&sp=racwl",
"beginExecutionTime": "2024-04-10T22:07:31.829789Z", "cancellationTime": null,
"quantumComputingData": {"count": 1}, "errorData": null, "isCancelling": false,
"tags": [], "name": "Job 1", "id": "aac2262b-f786-11ee-a6fd-aa03815e5e6b",
"providerId": "quantinuum", "target": "quantinuum.sim.h1-1e", "creationTime":
"2024-04-10T22:07:09.218404Z", "endExecutionTime": "2024-04-10T22:07:32.697602Z",
"costEstimate": {"currencyCode": "USD", "events": [{"dimensionId": "ehqc",
"dimensionName": "EHQC", "measureUnit": "hqc", "amountBilled": 5.01, "amountConsumed":
5.01, "unitPrice": 0.0}], "estimatedTotal": 0.0}, "itemType": "Job"}, {"containerUri":
"https://mystorage.blob.core.windows.net/job-acfb73ea-f786-11ee-b346-aa03815e5e6b?sv=PLACEHOLDER&sig=PLACEHOLDER&se=2050-01-01T00%3A00%3A00Z&srt=co&ss=b&sp=racwl",
"inputDataUri": "https://mystorage.blob.core.windows.net/job-acfb73ea-f786-11ee-b346-aa03815e5e6b/inputData?sv=PLACEHOLDER&sr=b&sig=PLACEHOLDER&se=2050-01-01T00%3A00%3A00Z&sp=rcw",
"inputDataFormat": "qir.v1", "inputParams": {"entryPoint": "ENTRYPOINT__main",
"arguments": [], "targetCapability": "AdaptiveExecution"}, "metadata": null,
"sessionId": "00000000-0000-0000-0000-000000000001", "status": "Succeeded",
"jobType": "QuantumComputing", "outputDataFormat": "microsoft.quantum-results.v1",
"outputDataUri": "https://mystorage.blob.core.windows.net:443/job-acfb73ea-f786-11ee-b346-aa03815e5e6b/outputData?sv=PLACEHOLDER&sig=PLACEHOLDER&se=2050-01-01T00%3A00%3A00Z&srt=co&ss=b&sp=racwl",
"beginExecutionTime": "2024-04-10T22:07:36.840055Z", "cancellationTime": null,
"quantumComputingData": {"count": 1}, "errorData": null, "isCancelling": false,
"tags": [], "name": "Job 2", "id": "acfb73ea-f786-11ee-b346-aa03815e5e6b",
"providerId": "quantinuum", "target": "quantinuum.sim.h1-1e", "creationTime":
"2024-04-10T22:07:24.2220056Z", "endExecutionTime": "2024-04-10T22:07:37.710831Z",
"costEstimate": {"currencyCode": "USD", "events": [{"dimensionId": "ehqc",
"dimensionName": "EHQC", "measureUnit": "hqc", "amountBilled": 5.01, "amountConsumed":
5.01, "unitPrice": 0.0}], "estimatedTotal": 0.0}, "itemType": "Job"}], "nextLink":
null}'
headers:
connection:
- keep-alive
content-length:
- '3028'
content-type:
- application/json; charset=utf-8
transfer-encoding:
- chunked
status:
code: 200
message: OK
version: 1
17 changes: 13 additions & 4 deletions azure-quantum/tests/unit/test_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,19 @@ def test_list_session_jobs_filtered_by_name(self):
check_job_name = job.details.name.startswith("Job")
self.assertTrue( check_job_name, job.details.name)

# job_type: Optional[str]= None,
# provider: Optional[list[str]]= None,
# target: Optional[list[str]]= None,
# status: Optional[list[JobStatus]] = None
@pytest.mark.live_test
def test_list_session_jobs_filtered_by_status(self):
session_id = "aa9da17d-f786-11ee-a6f7-aa03815e5e6b"

ws = self.create_workspace()
jobs = ws.list_session_jobs(session_id=session_id, status=["Succeeded"])

for job in jobs:
self.assertEqual(job.item_type, "Job")
self.assertEqual(job._details.session_id, session_id)

check_job_status = job.details.status == "Succeeded"
self.assertTrue( check_job_status, job.details.status)

@pytest.mark.live_test
def test_list_top_level_items(self):
Expand Down

0 comments on commit 28c7020

Please sign in to comment.