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

DM-37298 Add usage message for bps report in PanDA plugin #32

Merged
merged 1 commit into from
Dec 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions python/lsst/ctrl/bps/panda/panda_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,21 @@ def report(self, wms_workflow_id=None, user=None, hist=0, pass_thru=None, is_glo
message = ""
run_reports = []

if not wms_workflow_id:
message = "Run summary not implemented yet, use 'bps report --id <workflow_id>' instead"
return run_reports, message

idds_client = self.get_idds_client()
ret = idds_client.get_requests(request_id=wms_workflow_id, with_detail=True)
_LOG.debug("PanDA get workflow status returned = %s", str(ret))

request_status = ret[0]
tasks = ret[1][1]
if request_status != 0 or not tasks:
if request_status != 0:
raise RuntimeError(f"Error to get workflow status: {ret} for id: {wms_workflow_id}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just FYI, I realized that this exception will not be handled by the method's caller, the report() function. As a result, the user will see entire traceback that lead to this error. And that may be perfectly fine in this case as I'm assuming the issues with iDDS sever are important enough that it is better to provide entire traceback instead of the brief error message. However, if this is not a critical error you still may want just to pass the error message like any other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. For this exception, I leave it as is.


tasks = ret[1][1]
if not tasks:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm really nitpicking here, but can we please move line 423 just before this if statement, so the definition of the variable is closer to its usage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved. I know it's better for reading.

message = f"No records found for workflow id '{wms_workflow_id}'. Hint: double check the id"
else:
head = tasks[0]
wms_report = WmsRunReport(
Expand Down