k2-fsa / snowfall

Moved to https://github.com/k2-fsa/icefall
Apache License 2.0
143 stars 42 forks source link

Version information #135

Open danpovey opened 3 years ago

danpovey commented 3 years ago

It would be nice if we could print version information to make it easier to reproduce experiments and load trained models. I am thinking of printing things like git branch and git hash if available, of snowfall; and version information of lhotse and k2. I don't know if there is a standard way to get these?

csukuangfj commented 3 years ago

k2 has Python APIs to get its git hash indicating based on which commit it was built, though those APIs have not been exported to k2; they are only available through _k2 at present.

pzelasko commented 3 years ago

I don't think I have anything to indicate the git hash in Lhotse, not sure if there's a way to do it in general for pip-installed packages (think installed either through PyPI or pip install git+https://...)? Lhotse has no native code so there is no "build" unlike in K2. I'll keep thinking about it but I'm open to suggestions. Just using import lhotse; lhotse.__version__ is probably too broad as a lot changes between the releases...

csukuangfj commented 3 years ago

I think it is doable for Lhotse. Will try to find a way. The basic idea is to create some file containing the git hash during installation and remove the file from the source tree during post installation.

csukuangfj commented 3 years ago

Please see https://github.com/k2-fsa/k2/pull/688 as an example.

csukuangfj commented 3 years ago

From https://github.com/k2-fsa/k2/pull/688#discussion_r599631354

I'll wait for someone else to add related features to snowfall though, e.g. to print such info at the start of logs.

The relevant APIs from k2 can be found at https://github.com/k2-fsa/k2/pull/688#issue-597113143

>>> import k2
>>> k2.__version__
'0.3.3'
>>> k2.__dev_version__
'0.3.3.dev20210320'
>>> k2.__build_type__
'Release'
>>> k2.__git_sha1__
'5ee74c7e22340f26788894a224b0cadcc2f9c898'
>>> k2.__git_date__
'Thu Mar 18 22:22:17 2021'
entn-at commented 3 years ago

I don't think I have anything to indicate the git hash in Lhotse, not sure if there's a way to do it in general for pip-installed packages (think installed either through PyPI or pip install git+https://...)? Lhotse has no native code so there is no "build" unlike in K2. I'll keep thinking about it but I'm open to suggestions. Just using import lhotse; lhotse.__version__ is probably too broad as a lot changes between the releases...

Perhaps something like https://github.com/python-versioneer/python-versioneer could help here. Judging by the README, it seems to be able to support both PyPI installed and pip install git+https://... installed packages and also with --editable.

oplatek commented 3 years ago

FYI: git commit in setup.py in Lhotse https://github.com/lhotse-speech/lhotse/pull/291