Closed cpelley closed 1 month ago
@gavinevans, @bayliffe
I think we want might eventually want to move away from the use of the term 'Plugin', so any ideas for suitable alternative naming to MetaPluginCloudCondensationLevel
are welcome. Processing module is being thrown around as a way of people describing what IMPROVER currently calls plugins (EPP, otherwise).
So perhaps MetaProcModuleCloudCondensationLevel
?
Thanks for your thorough review @bayliffe ❤️ I'll take action now. I'll also update the PR description with details around the use of mock, sentinel etc. (apologies for this oversight).
I think we want might eventually want to move away from the use of the term 'Plugin',
Hallelujah!
@bayliffe, I have updated the ticket description with an explanation of my usage of mock/path/sentinel.
EDIT: I have just generalised as_cube
and as_cubelist
support for inputs to better reflect my current interpretation of the reviewer feedback (I reimplemented flatten since we are reliant on the handling of this function).
@bayliffe, appologies for making additional changes. I looked back at this again after our brief chat this morning and felt that perhaps what I had done wasn't quite aligned with your review feedback. Now, in summary:
as_cubelist
can be passed pretty much anything and it just verifies that a cubelist containing cubes is returned.as_cube
now calls as_cubelist
under the hood, then either returns the first index (when of length 1) or otherwise performs a CubeList.merge_cube
in an attempt to return a single cube.The second half of EPP required IMPROVER plugin changes are captured in https://github.com/metoppv/improver/pull/2003 (that PR builds on this for the remaining plugins).
Thanks @bayliffe, @gavinevans I have made changes in reflection of the reviews given 👍
Thanks @gavinevans, I think all feedback has been actioned.
People have yet to take the bait on my request for discussion around naming convention to these meta 'plugins'.
In absence of discussion, I have now gone with simply Meta<name>
... (motivated by avoiding the discussion around semantics of the term plugin by removing it from the name). I think 'processing module' is potentially more useful term but taking this decision to rename should hopefully allow us to leave that discussion for another time.
New issues spawned from this work (out of scope of this PR):
@cpelley I'm not sure that I'm best placed to comment on the use of the word "plugin" to describe the IMPROVER "plugins", but if you'd like to not include this term within your Meta
"plugins", then that seems fine from my perspective.
First subset of CLI modifications to IMPROVER required by EPP. This is intended to test the water against the types of change that I would make to the remainder CLI's.
CLI layers modified:
High-level summary of changes:
common_input_handle
utilities:as_cube
andas_cubelist
CubeList
orCube
where it makes sense to do so.CopyAttributes
plugin which was before handled by thecopy_attributes
CLI layer.MetaPluginCloudCondensationLevel
meta-plugin which handles callingHumidityMixingRatio
andCloudCondensationLevel
, whichcloud_condensation_level
CLI was doing before.Issues
Mock/patch usage explanation
In this test, we patch both the
as_cube
andas_cubelist
functions, replacing them with mock objects. This allows us to verify how they are called within the code. Specifically, we define aside_effect
for theas_cube
mock object to raise a customHaltExecution
exception when invoked. This setup enables us to check that theas_cube
andas_cubelist
functions are called with the correct arguments and ensures that the remainder of the plugin code (which isn't under test) does not execute.The use of
sentinel
helps create unique, identifiable objects for testing purposes. By passing a dummy template cube object (asentinel
), we can verify that the mockedas_cube
function is called with it as its argument. This approach simplifies the test setup by eliminating the need to create real iris cubes or handle the complexities associated with them. Thus, our unit test remains focused and isolated, only testing the behavior under consideration without external dependencies.