Skip to content

Commit

Permalink
4real this time?
Browse files Browse the repository at this point in the history
  • Loading branch information
thorbjoernl committed Jul 22, 2024
1 parent 5903b67 commit 00c79a5
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/aerovaldb/jsondb/jsonfiledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import orjson
from async_lru import alru_cache
from packaging.version import Version
from pkg_resources import get_distribution # type: ignore
from pkg_resources import DistributionNotFound, get_distribution # type: ignore

from aerovaldb.aerovaldb import AerovalDB
from aerovaldb.exceptions import UnusedArguments, TemplateNotFound
Expand Down Expand Up @@ -224,7 +224,16 @@ async def _get_version(self, project: str, experiment: str) -> Version:
try:
config = await self.get_config(project, experiment)
except FileNotFoundError:
return 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 DistributionNotFound:
version = Version("0.0.1")
finally:
return version
except orjson.JSONDecodeError:
# Work around for https://github.com/metno/aerovaldb/issues/28
return Version("0.14.0")
Expand All @@ -233,14 +242,7 @@ async def _get_version(self, project: str, experiment: str) -> Version:
version_str = config["exp_info"]["pyaerocom_version"]
version = Version(version_str)
except KeyError:
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")
version = Version("0.0.1")

return version

Expand Down

0 comments on commit 00c79a5

Please sign in to comment.