adding the API contracts#7
Conversation
d33bs
left a comment
There was a problem hiding this comment.
Nice job! I'm requesting changes mainly because I think there's existing tooling you could make use of to reduce the amount of new code you need to create.
If you feel strongly about keeping things as-is just let me know and I'll circle back to give this more thought.
d33bs
left a comment
There was a problem hiding this comment.
Great work! LGTM, left a few comments about possible improvements.
| When running `just all` locally, the coverage badge will not be updated since it is intended to be updated as part of the CI workflow. | ||
|
|
||
| ``` | ||
| just all |
There was a problem hiding this comment.
Consider providing an indication of "which" "all" we're meaning when we call this from just. For example all-prep or something could help distinguish what you mean in the project.
| ``` | ||
|
|
||
| the coverage badge will be automatically updated as part of the workflow. | ||
| If you want to update the covererage then just run: |
There was a problem hiding this comment.
| If you want to update the covererage then just run: | |
| If you want to update the coverage, run: |
|
|
||
| ### Linting, testing, coverage, and updating coverage badges | ||
|
|
||
| We apply a custom script to update our coverage badge in the README during our CI workflow. |
There was a problem hiding this comment.
Awesome! Thanks for spelling this out.
| ) | ||
|
|
||
|
|
||
| class ImageArrayModel(BaseModel): |
There was a problem hiding this comment.
Probably for a future PR or idea work: consider using LinkML to help specify a generated pydantic model for this and other classes here. Doing this might free the work up for new opportunities.
|
|
||
|
|
||
| @beartype | ||
| def validate_image_array_shape_contracts( |
There was a problem hiding this comment.
Could this be a class method where relevant, perhaps as something called from the constructor when invoked? Same comments about the other validation methods here. Could be this is a wrong assumption in terms of your architectural intent.
| except Exception as e: | ||
| raise ContractError(f"Return schema validation failed: {e}") |
There was a problem hiding this comment.
With this and other exceptions I recommend being more specific with the exception (Exception is super broad and could entail other kinds of failures we shouldn't pass along to the dependents of this function).
| def get_pandera_image_schema() -> pa.SeriesSchema: | ||
| """ | ||
| Get Pandera schema for image array validation. | ||
|
|
||
| Returns | ||
| ------- | ||
| pa.SeriesSchema | ||
| Pandera schema for numeric arrays | ||
| """ | ||
| return create_image_array_schema() |
There was a problem hiding this comment.
This is a super thin function! Do we need it? If not, ditch it, it will make maintenance easier long-term (fewer abstractions the better). Think: every abstraction object must justify its existence with value-added operations. If it's just deadweight and adds an additional onion-layer without assisting our goals, remove it quickly and outright.
| (areasizeshape, "areasizeshape.compute is not implemented yet"), | ||
| (colocalization, "colocalization.compute is not implemented yet"), | ||
| (granularity, "granularity.compute is not implemented yet"), | ||
| (intensity, "intensity.compute is not implemented yet"), | ||
| (neighbors, "neighbors.compute is not implemented yet"), | ||
| (texture, "texture.compute is not implemented yet"), |
|
|
||
| # PyPI configuration file | ||
| .pypirc | ||
| data/* |
There was a problem hiding this comment.
Could this dir be incorporated into the tests suite?
Description
This PR adds data contracts for validating inputs and outputs. This is an initial step and will be added to as other modules get added in the future.
What kind of change(s) are included?
Checklist
Please ensure that all boxes are checked before indicating that this pull request is ready for review.