Skip to content

Commit

Permalink
add {{PBP_version}} snippet for global attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
carueda committed Mar 20, 2024
1 parent 87b936d commit 8e00536
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

2024-03

- For global attributes, now resolving the `{{PyPAM_version}}` snippet against the
actual version number (according to `importlib.metadata`).
Also added a `{{PBP_version}}` snippet in case we eventually want to use it.
- removed `--gen-csv` option (not really used/needed)
- added `--version` option to the programs
- minor code reorg
Expand Down
9 changes: 9 additions & 0 deletions pbp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ def get_pbp_version() -> str:
return poetry.package.version.text
except Exception: # pylint: disable=broad-exception-caught
return "version not found"


def get_pypam_version() -> str:
try:
import importlib.metadata

return importlib.metadata.version("lifewatch-pypam")
except Exception: # pylint: disable=broad-exception-caught
return "??"
7 changes: 5 additions & 2 deletions pbp/process_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import xarray as xr

from pbp import get_pbp_version, get_pypam_version
from pbp.file_helper import FileHelper
from pbp.logging_helper import PbpLogger
from pbp.metadata import MetadataHelper, parse_attributes, replace_snippets
Expand Down Expand Up @@ -292,8 +293,10 @@ def _get_global_attributes(self, year: int, month: int, day: int):
}
md_helper = self.metadata_helper
md_helper.set_some_global_attributes(global_attrs)
# TODO get PyPAM version from somewhere
snippets = {"{{PyPAM_version}}": "0.3.0"}
snippets = {
"{{PBP_version}}": get_pbp_version(),
"{{PyPAM_version}}": get_pypam_version(),
}
global_attrs = md_helper.get_global_attributes()
# for each, key, have the {{key}} snippet for replacement
# in case it is used in any values:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "mbari-pbp"
version = "0.3.0b5"
version = "0.3.0b6"
# for now, pbp version "aligned" (not necessarily exactly) with that of lifewatch-pypam.
description = "PyPAM based Processing"
authors = [
Expand Down

0 comments on commit 8e00536

Please sign in to comment.