-
Notifications
You must be signed in to change notification settings - Fork 0
Fix more issues with (de)serializing recommendations and criteria #240
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
Conversation
|
Test fails with: This means that at least one task gets created more than once, although it shouldn't be. The results from some tasks (specifically, criteria) are required multiple times from different (or even the same) population_intervention_pair. These criteria/tasks should be executed just once, and this assertion makes sure that each task is indeed only created once, even if required multiple times. I don't know yet where the issue comes from, but this must be fixed before merging. |
|
I will update this once we are done with #242. I think, the changes in this pull request should work better then. |
At least some tests call the method with bytes.
…tion Before this change, the _root attribute was not included in the serialized representation and thus not stored in the database. As a result, the execution graph for a recommendation that had been restored from the database was different from the execution graph for a newly constructed recommendation.
Before this change, the special style in which the criterion includes not only its attributes but also its class in the serialization data dictionary was when serializing the Recommendation._base_criterion attribute. The ActivePatients criterion was compatible with that style but other criteria were not. As a result using any criterion but ActivePatients as the value of the _base_criterion attribute led to (de)serialization problems.
…ctly
Before this change, the id assignment for recommendations, pi_pairs,
and criteria did interact consistently with serialization to the
database.
The new approach which this change implements uses the following
principles:
* Each of the above mentioned object types has an id attribute and
accepts an id keyword parameter in its constructor. When no id is
supplied, the attribute is initialized to None.
* For newly constructed objects (as opposed to objects that have been
restored from the database) the value of the id attribute is None.
* The serialized representation of an object graph includes the id
attributes of all objects but all id attributes must be None when the
serialized representation is computed.
* As a consequence of the previous item: The hash value of an object
graph includes the id attributes of all objects but all id attributes
must be None when the hash is computed.
These principles lead to the following lifecycle for a
recommendation (the child object are processed similarly):
1. The recommendation is newly created, for example from information
retrieved from a recommendation server. All ids are None.
2. The recommendation is registered:
a. A hash is computed (including the None ids) and the database is
queried. The database is queried with the computed hash.
b.1 No match is found. The id from the matching row is assigned to
the recommendation.
b.2 A match is found. A preliminary representation with the
computed hash but without the JSON representation and without
the serialized execution graph is stored in the database. The
result is an id for the recommendation. That id is assigned to
the recommendation.
c. The JSON representation and serialized execution graph are
computed (including the assigned id) and the database row is
updated.
3. In a subsequent run, the recommendation is restored:
a. The database row is found based on the URL and version of the
recommendation.
b. The JSON representation of the object graph is loaded from the
database row.
c. The object graph for the recommendation and its child objects is
deserialized from the JSON representation, including the
previously assigned ids.
a5579d1 to
32df5a4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #240 +/- ##
==========================================
- Coverage 87.61% 87.59% -0.02%
==========================================
Files 92 92
Lines 5887 5910 +23
==========================================
+ Hits 5158 5177 +19
- Misses 729 733 +4 ☔ View full report in Codecov by Sentry. |
Running the tests locally, I got a few errors but at least some seem to be the results of issues with connections to recommendation and terminology servers.