Skip to content

Comments

regrid.py: Partials#99

Merged
mxkpp merged 10 commits intodevelopmentfrom
maxkipp-refactor-regrid-py-dryify-2
Feb 13, 2026
Merged

regrid.py: Partials#99
mxkpp merged 10 commits intodevelopmentfrom
maxkipp-refactor-regrid-py-dryify-2

Conversation

@mxkpp
Copy link

@mxkpp mxkpp commented Feb 13, 2026

Closing earlier PR #86 for this one.

This PR includes commits from #98 so it could be merged on its own (larger PR) or after #98 (for smaller diff).

Steps taken for this PR:

  1. Add new Partials class to regrid.py to store partial functions which significantly reduce parameter passing and line count.

  2. Replace existing partials calls with usage of the new Partials class.

  3. Use regex to replace existing log calls with the new Partials calls.

Regex replacements:


### Debug True, ending with comma and line break
err_handler\.log_msg\(\s*config_options,\s*mpi_config,\s*debug=True,\s*msg=(.*?),\n
pt.log_debug(msg=$1

### Debug True, ending with close parens
err_handler\.log_msg\(\s*config_options,\s*mpi_config,\s*debug=True,\s*msg=(.*?)\)
pt.log_debug(msg=$1)

### Debug True, ending with raw line break
err_handler\.log_msg\(\s*config_options,\s*mpi_config,\s*debug=True,\s*msg=(.*?)\n
pt.log_debug(msg=$1


### Info (debug omitted), ending with comma and line break
err_handler\.log_msg\(\s*config_options,\s*mpi_config,\s*msg=(.*?),\n
pt.log_info(msg=$1

### Info (debug omitted), ending with close parens
err_handler\.log_msg\(\s*config_options,\s*mpi_config,\s*msg=(.*?)\)
pt.log_info(msg=$1)

### Info (debug omitted), ending with raw line break
err_handler\.log_msg\(\s*config_options,\s*mpi_config,\s*msg=(.*?)\n
pt.log_info(msg=$1


### Warning, ending with comma and line break
err_handler\.log_warning\(\s*config_options,\s*mpi_config,\s*msg=(.*?),\n
pt.log_warn(msg=$1

### Warning, ending with close parens
err_handler\.log_warning\(\s*config_options,\s*mpi_config,\s*msg=(.*?)\)
pt.log_warn(msg=$1)

### Warning, ending with raw line break
err_handler\.log_warning\(\s*config_options,\s*mpi_config,\s*msg=(.*?)\n
pt.log_warn(msg=$1


### Error, ending with comma and line break
err_handler\.log_error\(\s*config_options,\s*mpi_config,\s*msg=(.*?),\n
pt.log_err(msg=$1

### Error, ending with close parens
err_handler\.log_error\(\s*config_options,\s*mpi_config,\s*msg=(.*?)\)
pt.log_err(msg=$1)

### Error, ending with raw line break
err_handler\.log_error\(\s*config_options,\s*mpi_config,\s*msg=(.*?)\n
pt.log_err(msg=$1


### Critical, ending with comma and line break
err_handler\.log_critical\(\s*config_options,\s*mpi_config,\s*msg=(.*?),\n
pt.log_crit(msg=$1

### Critical, ending with close parens
err_handler\.log_critical\(\s*config_options,\s*mpi_config,\s*msg=(.*?)\)
pt.log_crit(msg=$1)

### Critical, ending with raw line break
err_handler\.log_critical\(\s*config_options,\s*mpi_config,\s*msg=(.*?)\n
pt.log_crit(msg=$1 

Additions

class Partials in regrid.py

Removals

  • Previous log calls

Changes

  • Replace log calls with usage of Partials

Testing

  1. Tested calibrations and forecasts in RTE

Screenshots

Notes

Todos

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Target Environment support

  • Linux

"""A simple list of partials for common function / method calls."""

def __init__(self, mpi_config: MpiConfig, config_options: ConfigOptions):
a1 = (mpi_config, config_options, err_handler)

Choose a reason for hiding this comment

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

Can we be more verbose and use args1 args2. Or maybe even args_esmf args_log.

Copy link
Author

Choose a reason for hiding this comment

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

Updated to args1 and args2, keeping it nameless since each tuple might serve multiple purposes.

"Unable to create link: " + input_file + " to: " + tmpFile
)
err_handler.log_critical(config_options, mpi_config)
pt.log_crit(msg=f"Unable to create link: {input_file} to: {tmpFile}")

Choose a reason for hiding this comment

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

I think we can drop the msg= for these method calls. I think it is pretty clear what we are passing in and I think positionally we are fine. Please double check before making the change.

Copy link
Author

Choose a reason for hiding this comment

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

Updated to remove the instances of msg=

@mxkpp mxkpp requested a review from mdeshotel February 13, 2026 16:36
@mxkpp mxkpp merged commit bf16354 into development Feb 13, 2026
6 checks passed
@mxkpp mxkpp deleted the maxkipp-refactor-regrid-py-dryify-2 branch February 13, 2026 16:55
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.

2 participants