Repository: dask/dask

Issue:
getting git commit hash of dask from dask
That would help in debugging issues related to version mismatch. Also helpful when managing multiple versions of dask.



Discussion:
I agree that this would help.  Other projects use systems like versioneer.  I'd welcome a pull request that implemented this cleanly.

@jcrist might also have thoughts.  I'd defer to his opinion.

I used to populate that info during CI from env var storing git hash, just before wrapping package to release.

@jcrist could you add an example how to get git hash from python?

If you're on a release, the version will be a release number, otherwise it'll be the most recent release with the short git hash appended:

``` python
In [1]: import dask

In [2]: dask.__version__
Out[2]: '0.11.1+67.g4c1d8b4'
```

@jcrist I don't think this is resolving that issue. Any plans for providing git hash? should we re-open, or _won't fix_?

I'm not sure I follow? If your use case is fully specifying a version of dask, then `dask.__version__` does exactly this. Each release/commit has a different `__version__`. We're just using versioneer here, which is what [many](https://github.com/pandas-dev/pandas) [other](https://github.com/numba/numba) [projects](https://github.com/matplotlib/matplotlib) [use](https://github.com/bokeh/bokeh). Can you explain how this doesn't fully meet your usecase?

@jcrist From the very beginning of that issue I'm asking about _git hash_, full git hash would be better, short is still fine. Current `dask.__version__` will work only if you are on devel branch, not a release branch. It will also produce a string from which I can extract short git hash. It is quite far from what I was asking for.
My use case is to store application measures together with its uniquely defined version, measures for various applications are stored in a database and further processed. If some of the app is not able to provide git hash, it will just get NULL in db column, and it can't be re-build and re-run in automated manner.

@jangorecki Every released version has a corresponding git `tag`: https://github.com/dask/dask/tags

You can use tags instead of hashes in most cases within `git` to checkpoint particular versions.

@shoyer I am aware of it, but how it is related to title of this issue?

My point was that `dask.__version__` is sufficient to extract an "uniquely defined version" from a git repo, which I understood was your use case.

@shoyer It can be, if you conditionally - for release branches - will lookup git hash based on version number. Otherwise for devel branches you do substring and lookup full git hash from short hash. Seems doable, but I asked this question to avoid such workarounds and lookups, and just get current git hash in python. If you prefer _won't fix_ that's fine, I'm OK with that, just asking to know if it make sense to still keep a placeholder for storing that info or I can remove it from my project.


Resolving patch:
diff --git a/dask/__init__.py b/dask/__init__.py
--- a/dask/__init__.py
+++ b/dask/__init__.py
@@ -13,5 +13,7 @@
     pass
 
 from ._version import get_versions
-__version__ = get_versions()['version']
-del get_versions
+versions = get_versions()
+__version__ = versions['version']
+__git_revision__ = versions['full-revisionid']
+del get_versions, versions


Test patch: