Handling Errors¶
You Will Learn:
How errors are raised before a request is submitted
How errors are reported for individual samples after submission
How to check whether a result is valid before accessing it
Errors can occur at several stages of a ServiceX request: before submission, during transformation, or when retrieving results.
Errors Before Submission¶
Errors detected before submission raise an exception immediately and nothing is sent to the backend:
If the request cannot be parsed, a
ValidationErroris raised.If the request contains invalid values, an appropriate exception (
ValueError,RuntimeError,TypeError, orNameError) is raised.If the authentication information in the
.servicexorservicex.yamlfile is incorrect, anAuthorizationErroris raised.
Errors During Transformation¶
Sometimes errors occur during the transformation on the backend. These errors occur when the python code cannot check for them, for example, trying to open a container in an xAOD that is not there. These errors are a little tricky to find the full log. Here are the steps to find the log:
Step 1:
Step 2:
Step 3:
Errors After Submission¶
When deliver() returns, each sample’s result is a GuardList. A GuardList behaves like a normal list when the sample succeeded, but raises a ReturnValueException if accessed after a failure. This allows successful results to be accessed while failed ones are flagged.
The validity of a result can be checked before accessing it:
results = deliver(spec)
for name, result in results.items():
if result.valid():
# process result
else:
# handle failure
Common causes of post-submission errors include canceled or failed transformations, incomplete file processing, and download failures (such as insufficient disk space or connection problems). In all cases, failed results are not cached — resubmitting will send a new transformation request.