awesome-mecheng
awesome-mecheng copied to clipboard
Refactor job creation code
- This PR substantially refactors the job creation code to re-use the same CIV creation and validation code that we also use for display sets and archive items.
- Errors from asynchronous input validation (images and large files) now get caught and are reported back to the user as error message on the Job object. The job is then cancelled and not executed.
- It also enables selecting existing images and files for jobs through the UI and re-uses CIVs for existing values if possible. The same holds partially for the API view as well (see below). Making this possible, required consolidating the logic behind how we create an
InterfaceFormField
. The updated code also fixes a bug that I didn't know we had for archive item file uploads and is a lot more DRY and hopefully easier to work with in the future. It didn't make sense to separate this out into another PR, but it is quite a big changeset, sorry! - I have tried to add tests to cover all scenarios. Methods that aren't tested directly, are at least tested indirectly (through view tests that call these methods). If I have time, I will write direct tests where there are missing. Review can start in the meantime though!
- There is also some repetition/overlap here and there in the tests, but I didn't have time (yet) to clean that up and figured too many tests is better than too few tests.
Part of https://github.com/DIAGNijmegen/rse-roadmap/issues/335
Closes https://github.com/comic/grand-challenge.org/issues/3139 Closes https://github.com/comic/grand-challenge.org/issues/3325 Partially addresses https://github.com/comic/grand-challenge.org/issues/3368 Note: it is not yet possible to create a job with an existing non-image file through the API. This is out of scope for the current pitch and can be addressed later on, see https://github.com/DIAGNijmegen/rse-roadmap/issues/335#issuecomment-2304484574.
Note: It does not allow updating the interface kind for images in display sets and archive items through the API, that will be tackled in a separate PR after this one has been merged.