payu-org / payu

A workflow management tool for numerical models on the NCI computing systems
Apache License 2.0
21 stars 27 forks source link

Fix metadata warning formatting #451

Open jo-basevi opened 5 months ago

jo-basevi commented 5 months ago

The metadata related warnings look a bit broken with unclosed parentheses. e.g.

/g/data/vk83/prerelease/apps/payu/dev/lib/python3.9/site-packages/payu/metadata.py:125: MetadataWarning: No experiment uuid found in metadata. Generating a new uuid
  warnings.warn("No experiment uuid found in metadata. "
Found experiment archive: /scratch/PROJECT/USER/access-esm/archive/access-esm1.5-configs

So it has the filename, line number, name of the warning and the line of the source code where warning get raised. The line of source code e.g. warnings.warn(.., can probably be left out of the log messages.

Wondering whether it'll be worth using logging.warning instead of warnings.warn for metadata warnings as reading more python documentation (e.g. https://docs.python.org/3/howto/logging.html), warnings.warn is for if the warning can be avoided in the clients application, while logging.warning is when the situation should be noted. This makes more sense when warning the user that a new experiment uuid is being generated.

aidanheerdegen commented 5 months ago

Wondering whether it'll be worth using logging.warning instead of warnings.warn for metadata warnings as reading more python documentation (e.g. https://docs.python.org/3/howto/logging.html), warnings.warn is for if the warning can be avoided in the clients application, while logging.warning is when the situation should be noted. This makes more sense when warning the user that a new experiment uuid is being generated.

Sounds like good idea.