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

Conversation

zhaoyuyoung
Copy link
Contributor

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@codecov
Copy link

codecov bot commented Dec 14, 2022

Codecov Report

Base: 30.00% // Head: 29.74% // Decreases project coverage by -0.25% ⚠️

Coverage data is based on head (60f4ba5) compared to base (2456b8c).
Patch coverage: 0.00% of modified lines in pull request are covered.

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              
Impacted Files Coverage Δ
python/lsst/ctrl/bps/panda/panda_service.py 16.08% <0.00%> (-0.36%) ⬇️

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@wguanicedew wguanicedew left a 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)
Copy link
Collaborator

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".

Copy link
Contributor Author

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)
Copy link
Collaborator

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"

Copy link
Contributor Author

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:
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.

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.

@zhaoyuyoung zhaoyuyoung force-pushed the tickets/DM-37298 branch 3 times, most recently from 9bf53a1 to 74e9064 Compare December 15, 2022 18:43
Copy link
Contributor

@wguanicedew wguanicedew left a 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.

@zhaoyuyoung zhaoyuyoung merged commit 35b5d61 into main Dec 16, 2022
@zhaoyuyoung zhaoyuyoung deleted the tickets/DM-37298 branch December 16, 2022 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants