-
Notifications
You must be signed in to change notification settings - Fork 3
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
Major refactor of helper functions #167
base: main
Are you sure you want to change the base?
Conversation
…e-super_kind interfaces
This reverts commit d50d251.
) | ||
|
||
# retrieve existing archive item pk | ||
items = get_archive_items(c, archive.pk, len(old_items_list)) | ||
|
||
old_civ_count = len(items[-1].values) | ||
|
||
with pytest.raises(ValueError) as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Covered by unittests
}, | ||
"predictions-csv-file": [ | ||
Path(__file__).parent / "testdata" / "test.csv" | ||
CIV_SET_PARAMS = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defining this 4x seemed a bit verbose.
|
||
|
||
def test_add_cases_to_reader_study_multiple_files(local_grand_challenge): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Covered by unittests
Ugh. I was afraid of this. There are some race conditions between a RawImageUpload being processed, a CIV being created and the |
Fingers crossed... locally everything ran butter smooth. It's the CI restraints that show the race conditions. |
DeprecationWarnings, fixing...
.. Done! |
How can it be that something that is referenced via a hyperlink from the API (e.g. via "Sometimes" :- because it is flaky. |
Ok, possible fix: not recursing in tests when |
Converting this to a draft and going to cut it up in smaller piece for reviewing. |
This PR refactors existing helper functions (i.e.
Client.update_archive_item
) and adds some new ones that make sense.These are the helper functions now:
update_archive_item
add_cases_to_archive
(new)update_display_set
(new)add_cases_to_reader_study
run_external_job
upload_cases
(untouched)Proto models
The core of this PR is the 'gcapi/models_proto.py'.
This PR introduces proto-models. These are models of things that are yet to be. Their main function is to separate the creation/saving logic from the validation logic. This allows for quick unit tests to cover corner cases in validation, while simultaneously allowing to validate all values before anything hits the platform.
These 'preflight' validations were, partially, already in place for
add_cases_to_reader_study
but are now ubiquitous for all helper functions.While refactoring I ran into several issues concerning the adaptation of models, which I fixed as I went. With deadline pressure and random fixes, flaky tests, et cetera this is now a messy and large change set. Sorry!
Below are some descriptions of additional fixes that are included in the PR.
Both
str
, and [str
] are allowedSourcing a CIV from one file no longer requires a one-lengthed list, the helper functions automagically handle both. This also applies to
pathlib.Path
..details
API now accepts anapi_url
keyword argumentSince we are casting to models it made more sense to be able to call the
.details
with api_url than to manually figure out whichgcapi.models
one is to use.This replaces:
With:
.create()
/.update()
/.partial_update()
-> modelsAPI calls that support
.create(..)
,.update(..)
, and.partial_update(..)
now returngcapi.models
instead ofdicts
.Using existing images
Related to the actual pitch:
One can add an existing image as follows (pulled from a test):
Some typing stuff
Closes: #163
Usage of
JSON
for"File"
super_kind interfaces.Closes: #153
It is now possible to provide:
"Value"
interfacedict
(or other JSON-like python object) to a super-kind:"File"
interfaceNote that for the
"File"
one, this cannot be done for an interface with kind"String"
. It would be far too easy to have a non-existing file path as content for a String interface. All other interfaces should error out on the platform and run into schemas there.