From bef810fc6b480ed901164c6aa382c85e181a23db Mon Sep 17 00:00:00 2001 From: Mike McCann Date: Tue, 2 Dec 2025 13:49:19 -0800 Subject: [PATCH 1/2] Check for HOST_NAME env var and use actual_hostname if set. --- src/data/align.py | 4 ++-- src/data/calibrate.py | 4 +++- src/data/combine.py | 6 +++++- src/data/process.py | 4 +++- src/data/resample.py | 5 ++++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/data/align.py b/src/data/align.py index d7747e41..d3fca8ac 100755 --- a/src/data/align.py +++ b/src/data/align.py @@ -203,7 +203,7 @@ def global_metadata(self) -> dict: # noqa: PLR0915 metadata["comment"] = ( f"MBARI Dorado-class AUV data produced from calibrated data" f" with execution of '{self.commandline}' at {iso_now} on" - f" host {gethostname()}. Software available at" + f" host {actual_hostname}. Software available at" f" 'https://github.com/mbari-org/auv-python'" ) elif log_file: @@ -214,7 +214,7 @@ def global_metadata(self) -> dict: # noqa: PLR0915 metadata["comment"] = ( f"MBARI LRAUV-class AUV data produced from logged data" f" with execution of '{self.commandline}' at {iso_now} on" - f" host {gethostname()}. Software available at" + f" host {actual_hostname}. Software available at" f" 'https://github.com/mbari-org/auv-python'" ) if matches: diff --git a/src/data/calibrate.py b/src/data/calibrate.py index 85b6a16d..95fe1e68 100755 --- a/src/data/calibrate.py +++ b/src/data/calibrate.py @@ -655,6 +655,8 @@ def global_metadata(self): if "pytest" in sys.modules: self.logger.debug("Skipping dynamic metadata generation (running under pytest)") return {} + # Try to get actual host name, fall back to container name + actual_hostname = os.getenv("HOST_NAME", gethostname()) iso_now = datetime.now(tz=UTC).isoformat() + "Z" @@ -705,7 +707,7 @@ def global_metadata(self): metadata["comment"] = ( f"MBARI Dorado-class AUV data produced from original data" f" with execution of '{self.commandline}'' at {iso_now} on" - f" host {gethostname()}. Software available at" + f" host {actual_hostname}. Software available at" f" 'https://github.com/mbari-org/auv-python'" ) diff --git a/src/data/combine.py b/src/data/combine.py index 1aba0a49..6a6b259f 100755 --- a/src/data/combine.py +++ b/src/data/combine.py @@ -40,6 +40,7 @@ import json # noqa: I001 import logging +import os import sys import time from datetime import UTC @@ -122,6 +123,9 @@ def global_metadata(self): """ from datetime import datetime + # Try to get actual host name, fall back to container name + actual_hostname = os.getenv("HOST_NAME", gethostname()) + iso_now = datetime.now(tz=UTC).isoformat() + "Z" metadata = {} @@ -175,7 +179,7 @@ def global_metadata(self): metadata["comment"] = ( f"MBARI Long Range AUV data produced from original data" f" with execution of '{self.commandline}'' at {iso_now} on" - f" host {gethostname()}. Software available at" + f" host {actual_hostname}. Software available at" f" 'https://github.com/mbari-org/auv-python'" ) diff --git a/src/data/process.py b/src/data/process.py index 87cc7374..a4e8438b 100755 --- a/src/data/process.py +++ b/src/data/process.py @@ -780,12 +780,14 @@ def process_mission(self, mission: str, src_dir: str = "") -> None: # noqa: C90 f"{FAILED} program specified in dorado_info.py. Not processing {mission}" ) raise FailedMission(error_message) + # Try to get actual host name, fall back to container name + actual_hostname = os.getenv("HOST_NAME", gethostname()) self.logger.info( "Processing %s mission %s by user %s on host %s", program, mission, getuser(), - gethostname(), + actual_hostname, ) except KeyError: error_message = f"{mission} not in dorado_info" diff --git a/src/data/resample.py b/src/data/resample.py index aaf2aa4c..ff795eb8 100755 --- a/src/data/resample.py +++ b/src/data/resample.py @@ -10,6 +10,7 @@ __copyright__ = "Copyright 2021, Monterey Bay Aquarium Research Institute" import logging # noqa: I001 +import os import re import sys import time @@ -105,6 +106,8 @@ def _build_global_metadata(self) -> None: # Skip dynamic metadata during testing to ensure reproducible results if "pytest" in sys.modules: return {} + # Try to get actual host name, fall back to container name + actual_hostname = os.getenv("HOST_NAME", gethostname()) repo = git.Repo(search_parent_directories=True) try: gitcommit = repo.head.object.hexsha @@ -166,7 +169,7 @@ def _build_global_metadata(self) -> None: self.metadata["source"] = ( f"MBARI Dorado-class AUV data produced from {from_data}" f" with execution of '{self.commandline}' at {iso_now} on" - f" host {gethostname()} using git commit {gitcommit} from" + f" host {actual_hostname} using git commit {gitcommit} from" f" software at 'https://github.com/mbari-org/auv-python'" ) self.metadata["summary"] = ( From 1c4181c4d122decabfa27c5f8affe696a422cd36 Mon Sep 17 00:00:00 2001 From: Mike McCann Date: Tue, 2 Dec 2025 13:53:14 -0800 Subject: [PATCH 2/2] Remove mention of original sampling intervals from summary metadata attribute. --- src/data/resample.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/data/resample.py b/src/data/resample.py index ff795eb8..5f0a155d 100755 --- a/src/data/resample.py +++ b/src/data/resample.py @@ -336,6 +336,10 @@ def lrauv_global_metadata(self) -> dict: f". Processing log file: {BASE_LRAUV_WEB}/" f"{self.log_file.replace('.nc4', '_processing.log')}" ) + # Remove mention of original sampling intervals from summary + self.metadata["summary"] = self.metadata["summary"].replace( + " with measurements at original sampling intervals", "" + ) # Preserve comment from align.nc if available, otherwise use default if "comment" in self.ds.attrs: