-
-
Notifications
You must be signed in to change notification settings - Fork 660
sage-logger
: Suppress "No such file or directory" messages
#37785
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
Conversation
…me is not available
Documentation preview for this PR (built with commit ededb59; changes) is ready! 🎉 |
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.
It looks good to me!
Thanks! |
@@ -63,15 +63,15 @@ fi | |||
|
|||
timefile="$logdir/$logname.time" | |||
rm -f "$timefile" | |||
if /usr/bin/time -h -o /dev/null true; then | |||
if /usr/bin/time -h -o /dev/null true 2>/dev/null; then |
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 sure ubuntu has /usr/bin/time
available. The problem is that you are using nonstandard arguments to time(1)
:
$ /usr/bin/time -h -o /dev/null
/usr/bin/time: invalid option -- 'h'
Try '/usr/bin/time --help' for more information.
$ echo $?
125
Also, if you want to parse the time you should pass -p
to ensure the standard format is used (https://www.man7.org/linux/man-pages/man1/time.1p.html), and then you can just use the bash builtin.
For what you are trying to acomplish, you could also use bash variables $EPOCHSECONDS
(or $EPOCHREALTIME
for more precision).
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 reviewer specifically asked for the human-readable format to be used.
The whole thing is just a convenience.
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 reviewer specifically asked for the human-readable format to be used. The whole thing is just a convenience.
I don't know what is "the human-readable format" but -h
is not supported by gnu time(1)
nor by the bash builtin.
Gnu time does support -o
but not -h
.
If you want to bypass the bash builtin, the better approach is to use \time
which will still search in PATH
.
For what you are trying to acomplish, you could also use bash variables $EPOCHSECONDS (or $EPOCHREALTIME for more precision).
There's also $SECONDS
.
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 reviewer specifically asked for the human-readable format to be used. The whole thing is just a convenience.
I see, but then the bash builtin time is just what the reviewer asked for.
You could
- do the redirect
2>&1
inside thesh -c "..."
- capture with
2>
the output of time
(since the bash builtin doesn't support -o)
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.
If you want to prepare a follow-up PR, I can test it for its portability. I don't have time to work on it myself at the moment.
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.
If you want to prepare a follow-up PR, I can test it for its portability. I don't have time to work on it myself at the moment.
Please don't tell me what I should do with my time.
My comment before was just remarking that the current PR does not fix the issue but only hides it. Reverting cb4e718 for the time being seems to be easier workaround, until you or someone else gets the time to improve the output in a portable way.
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.
Please don't tell me what I should do with my time.
@tornaria And I am not, so don't tell me what I shouldn't tell you.
Please revert cb4e718 so this works on all supported platforms. |
No, that's outside of the scope of this PR. |
Per PR description, this PR resolves the messages displayed |
It's in scope for #37391 which was incorrect in this regard. The follow-up should be fixing, not hiding it. The error you showed is
this has nothing to do with the absence of Reverting cb4e718 seems easy enough; this ends up with your original PR which is the one I assume you tested most. Trying to satisfy a very reasonable request by @kwankyu is great, but not at the expense of breaking in a lot of supported systems. |
Please, Gonzalo, the PR author sets scope of the PR. |
If you look at the actual ticket description, line 1:
So yes, this PR is about absence of |
But #37391 is also broken on boxes where
This includes most linux boxes. I grant you that changing this to use the builtin I'll show myself the exit. I was only trying to help since I know (and appreciate) you are always concerned about portability. PS: note that
so the obvious using
In fact, you could do something like the following:
PS2: when you want to skip a bash builtin, the common idiom is |
That's appreciated, and I will benefit from the details and suggestions that you made when I work on the follow-up PR. Thank you. |
I think my last suggestion might be useful. It seems to me that the format for the bash builtin Since all of our scripts already depend on bash (as the shebang shows) depending on bashisms of the |
… messages <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> A minor follow-up after sagemath#37391: Seen for example in https://github.com/sagemath/sage/actions/runs/8626379356/job/23644513913 ?pr=37570#step:11:3227: ``` sagemath#24 4091.8 /sage/build/bin/sage-logger: line 66: /usr/bin/time: No such file or directory sagemath#24 4091.8 [sagemath_doc_html-none] installing. Log file: /sage/logs/pkgs/sagemath_doc_html-none.log sagemath#24 5807.5 cat: /sage/logs/pkgs/sagemath_doc_html-none.time: No such file or directory ``` We suppress these (harmless) messages which show up when `/usr/bin/time` is not available. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#37785 Reported by: Matthias Köppe Reviewer(s): David Ayotte, Gonzalo Tornaría, Matthias Köppe
sagemathgh-37840: `sage-logger`: Replace use of `/usr/bin/time` by bash keyword `time` <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Follow-up after - sagemath#37391 - sagemath#37785 ... to make the display of package build times available on Linux too. Fixes sagemath#37785 (comment), closes sagemath#37832. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> - Depends on sagemath#37785 URL: sagemath#37840 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee
sagemathgh-37840: `sage-logger`: Replace use of `/usr/bin/time` by bash keyword `time` <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Follow-up after - sagemath#37391 - sagemath#37785 ... to make the display of package build times available on Linux too. Fixes sagemath#37785 (comment), closes sagemath#37832. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> - Depends on sagemath#37785 URL: sagemath#37840 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee
sagemathgh-37840: `sage-logger`: Replace use of `/usr/bin/time` by bash keyword `time` <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Follow-up after - sagemath#37391 - sagemath#37785 ... to make the display of package build times available on Linux too. Fixes sagemath#37785 (comment), closes sagemath#37832. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> - Depends on sagemath#37785 URL: sagemath#37840 Reported by: Matthias Köppe Reviewer(s): Gonzalo Tornaría, Kwankyu Lee, Matthias Köppe
A minor follow-up after #37391:
Seen for example in
https://github.com/sagemath/sage/actions/runs/8626379356/job/23644513913?pr=37570#step:11:3227:
We suppress these (harmless) messages which show up when
/usr/bin/time
is not available.📝 Checklist
⌛ Dependencies