Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update copy_attribute plugin to include copying history attribute #2055

Merged
merged 5 commits into from
Dec 10, 2024

Conversation

mspelman07
Copy link
Contributor

Addresses https://metoffice.atlassian.net/browse/EPPT-1717

This PR updates the ability of the copy attributes plugin to include an exception for copying the history attribute if there are multiple input template cubes. In this case the most recent time stamp is used.

I've also slightly altered its ability to take in multiple cubes. Originally you could provide 1 template cubes and the attributes were copied from this cube onto all other provided cubes. I've now changed this to take in 1 cube and multiple template cubes requiring that the template cube attributes we are copying all match.

Testing:

  • Ran tests and they passed OK
  • Added new tests for the new feature(s)

@mspelman07 mspelman07 added the EPP PR's related to Enhancing Post Processing team label Nov 25, 2024
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.39%. Comparing base (84a8944) to head (8136aeb).
Report is 49 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2055    +/-   ##
========================================
  Coverage   98.39%   98.39%            
========================================
  Files         124      133     +9     
  Lines       12212    13117   +905     
========================================
+ Hits        12016    12907   +891     
- Misses        196      210    +14     

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

mo-philrelton
mo-philrelton previously approved these changes Dec 9, 2024
Copy link
Contributor

@mo-philrelton mo-philrelton left a comment

Choose a reason for hiding this comment

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

This looks good to me and all the tests are passing, with the exception of the one that always fails. There is one section that is failing CodeCov, I don't know if that needs fixing before merging.

I've left a few comments, they aren't necessary as they will work, they're just more Pythonic.


plugin = CopyAttributes(attributes)
result = plugin.process(cube0, template_cube_2, template_cube)
assert type(result) is Cube
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it really matters but it's probably better to use assert isinstance(result, Cube) here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

assert result.attributes["attribA"] == "tempA"
assert result.attributes["attribB"] == "tempB"
assert "attribC" not in result.attributes
assert id(result) == id(cube0)
Copy link
Contributor

Choose a reason for hiding this comment

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

If the id's are the same then they are the same object and you should use assert result is cube0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 99 to 103
assert type(result) is Cube
assert result.attributes["attribA"] == "tempA"
assert result.attributes["attribB"] == "tempB"
assert "attribC" not in result.attributes
assert id(result) == id(cube0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same pedantic comments here as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -76,3 +124,45 @@ def test_copy_attributes_single_input():
assert result.attributes["attribD"] == "valueD"
assert "attribC" not in result.attributes
assert id(result) == id(cube0)
Copy link
Contributor

Choose a reason for hiding this comment

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

assert result is cube0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@Katie-Howard Katie-Howard left a comment

Choose a reason for hiding this comment

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

The changes look fine, they seem to do what you want them to do. The tests seem to check what you need them too as well. The tests all seem to pass so I'm happy with this. You will need to rebase before it can be merged due to CopyAttributes becoming CopyMetada and then I'll approve 👍

Copy link
Contributor

@Katie-Howard Katie-Howard left a comment

Choose a reason for hiding this comment

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

These changes look fine after the updates and rebase - all the unit tests still run and pass 👍

@mo-philrelton mo-philrelton self-requested a review December 10, 2024 10:18
@mspelman07 mspelman07 merged commit 3c02114 into metoppv:master Dec 10, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EPP PR's related to Enhancing Post Processing team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants