Skip to content

(Towards #3398) move LFRicRedundantComputationTrans and update to use kwargs.#3417

Open
arporter wants to merge 11 commits into
masterfrom
3398_move_redun_trans
Open

(Towards #3398) move LFRicRedundantComputationTrans and update to use kwargs.#3417
arporter wants to merge 11 commits into
masterfrom
3398_move_redun_trans

Conversation

@arporter
Copy link
Copy Markdown
Member

An initial step before updating the options accepted by this transformation.

@arporter arporter self-assigned this Apr 27, 2026
@arporter arporter marked this pull request as draft April 27, 2026 15:14
@arporter arporter added enhancement in progress LFRic Issue relates to the LFRic domain labels Apr 27, 2026
@arporter
Copy link
Copy Markdown
Member Author

Test failure is the treesitter one that #3408 fixes.

@arporter arporter added the Blocked An issue/PR that is blocked by one or more issues/PRs. label Apr 28, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.96%. Comparing base (59b71f5) to head (2ae68a3).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3417   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files         389      390    +1     
  Lines       54598    54616   +18     
=======================================
+ Hits        54579    54597   +18     
  Misses         19       19           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@arporter arporter marked this pull request as ready for review April 29, 2026 07:18
@arporter arporter removed the Blocked An issue/PR that is blocked by one or more issues/PRs. label Apr 29, 2026
@arporter
Copy link
Copy Markdown
Member Author

A fairly straightforward PR that just moves LFRicRedundantComputationTrans to the correct location and updates it to use kwargs. One for @LonelyCat124 @sergisiso or @hiker.

Copy link
Copy Markdown
Collaborator

@LonelyCat124 LonelyCat124 left a comment

Choose a reason for hiding this comment

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

Hi @arporter - few things to sort out, mostly in tests/formatting but I think there are a couple of errors in the kwargs update also.

Edit: Also can you double check if this is used in lfric_apps/core scripts and make sure they're updated with the new import location (conditionally with importError probably).

import RaisePSyIR2LFRicAlgTrans
from psyclone.domain.lfric.transformations.lfric_loop_fuse_trans \
import LFRicLoopFuseTrans
from psyclone.domain.lfric.transformations.lfric_redundant_computation_trans \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use parentheses here instead of \. You don't need to change the whole file unless you want.

validity checks.
:param options: a dictionary with options for transformations.
:type options: Optional[Dict[str, Any]]
:param int options["depth"]: the depth of the stencil if the value
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You don't need to keep the options declarations in the docstring now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Once thats done I'll check the generated docs are correct.

# TODO #2668: Deprecate options dictionary.
depth = options.get("depth")
else:
depth = self.get_option("depth", **kwargs)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You don't need the else block for the apply method - we just have the depth kwarg value. Do we have a test for this behaviour as I think the current implementation should fail that test as self.get_option("depth", **kwargs) should always return None here I think.

rc_trans = LFRicRedundantComputationTrans()
loop = schedule.children[4]
with pytest.raises(TransformationError) as excinfo:
rc_trans.apply(loop, {"depth": 0})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Update the test to use keywords.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Keep one test (or duplicate one test) with kwargs and add a TODO to remove it.

rc_trans = LFRicRedundantComputationTrans()
loop = schedule.children[4]
with pytest.raises(TransformationError) as excinfo:
rc_trans.apply(loop, {"depth": 1})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here also

schedule = invoke.schedule
rc_trans = LFRicRedundantComputationTrans()
loop = schedule.children[4]
rc_trans.apply(loop, {"depth": 3})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And again

# there are 3 halo exchange calls
index = 3
loop = schedule.children[index]
rc_trans.apply(loop, {"depth": 3})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

also

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also lines 324, 370, 424, 473, 561, 614, 728, 783, 792, 809, 830, 853, 859, 866, 902, 910, 1014, 1045-1046, 1052, 1062, 1087, 1094, 1118, 1126, 1153, 1160, 1168, 1229

@LonelyCat124
Copy link
Copy Markdown
Collaborator

Looking at the ITs failures it lokos like this was handled previously by the Dynamo compatability layer in transformations.py - so either we can update that or we can update lfric_apps/core scripts (the latter is probably preferable at this point).

@sergisiso
Copy link
Copy Markdown
Collaborator

@arporter @LonelyCat124 I have the new branches that force push to our lfric_apps almost ready, let me do the change and give you a hash to try, otherwise it will conflict with my changes. I will look at this tomorrow.

@arporter
Copy link
Copy Markdown
Member Author

OK, thanks Sergi.

@sergisiso
Copy link
Copy Markdown
Collaborator

@arporter Updating the LFRic hash to 300225d72ffca5c843cdeceeedb353f6eb01dfa9 should work, but you need to bring the branch to master first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement LFRic Issue relates to the LFRic domain reviewed with actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants