Skip to content

Reduce duplicated logging code, standardize logs#777

Merged
mcgibbon merged 14 commits intomainfrom
refactor/logging_deduplicate
Feb 23, 2026
Merged

Reduce duplicated logging code, standardize logs#777
mcgibbon merged 14 commits intomainfrom
refactor/logging_deduplicate

Conversation

@mcgibbon
Copy link
Copy Markdown
Contributor

@mcgibbon mcgibbon commented Feb 2, 2026

This PR moves low-level logging logic into the configure_logging helper, which now configures all types of logging including wandb.

All entrypoints now log all of the information we log at the start of runs.

Changes:

  • LoggingConfig.configure_logging now takes in config and resumable arguments for configuring WandB.

  • Reduced duplicated logging code in train and inference entrypoints.

  • Tests added

Resolves #536

Copy link
Copy Markdown
Member

@jpdunc23 jpdunc23 left a comment

Choose a reason for hiding this comment

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

Thanks for the nice cleanup. I noticed a couple of minor inconsistencies and an unused arg. Otherwise, LGTM.

Comment thread fme/downscaling/inference/inference.py Outdated
config=config, env_vars=env_vars, resumable=resumable, **kwargs
config = to_flat_dict(dataclasses.asdict(self))
self.logging.configure_logging(
self.experiment_dir, log_filename, config=config, resumable=True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
self.experiment_dir, log_filename, config=config, resumable=True
self.experiment_dir, log_filename, config=config, resumable=False

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

While the default to this helper was False, there was a hard-code resumable=True where it's called on generation_config.configure_wandb below, so I think resumable=True is no change in behavior.

Can you check and make sure you agree?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread fme/downscaling/evaluator.py Outdated
self.logging.configure_wandb(
config=config, env_vars=env_vars, resumable=resumable, **kwargs
self.logging.configure_logging(
self.experiment_dir, log_filename, config=config, resumable=True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
self.experiment_dir, log_filename, config=config, resumable=True
self.experiment_dir, log_filename, config=config, resumable=False

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Similarly, resumable=True is hard-coded where this is called in practice. Not sure if this was intended, strange to have it for an inference-like entrypoint.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I see from the diff that in main() we had evaluator_config.configure_wandb(resumable=True, notes=beaker_url). So I understand you're preserving that behavior, but why not add a resumable: bool = False default arg to EvaluatorConfig.configure_logging and pass resumable=True when calling evaluator_config.configure_logging below in main()? This would preserve the existing behavior of EvaluatorConfig.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When I passed through this file the existing code was quite confusing - why is a default set that never gets used? I expected we run this with resumable=False based on the config method, but then saw it's actually resumable=True from the code below. I updated it to the style used in the training scripts as a cleanup.

I could split this out into a separate PR? I'll do that on Monday.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

Comment thread fme/core/logging_utils.py Outdated
experiment_dir: str,
log_filename: str,
config: Mapping[str, Any],
resumable: bool = False,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The default value for resumable was changed from True to False. Please double check that resumable=True is explicitly passed everywhere configure_wandb was previously called without the resumable argument.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted the change back to default True.

Comment thread fme/ace/inference/evaluator.py Outdated
def configure_wandb(
self, env_vars: dict | None = None, resumable: bool = False, **kwargs
):
config = to_flat_dict(dataclasses.asdict(self))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should remove to_flat_dict here (and other inference entrypoints) as was done in the training scripts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was actually a bug - I hadn't added to_flat_dict to the wandb helper. But it's a good idea, I added it and removed these calls.

Comment thread fme/core/logging_utils.py
experiment_dir=experiment_dir,
resumable=resumable,
dir=wandb_dir,
**kwargs,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

**kwargs is not longer used. Do we need it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@mcgibbon mcgibbon enabled auto-merge (squash) February 23, 2026 15:57
@mcgibbon mcgibbon merged commit baa60a5 into main Feb 23, 2026
7 checks passed
@mcgibbon mcgibbon deleted the refactor/logging_deduplicate branch February 23, 2026 16:15
William-gregory pushed a commit to William-gregory/ace that referenced this pull request Mar 3, 2026
This PR moves low-level logging logic into the configure_logging helper,
which now configures all types of logging including wandb.

All entrypoints now log all of the information we log at the start of
runs.

Changes:
- `LoggingConfig.configure_logging` now takes in `config` and
`resumable` arguments for configuring WandB.
- Reduced duplicated logging code in train and inference entrypoints.

- [ ] Tests added

Resolves ai2cm#536
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.

LoggingConfig use requires low level logic

2 participants