OpenDrift / opendrift

Open source framework for ocean trajectory modelling
https://opendrift.github.io
GNU General Public License v2.0
245 stars 120 forks source link

Easy way to know exact code commit used? #1098

Closed jerabaul29 closed 1 year ago

jerabaul29 commented 1 year ago

That may be a bit general, if so apologies.

I had some "user side issues" the last few days where I got confused "all on my own" when working from source installation vs conda installation and having a bit of mess about it (which I think can easily happen when using a mix of conda envs, conda vs git installs, etc).

In short, I was confused about "am I using the 'true' version 1.10.6, or the version 1.10.6 according to setuptools, but actually this is from a commit that is more up to date"? The way to check for this now is to do:

In [1]: import opendrift as od

In [2]: od.__version__
Out[2]: '1.10.6'

In [3]: od.__path__
Out[3]: ['MYHOME/Git/opendrift/opendrift']

And then to go to the corresponding folder, check the git log or similar to check the commit, etc.

My question: is it possible / would it make sense to have an attribute in the kind of:

od.__commit__

that would return the exact commit used, either this is from a release, or from a git source install? That may make it much easier to debug / track versions etc. No idea if this can be supported out of the box, or if this would require a bit of code.

gauteh commented 1 year ago

You can use od.version.version_or_git()

jerabaul29 commented 1 year ago

Aaah, nice, many thanks, I was not aware of this :) .