-
Notifications
You must be signed in to change notification settings - Fork 33
bashlib: implement new CLI options #929
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Since
--profileis python-specific, I am unsure whether we want to mirror it in bashlib unless we have a good idea on how to actually implement it. If we decide that this should be consistent across all processors - so a clearly defined feature, not just a debugging aid - then we should probably amend the CLI spec for it. If we decide against that, it might be better to use a non-flag option like an environment variable and document it outside of the--helptext.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 don't think we should elevate this to spec. But having it in core anyway, it's only natural to at least pass the information on in the arg parser for bashlib. Of course there is not so much more we can do from bashlib (except perhaps
set -x, or evenexec 3>${ocrd__argv[profile_file]}; export BASH_XTRACEFD=3; or maybe some timestamping in theDEBUGtrap), because the implementation may not use much of bash and only delegate to other programs. The flag would still be useful then, for example by activating some native profiling mechanism in that program.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.
exec 3>${ocrd__argv[profile_file]}; export BASH_XTRACEFD=3That's an amazing snippet I will save for later :)
I agree, so for consistency's sake, shall we change the mechanism in the python implementation to use environment variables (
OCRD_PROFILE,OCRD_PROFILE_FILE) and drop it from the--helpoutput?Uh oh!
There was an error while loading. Please reload this page.
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.
Once we have agreed upon a general mechanism (also for error handling, caching, timeouts and for "universal parameters" like DPI or runtime input/output validation) – yes, then that should be used here, too.
At the moment this just restores consistency for the current state of affairs (i.e. the existing
--profileoption).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 get that, but consistency with the current state of affairs is also the target of this PR, so I thought we could handle
--profilevs.OCRD_PROFILEhere before we start to adding new flags for caching, processing server etc.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.
Oh, now I got it. But that's a breaking change! And I doubt we will arrive at a definitive conclusion for the general configuration/customization issue quickly. So why not just get this done first?
Ah, I see! Then let's just implement them quick and dirty (see above) as a first step.
Also, with a thing like bashlib, you cannot say that they are not implemented: bashlib processors can now start implementing them. (But not without the parser!)
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.
In c7aa0a8 I implemented a variant that's superior to
set -x: it also includes the timing of all commands.Example with ocrd-olena-binarize…
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.
So this is still just tracing (but again, the processor code can act on
ocrd__argv[profiling]and do something else.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.
Yeah, I thought I could slip a backwards-incompatible change into your PR, that's not the right approach. Let's align bashlib and core first and postpone the discussion about configuring these "extra" behaviors.
OK, I agree that c7aa0a8 is a sensible approximation of the functionality. Always impressed with your knowledge of bash internals 👍
Funnily enough, @MehmedGIT and I debugged a problem with his ocrd_olena installation with
bash -x $(which ocrd-olena-binarize)earlier today, so there's at least two potential users of the functionality :)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, it will also give us hints which parts of the bashlib processors need to be streamlined or parallelised. And we can just ask the user to provide these logs from their environment now.