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
Conversation
Codecov ReportBase: 30.00% // Head: 29.74% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #32 +/- ##
==========================================
- Coverage 30.00% 29.74% -0.26%
==========================================
Files 9 9
Lines 590 595 +5
Branches 98 100 +2
==========================================
Hits 177 177
- Misses 410 415 +5
Partials 3 3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure whether sys.exit is a good idea. If 'raise RuntimeError' can work, I would prefer you switch to use it. Because if someone use it as an API, 'sys.exit' will cause the caller fails.
if not wms_workflow_id: | ||
print("Missing workflow id.") | ||
print("To use the command as: bps report --id workflowid") | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead printing the error message in the plugin and exiting please return the results back to the caller, the report()
function. For example
if not wms_workflow_id:
return run_reports, "Missing workflow id. To use the command as: bps report --id <workflow_id>"
For the reasons Wen already pointed out, we don't want sys.exit()
here.
The separate issue is that I find the proposed error message slightly misleading. Calling bps report
with no arguments is a valid option. In such a case, the command is supposed to show the summary of runs the are either currently running or already finished (using a default or provided time window). As the PanDA plugin does not support it yet (but may in the future) I would suggest something like "Run summary not implemented yet, use 'bps report --id <workflow_id> instead".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change accordingly.
|
||
if not tasks: | ||
print(f"No records found for workflow id '{wms_workflow_id}'. " f"Hints: Double check id") | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, let the method propagate the results back to the caller:
if not tasks:
message = f"No records found for workflow id '{wms_workflow_id}'. Hint: double check the id"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, will be changed.
raise RuntimeError(f"Error to get workflow status: {ret} for id: {wms_workflow_id}") | ||
|
||
if not tasks: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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}") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
9bf53a1
to
74e9064
Compare
74e9064
to
60f4ba5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for me.
Checklist
doc/changes