Skip to content

Commit

Permalink
fix: version issue in Pyaerocom tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thorbjoernl committed Jul 22, 2024
1 parent 4591513 commit 5f73a35
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/aerovaldb/jsondb/jsonfiledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import orjson
from async_lru import alru_cache
from packaging.version import Version
from pkg_resources import get_distribution # type: ignore

from aerovaldb.aerovaldb import AerovalDB
from aerovaldb.exceptions import UnusedArguments, TemplateNotFound
Expand Down Expand Up @@ -232,7 +233,14 @@ async def _get_version(self, project: str, experiment: str) -> Version:
version_str = config["exp_info"]["pyaerocom_version"]
version = Version(version_str)
except KeyError:
version = Version("0.0.1")
try:
# If pyaerocom is installed in the current environment, but no config has
# been written, we use the version of the installed pyaerocom. This is
# important for tests to work correctly, and for files to be written
# correctly if the config file happens to be written after data files.
version = Version(get_distribution("pyaerocom").version)
except KeyError:
version = Version("0.0.1")

return version

Expand Down

0 comments on commit 5f73a35

Please sign in to comment.