Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 1367_disturbance_model #1391 +/- ##
==========================================================
- Coverage 94.70% 94.55% -0.16%
==========================================================
Files 71 73 +2
Lines 7503 7568 +65
==========================================================
+ Hits 7106 7156 +50
- Misses 397 412 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jacobcook1995
left a comment
There was a problem hiding this comment.
This all looks sensible to me, I won't approve it though as I'm aware that this is an area where @davidorme has much stronger opinions than me and Taran
Ha. There's a lot written into that bolded much 😄 |
davidorme
left a comment
There was a problem hiding this comment.
Neat. As you say, makes good re-use of the existing discovery mechanisms. One question about typing!
| T = TypeVar("T") | ||
|
|
||
|
|
||
| def _discover_models(models: ModuleType, of_type: type[T]) -> list[type[T]]: |
There was a problem hiding this comment.
I think what is going on here is that we'd "ideally" have this as:
def _discover_models(models: ModuleType, of_type: type[BaseModel] | type[BaseDisturbance]) -> list[type[BaseModel] | type[BaseDisturbance)]:But because we can't import those two classes outside of the functions because of circularity (which bugs me but 🤷 ) we instead use this to tell the function that it is generically getting a type of something (not an instance etc.).
Is that right - if so, could you add a comment to that effect? It's probably pretty entry level but right now generic typing is out of my comfort zone, so it would be useful to have an explanation to hand 😄 .
Of course, if my explanation isn't right, then it needs a comment even more!
There was a problem hiding this comment.
Actually, no. We do want type[T] - i.e. to use generics - because that way I am locking the types of the inputs and outputs together. It's like saying that whatever the input, the output is a list if those same things. In your example, from the typing perspective there is no relationship between input and output. I could have type[BaseModel] as input and have a list of type[BaseDisturbance] as outputs.
Generics are really powerful, but can also be quite confusing.
There was a problem hiding this comment.
Docstring expanded with some details.
TaranRallings
left a comment
There was a problem hiding this comment.
Looks sensible to me as well.
Description
Adds the disturbance model discovery process. I have refactor the existing discovery engine such that it works equally for normal models and disturbance models. A disturbance testing model has been added for testing purposes within a
disturbancefolder. As the same model discovery process is used, the very same rules in terms of module name and class name conventions apply to the disturbances. New tests have been limited to just the new functionality, as the logic of the registry and discovery has already been thoroughly tested for normal models.The
priorityattribute will be added in the final PR, when this is hooked into the main workflow and an order needs to be defined for the disturbance models.Fixes #1368
Type of change
Key checklist
pre-commitchecks:$ pre-commit run -a$ poetry run pytestFurther checks