Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Feature/custom exit codes in tools #2566
Feature/custom exit codes in tools #2566
Changes from 4 commits
e02efee
ac232fb
628e81f
2663085
8fef3fd
636d451
bbe607c
6925244
42ecb4c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
the original plan was to not allow any random exit code, only a pre-defined set. If we need to have arbitrary exit codes (I guess the use case here is for workflow handling?), at the very least the code that was used should be stored in the provenance. Just recording "SystemExit" loses the reason for the exit happening. So we should either add a field to the provenance, or include the code in the status. The latter is less ideal since it would require parsing, and means the sets of possible status values is not finite
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.
Yes, the use case here is workflow handling. And the exit codes should not be completely randomly, but rather controlled by the corresponding ICD in our case. However, given that
ctapipe
is a community product, I'm a bit hesitant to introduce such a dependency here. On the other hand, I fully agree with your point that the exit code should be stored in provenance. Here before making a move, I'd like to discuss options.So far, the possible statuses are
["completed", "interrupted", "error"]
plus "SystemExit" I've added. I'm not sure what the subsequent purpose of this field. Is it just a human-readable label? If so, I would add another field,exit_code
or justcode
where an actual exit code will be stored and change the list of possible statuses to["success", "interrupted", "error", "partial_success"]
or similar. On the other hand, if thestatus
field is supposed to be machine-readable, shall it just keep the exit code value?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 think
SystemExit
is not needed. The only reason to have a non-zero exit code is by definition some kind of "error".Yes, I think adding the
exit_code
field is the way to go.The problem is a bit that in the current scheme,
Acitivity
is not mapped one-to-one to a command-line tool.I think that's a bit hard to define at the
Tool
logic-level, however, what we could do is to let the implementation set this status alreadyProvenance().current_acitvity.status = "partial_success"
and in that case we don't override it inTool.run
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.
Perhaps, this should be default in the
_ActivityProvenance
helper class constructor:ctapipe/src/ctapipe/core/provenance.py
Lines 220 to 230 in 2b70207
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.
That's always the python interpreter, right? It won't be the cli tool name even if used via an entry point installed script
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.
this is the default value in the current code. It is overridden in the
Tool.run()
function:ctapipe/src/ctapipe/core/tool.py
Line 409 in 2b70207