metno / pyaerocom

Python tools for climate and air quality model evaluation
https://pyaerocom.readthedocs.io/
GNU General Public License v3.0
25 stars 13 forks source link

paerocom cli should have a --version argument #496

Closed jgriesfeller closed 2 years ago

jgriesfeller commented 2 years ago

In the Unix world it's a good practice for every program to provide an easy way of determining it's version number. Usually that is done with a --version command line option.

The purpose for me is to determine easily on which version number I am.

avaldebe commented 2 years ago

Should we add some additional info listing the installed pya dependencies? This is quite easy to implement with importlib.metadata.version Here is an example, from one of my CLI apps

$ utils4cwf -V

utils4cwf (0.4.0)
dependencies (installed version)

data formats
netCDF4 (1.5.5.1), eccodes (1.3.3), cfgrib (0.9.9.1), pyarrow (6.0.0)

data manipulation
dask (2021.11.1), xarray (0.20.1), scipy (1.6.1), numpy (1.19.5)

remote execution
fabric (2.6.0), invoke (1.6.0), paramiko (2.8.0)

configuration
python-dotenv (0.19.2), toml (0.10.2)

command line
typer (0.4.0), click (8.0.3)
jgriesfeller commented 2 years ago

Sounds like a good idea What I was after can be achieved like this

>>> import pyaerocom
>>> from importlib.metadata import version
>>> version('pyaerocom')
'0.12.2.dev1'

This is so small that I can implement it right away in https://github.com/metno/pyaerocom/blob/main-dev/pyaerocom/scripts/cli.py

avaldebe commented 2 years ago

on the current version you can get __version__ as follows

>>> from pyaerocom import __version__
>>> print(__version__)
0.12.2.dev1

which I implemented using importlib.metadata.version

https://github.com/metno/pyaerocom/blob/3e8048895bbd403e504a99e38967f43afc441dbf/pyaerocom/__init__.py#L6

This is so small that I can implement it right away in https://github.com/metno/pyaerocom/blob/main-dev/pyaerocom/scripts/cli.py

Yes, you could just do that. However, I would take the opportunity to re-implement pyaerocom.scripts.cli using typer.

jgriesfeller commented 2 years ago

Then just do it, I am too used to argparse.

avaldebe commented 2 years ago

addressed by #624