Skip to content

fix #1032 Exclusive Access: show validation error #1035

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

Merged
merged 18 commits into from
Jun 23, 2025
Merged
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
33 changes: 27 additions & 6 deletions src/bloqade/analog/task/exclusive.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
else:
print(f"HTTP request failed with status code: {response.status_code}")
print("HTTP responce: ", response.text)
return "Failed"
return "HTTP Request Failed"

Check warning on line 105 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L105

Added line #L105 was not covered by tests

def query_task_status(self, task_id: str):
response = request(
Expand All @@ -115,21 +115,39 @@
},
)
if response.status_code != 200:
return "Not Found"
return "HTTP Request Failed."

Check warning on line 118 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L118

Added line #L118 was not covered by tests
response_data = response.json()
# Get "matched" from the response
matches = response_data.get("matches", None)
# The return is a list of dictionaries
# Verify if the list contains only one element
if matches is None:
print("No task found with the given ID.")
return "Failed"
return "Task searching Failed"

Check warning on line 126 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L126

Added line #L126 was not covered by tests
elif len(matches) > 1:
print("Multiple tasks found with the given ID.")
return "Failed"
return "Task searching Failed"

Check warning on line 129 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L129

Added line #L129 was not covered by tests

record = matches[0]

Check warning on line 131 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L131

Added line #L131 was not covered by tests

# Extract the status from the first dictionary
status = matches[0].get("status")
status = record.get("status")

Check warning on line 134 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L134

Added line #L134 was not covered by tests

if status == "Failed validation":
googledoc = record.get("resultsFileUrl")

Check warning on line 137 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L136-L137

Added lines #L136 - L137 were not covered by tests

# convert the preview URL to download URL
googledoc = convert_preview_to_download(googledoc)
res = get(googledoc)
res.raise_for_status()
data = res.json()

Check warning on line 143 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L140-L143

Added lines #L140 - L143 were not covered by tests
# get the "statusCode" and "message" from the data and print them out.
status_code = data.get("statusCode", "NA")
message = data.get("message", "NA")
print(

Check warning on line 147 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L145-L147

Added lines #L145 - L147 were not covered by tests
f"Task validation failed with status code: {status_code}, message: {message}"
)

return status

def fetch_results(self, task_id: str):
Expand Down Expand Up @@ -283,7 +301,10 @@
return QuEraTaskStatusCode.Unsubmitted
res = self._http_handler.query_task_status(self._task_id)
if res == "Failed":
raise ValueError("Query task status failed.")
return QuEraTaskStatusCode.Failed
elif res == "Failed validation":

Check warning on line 305 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L304-L305

Added lines #L304 - L305 were not covered by tests

return QuEraTaskStatusCode.Failed

Check warning on line 307 in src/bloqade/analog/task/exclusive.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/task/exclusive.py#L307

Added line #L307 was not covered by tests
elif res == "Submitted":
return QuEraTaskStatusCode.Enqueued
# TODO: please add all possible status
Expand Down