-
Notifications
You must be signed in to change notification settings - Fork 148
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
Print version number #236
base: main
Are you sure you want to change the base?
Print version number #236
Conversation
4f57284
to
6a7c668
Compare
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 including the git revision in the log is a good idea but I have some practical concerns about the implementation.
- We already have a command
./fast-downward.py --version
which prints the release (e.g.,23.06
) on a release version and something like23.06+
for other versions. We want to keep the release number and not introduce two different ways of referring to one build. One way to report this would be23.06
for a release and23.06+ (rev f39b35b2)
for others. The trouble is that--version
is an option of the driver, not the search component. - Baking the git revision into the binary with CMake only works if we build from a repository but there are cases where we build from a tarball, or a git export of the code. In that case, there is no surrounding git repo, and accessing the revision number would fail.
.gitignore
Outdated
@@ -5,3 +5,5 @@ __pycache__/ | |||
/builds/ | |||
/misc/.tox/ | |||
/misc/autodoc/downward-xmlrpc.secret | |||
*~ | |||
#* |
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.
#* |
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.
#*
is also a pattern for emacs backup file.
For example, if I am editing a.c
, it creates #a.c
while I am still editing the file, and a.c~
when the file is saved.
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 both of these patterns should rather be in a user's global git configuration, not each project-specific repository. That way, users can configure these once for all projects, and the projects don't need to deal with all possible editor setups.
For what it's worth, as a fellow emacs user: I've configured emacs to put the *~ backups in a global place rather than alongside the original files because I think it's much less messy. And for the #* files, I think it's a feature not to have git ignore them because their presence indicates that there are unsaved edited files currently open, and having this shown clearly when doing a git status or similar prior to a commit is good. It's rarely a good idea to commit when there are unsaved changes.
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 agree that it would be better to leave this up to the user configuration then. But isn't #
a comment in gitignore? Does this work as a pattern without escaping #
?
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.
put the *~ backups in a global place
This indeed works. I am fine with dropping this commit, it is just my habit from experience that plenty of students don't know these and commit absolute everything, and I got annoyed often enough removing .DS_store etc commited in a shared repo...
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 removed the gitignore commit.
Thanks, this is a legit concern! Though the release version and my PR have certainly different purposes (the latter is to confirm that the binary version actually matches the version of the source code it was built from). |
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, I agree that the two numbers have slightly different purposes. But what I would like to avoid is that there are two different answers to the question "Which version did you use?". So I suggest to report both numbers together. If we are on a release, the revision number is not necessary (the release itself is a tag that works like a revision number). For other revisions, it would still be good to see which release this code is based on. Reporting 23.06+ (rev f39b35b2)
would be better than just f39b35b2
.
We could do this in CMake: ask the driver for a version, then try to get the revision from git and use something like unknown revision
in case we build from a tarball (doesn't have to be a critical failure, since we can still build the code). The problem I have with this approach is that if we now ask the driver about the version, it will report 23.06+
, not 23.06+ (rev f39b35b2)
. The problem here is what revision should the driver specify here: The revision of its own code (current git revision), or the revision of the binary it is about to run (the search component, which might be compiled with a different version of the code). Also, we might want to cover the case that the repository has uncommitted changes. In that case, the revision number is also not accurately representing the version of the code.
We could also shift this functionality into the driver and make it responsible for getting the git version and building the string 23.06+ (rev f39b35b2)
. Since the new patch calls the driver from CMake anyway, we might as well implement this in Python, rather than in CMake. One suggestion would be to have the following functionality in the driver
get_release()
->23.06
or23.06+
get_code_revision()
->f39b35b2
(current repo revision), orf39b35b2+
(if there are uncommitted changes), orunknown revision
(if run from a tarball)get_code_version()
-> Something likef"{get_release()} ({get_code_revision()})"
called by CMake and built into the binaryget_binary_version(binary)
-> retrieves the value from the binary and reports it (called by./fast-downward.py --version
so it reports what version is actually run). That would mean the binary itself needs an option--version
to report its internally stored value.
Am I overthinking this? I definitely see the problem of the driver and binary going out of sync (if you build, then switch git branches, then forget to rebuild), and that the source code and repository going out of sync (if you build with uncommitted changes). Maybe instead of passing this information back and forth, we could just store in independently in both the driver and the binary and have each one report its version. But then I would still store both 23.06+
and f39b35b2+
as separate fields and combine them in the output. The driver could actually report both. Something like: 23.06+ (driver code: f39b35b2+, binary: 35b26510)
.
.gitignore
Outdated
@@ -5,3 +5,5 @@ __pycache__/ | |||
/builds/ | |||
/misc/.tox/ | |||
/misc/autodoc/downward-xmlrpc.secret | |||
*~ | |||
#* |
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 agree that it would be better to leave this up to the user configuration then. But isn't #
a comment in gitignore? Does this work as a pattern without escaping #
?
perhaps I was wrong all along... |
Perhaps one way to address this is to make it less obvious to the user so that it does not mess up the bug report and increase the effort by the maintainers.
|
To be clear, I just think it is a good idea to be able to check the output log retroactively for forensic purpose and be absolutely certain about the version of the C++ source code of the binary that produced the log.
Just emitting the build sha1 hash provides a large QoL improvement. Having --version option is also a good idea, and is easily doable, but the fact that it must be explicitly invoked will defeat the purpose (because one will forget). I also often run downward without driver to cache SAS+ files. |
Besides, another idea is that if there are uncommitted changes, the build hash may contain "-dirty" suffix to indicate something weird is happening. |
5d2b9d9
to
ec75d49
Compare
I agree with all of those points as potential problems where you want a version number in the output. The idea with having this as a CLI option was to change the experimental setup so it always prints the version to the log but I don't have a strong opinion on this point. I also think a suffix for dirty repos makes sense but I would call it What I dislike about the current patch is that it accesses the python version as a fallback in cases were we build from a tarball. I think the reason for this is that if we don't have exact information about the revision, we at least want to know which release it is based on. But I think this information is either always interesting (also if we have the revision) or never (even if we don't have the revision). So I'd either run it unconditional and make it part of the print statement, or remove it altogether and print "unknown revision" or something like it in such cases. |
We usually treat discussions in Github pull requests as ephemeral, so I created an issue in our tracker summarizing the discussion so far: https://issues.fast-downward.org/issue1163 |
f8957bc
to
84b723a
Compare
I added the feature that was requested.
|
For tarballs, it still reads from the python file. But this is not my commits' fault! At least I fixed it so that my change (which I am responsible) does not break the build, and I have no responsibility to the prior design (that version.py was updated manually after each release). Someone can improve it, but I see no point of holding it back. If I do it, I would move my CMAKE code to the src/CMakefile, and autogenerate |
No, the previous design is certainly not your commits' fault, I take responsibility for that. But I think I didn't express my concern in the right way, My issue was not that the python files are accessed. it was that this is done only as a fallback. Given what Malte said in the issue, I would suggest this workflow:
The last step is still unclear to me and we should discuss this in the issue tracker. |
This PR adds a version number (the Git hash at the build time) to the output log
This prevent several accidents like forgetting to recompile it before the experiments & not noticing it, ending up getting a wrong result
The first line of the log output look like this