Conversation
tgamblin
left a comment
There was a problem hiding this comment.
@alalazo: see my comments -- I'm not sure we need this command as it seems non-orthogonal to some existing ones that could do the same thing. See what you think.
I think it would be useful if it dumped the log, as that would allow someone to grep for errors. But beyond that maybe it should be an add-on to either spack edit or spack env (soon to be spack build-env).
lib/spack/spack/cmd/logs.py
Outdated
| spack.cmd.display_specs(specs, args) | ||
| raise SystemExit(1) | ||
|
|
||
| spec = specs[0] |
There was a problem hiding this comment.
just use spack.cmd.disambiguate_spec() and you can delete everything from here up.
lib/spack/spack/cmd/logs.py
Outdated
|
|
||
| spec = specs[0] | ||
| if spec.external: | ||
| msg = '{0} is an external. External specs have no logs.' |
There was a problem hiding this comment.
'{0} is an external package and has no logs.'
lib/spack/spack/cmd/logs.py
Outdated
| tty.die(msg.format_map(spec.short_spec)) | ||
|
|
||
| # Construct the filename to be opened | ||
| filename = 'build.env' if args.environment else 'build.out' |
There was a problem hiding this comment.
why not make several arguments that use store_const with these string values and a single filename as dest? Then the parser will build the name for you.
lib/spack/spack/cmd/logs.py
Outdated
|
|
||
| def setup_parser(subparser): | ||
| subparser.add_argument( | ||
| '--environment', |
There was a problem hiding this comment.
I would call this --build-env or --build-environment. I'm somewhat conflicted about whether this should be an argument to this command or to spack env, e.g. spack env --installed <spec>. The latter would also let you actually run a command in the old environment, which could be very useful.
There was a problem hiding this comment.
Let me know if you want this command at all, or if you want just want
spack env --install <spec>
For the what is worth, the motivation that lead me putting this PR together was just being tired to repeat:
$ spack find -p <spec>
==> 1 installed packages.
-- linux-ubuntu14.04-x86_64 / [email protected] ---------------------------
[email protected] /home/mculpo/PycharmProjects/spack/opt/spack/linux-ubuntu14.04-x86_64/gcc-4.8/zlib-1.2.11-eksallf6cymqkp6pkz6ymzjakqt6bqkx
$ less <cut'n paste of the path above>/.spack/build.out
over and over when looking at previous installations logs. Having a dump of the environment was just a low hanging fruit once opening the logs had been implemented.
There was a problem hiding this comment.
How about just these:
spack env --install <spec>spack edit --log <spec>
or just the latter if you're short on time? I think the use case you describe is a good one, we just already have spack edit
There was a problem hiding this comment.
PS -- spack edit probably only need another arg and a call to disambiguate spec in edit_package to make this work
lib/spack/spack/cmd/logs.py
Outdated
| msg = 'log file does not exist! [{0}]' | ||
| tty.die(msg.format(abs_filename)) | ||
|
|
||
| spack.editor(abs_filename) |
There was a problem hiding this comment.
I think if this is just going to edit the file, it should be implemented as an argument to spack edit. e.g., spack edit --build-log <spec>.
Similarly, if it is going to print the filename, there should probably be an argument to spack location.
What we don't have currently is something to just dump the log, so maybe this command should just do that? Seems like it should also be called spack show-log if it does that. But see my comments about about overlap with spack env for the environment log.
There was a problem hiding this comment.
spack.editor was the fastest way I could think of to open the logs into something paged.
I would really like to be able to somehow open the file read only, but couldn't find a decent way to do it that works for every editor I am aware of. An alternative, to avoid accidental corruptions of the logs, is to copy the logs in some tmp space and open the copy + delete it on editor exit.
Note that if you want just a dump, for instance within a script, you can:
export EDITOR=cat
spack logs <spec>
Does this seem reasonable to you?
There was a problem hiding this comment.
I guess it seems kind of awkward? What about just:
spack show-log <spec>
db83941 to
16405ea
Compare
|
@tgamblin Just dumping the log right now. Will do a PR for: later on. Also, not sure if in the end you wanted: or directly a sub-command: Just post your preferred, I'll change the naming here. |
|
ping |
I think I addressed the comment. Let me know if there's something else to do here. |
|
@alalazo I kind of like Speaking of which, see #7093. Should that be added here? The only thing is that |
|
@tgamblin I agree with merging these two as: spack log parse [-f file | spec]
spack log show [-f file | spec]Ok if I proceed with that in this PR? |
|
sure! go ahead |
02c510f to
64e400a
Compare
|
@tgamblin Ready for another review! EDIT: In the end the sub-commands work like: |
Added a new command `spack logs`, that mimics `docker logs`. It takes a contraint that identifies a unique spec, and dumps its build.out.
The functionality previously in `spack logs` and `spack log-parse` has been moved to sub-commands of `spack log`. `spack log parse` now accepts an installed spec as an argument and converts it into the corresponding `build.out` file to be parsed.
c3537f9 to
a78be63
Compare
|
ping |
Added a new command
spack log show, that mimicsdocker logs:It takes a constraint that identifies a unique spec, and dumps its
build.out. The log can be piped to other linux commands (such asgrepor less). Errors are handled gracefully:The command
spack log-parsehas been moved tospack log parseand now accepts either a file or a spec: