-
Notifications
You must be signed in to change notification settings - Fork 482
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
Add UT for Model #1229
Add UT for Model #1229
Conversation
@@ -54,7 +54,7 @@ def get(self, k, default=None): | |||
try: | |||
return getattr(self, k) | |||
except AttributeError: | |||
return self.kwargs.get(k, default=default) | |||
return self.kwargs.get(k, default) |
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.
dict.get
does not havedefault
parameter
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.
Gotcha.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1229 +/- ##
==========================================
+ Coverage 80.33% 80.87% +0.53%
==========================================
Files 95 95
Lines 6602 6605 +3
==========================================
+ Hits 5304 5342 +38
+ Misses 1298 1263 -35
☔ View full report in Codecov by Sentry. |
9884d69
to
8178285
Compare
8178285
to
9d3d032
Compare
9d3d032
to
1d9369a
Compare
I mocked out DB and Select related classes, so in some test cases, the model will not actually interact with the DB. |
Later, UT will be added for fit and predict of different AI frameworks in |
a4c045d
to
d88b1a6
Compare
expect = postprocess(to_call(X)) | ||
assert np.allclose(predict_mixin._predict_one(X), expect) | ||
|
||
# Bad postprocess |
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.
What type of bad postprocess
?
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.
if isinstance(self.postprocess, Artifact):
outputs = [self.postprocess.artifact(o) for o in outputs]
elif self.postprocess is not None:
raise ValueError('Bad postprocess')
postprocess must be a Arfifact or None
|
||
|
||
@patch.object(Datalayer, 'add') | ||
def test_pm_predict_and_listen(mock_add, predict_mixin, local_empty_db): |
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.
Nice.
db.databackend.id_field = 'id_field' | ||
|
||
# overwrite = True | ||
with patch.object(predict_mixin, '_predict_with_select_and_ids') as mock_predict: |
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.
Nice -- yes this is needed (important for efficiency).
@@ -54,7 +54,7 @@ def get(self, k, default=None): | |||
try: | |||
return getattr(self, k) | |||
except AttributeError: | |||
return self.kwargs.get(k, default=default) | |||
return self.kwargs.get(k, default) |
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.
Gotcha.
Description
#1172
Related Issues
Checklist
make test
successfully?Additional Notes or Comments