-
-
Notifications
You must be signed in to change notification settings - Fork 734
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
Better partial support #527
Conversation
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.
👍 Looks good to me!
- Reviewed the entire pull request up to 6104107
- Looked at
385
lines of code in3
files - Took 1 minute and 57 seconds to review
More info
- Skipped
0
files when reviewing. - Skipped posting
3
additional comments because they didn't meet confidence threshold of85%
.
1. instructor/dsl/partial.py:98
:
- Assessed confidence :
50%
- Comment:
Ensure that theget_partial_model
method is pure (i.e., it always returns the same result given the same arguments and doesn't have any side effects). This is important because thelru_cache
decorator is used, which caches the results of the method calls with the given arguments. - Reasoning:
Thelru_cache
decorator is used on theget_partial_model
method in thePartialBase
class. This is a good practice as it will cache the results of the method calls with the given arguments, improving performance for repeated calls with the same arguments. However, it's important to ensure that the method is pure (i.e., it always returns the same result given the same arguments and doesn't have any side effects), otherwise the caching could lead to incorrect results.
2. instructor/dsl/partial.py:299
:
- Assessed confidence :
50%
- Comment:
Ensure that the change in the__class_getitem__
method of thePartial
class, where the fields are wrapped withPartial
but not made optional, doesn't break any existing functionality that relies on the fields being optional. - Reasoning:
The__class_getitem__
method in thePartial
class is wrapping the fields withPartial
but not making them optional. This is a change from the previous implementation where the fields were made optional. This change is explained in the comments and seems to be intentional, but it's important to ensure that this doesn't break any existing functionality that relies on the fields being optional.
3. tests/dsl/test_partial.py:16
:
- Assessed confidence :
100%
- Grade:
80%
- Comment:
Consider adding a test case that validates the functionality of the partial model with some partial data. This will ensure that the partial model can handle and validate partial data correctly. - Reasoning:
The test casetest_partial
is checking the JSON schema of the partial model. However, it's not actually testing the functionality of the partial model, i.e., whether it can handle partial data correctly. It would be beneficial to add a test case that validates the functionality of the partial model with some partial data.
Workflow ID: wflow_0wk46lx0qcXuolEe
Not what you expected? You can customize the content of the reviews using rules. Learn more here.
this is great yeah the _Partial might need some work but this looks correct. if we break backwards compat, can we keep only one PArtial |
I was able to make this cleaner with the use of another class |
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.
Changes look good to me! Nice approach with the MakeFieldsOptional
, that's really clean
I noticed that when using
Partial[MyModel]
the model wasn't always populating required fields. With this change, the JSON schema we send to the model doesn't change (aside from having the model names updated toPartial{...}
to make it match validation).The naming of all the
Partial
/_Partial
classes is a little weird. I was trying to keep this backwards compatible with the existing implementation. Open to suggestions on how to make this better.Summary:
This PR improves the handling of partial models in the
instructor
package, adds tests for the updated functionality, and updates some dependencies to optional inpoetry.lock
.Key points:
Partial
class ininstructor/dsl/partial.py
to better handle partial models.tests/dsl/test_partial.py
to test the updatedPartial
class.poetry.lock
.Generated with ❤️ by ellipsis.dev