Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchcab version to model output attributes #167

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions benchcab/fluxsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import netCDF4
import f90nml

from benchcab import __version__
from benchcab import internal
from benchcab.repository import CableRepository
from benchcab.comparison import ComparisonTask
Expand Down Expand Up @@ -341,6 +342,7 @@ def add_provenance_info(self, verbose=False):
**{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we are not using the dict() syntax here?

For example

**dict(
    cable_branch='...',
    svn_revision_number='...',
    benchcab_version=__version__
)

"cable_branch": self.repo.svn_info_show_item("url"),
"svn_revision_number": self.repo.svn_info_show_item("revision"),
"benchcab_version": __version__,
},
}
)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fluxsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CableError,
)
from benchcab import internal
from benchcab import __version__
from benchcab.repository import CableRepository
from benchcab.utils.subprocess import SubprocessWrapperInterface
from .common import MOCK_CWD, get_mock_config, MockSubprocessWrapper
Expand Down Expand Up @@ -377,6 +378,7 @@ def test_add_provenance_info():
atts = vars(nc_output)
assert atts["cable_branch"] == mock_subprocess.stdout
assert atts["svn_revision_number"] == mock_subprocess.stdout
assert atts["benchcab_version"] == __version__
assert atts[r"filename%met"] == "/path/to/met/file"
assert atts[r"filename%foo"] == 123
assert atts[r"bar"] == ".true."
Expand Down