Skip to content

GEOPY-1029: Add datetime stamp to simpeg.log and simpeg.out file names#140

Merged
domfournier merged 3 commits intorelease/GA_4.8from
GEOPY-1029C
Apr 23, 2026
Merged

GEOPY-1029: Add datetime stamp to simpeg.log and simpeg.out file names#140
domfournier merged 3 commits intorelease/GA_4.8from
GEOPY-1029C

Conversation

@domfournier
Copy link
Copy Markdown

@domfournier domfournier commented Apr 22, 2026

GEOPY-1029 - Add datetime stamp to simpeg.log and simpeg.out file names

Copilot AI review requested due to automatic review settings April 22, 2026 23:12
@github-actions github-actions Bot changed the title GEOPY-1029 GEOPY-1029: Add datetime stamp to simpeg.log and simpeg.out file names Apr 22, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates SaveLogFilesGeoH5 to support a caller-provided base_name so log/artifact files can be read/written with a configurable prefix instead of hard-coded SimPEG.* filenames.

Changes:

  • Add a base_name constructor argument and use it to build .out/.log paths.
  • Change output header creation to depend on output file existence rather than iteration == 0.
  • Update save_log() to iterate over extensions and build file paths using base_name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 387 to 394
def __init__(
self,
h5_object,
base_name,
**kwargs,
):
self.base_name = base_name
super().__init__(h5_object, **kwargs)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

SaveLogFilesGeoH5 is exported as part of simpeg.directives, but base_name is now a required positional arg. This is a breaking API change for downstream code that instantiates the directive without it. Consider providing a default (e.g., "SimPEG") and/or making it a keyword-only optional parameter to preserve backwards compatibility.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Na, an update to simpeg comes with it

Comment on lines 431 to +435

for file in [
"SimPEG.out",
"SimPEG.log",
"ChiFactors.log",
".out",
".log",
".chi",
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

save_log() now looks for a chi-factors file at f"{base_name}.chi", but ScaleMisfitMultipliers writes ChiFactors.log by default (see simpeg/directives/_directives.py:2704). As written, chi-factor logs likely won’t be found/saved. Consider keeping ChiFactors.log, or making the chi-factor filename configurable and aligning both producers/consumers.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Also updated

Comment on lines 436 to 446
]:
filepath = dirpath / file
filepath = dirpath / f"{self.base_name}{file}"

if not filepath.is_file():
continue

with open(filepath, "rb") as f:
raw_file = f.read()

file_entity = h5_object.get_entity(file)[0]
file_entity = h5_object.get_entity(f"{self.base_name}{file}")[0]
if file_entity is None:
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

file_entity = h5_object.get_entity(file)[0] is now using strings like ".out"/".log" as the lookup key, but add_file(filepath) will typically create an entity named after the actual file (e.g., f"{base_name}.out"). This mismatch can prevent updates to existing entities and may repeatedly add new file entities. Use filepath.name (or another consistent identifier) for both get_entity(...) and add_file(...) so the same entity is updated each time.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

On purpose

MatthieuCMira
MatthieuCMira previously approved these changes Apr 23, 2026
Copy link
Copy Markdown

@MatthieuCMira MatthieuCMira left a comment

Choose a reason for hiding this comment

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

seems ok for me.

Answer the copilote comments

self._joint_index = value


class SaveLogFilesGeoH5(BaseSaveGeoH5):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe we could use this PR to add some docstring in there!

Copy link
Copy Markdown

@MatthieuCMira MatthieuCMira left a comment

Choose a reason for hiding this comment

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

good to go

@domfournier domfournier merged commit ea70aa2 into release/GA_4.8 Apr 23, 2026
11 checks passed
@domfournier domfournier deleted the GEOPY-1029C branch April 23, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants