Closed candleindark closed 5 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
4423b41
) 97.66% compared to head (6ac7c8d
) 91.99%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
ATM, packages such as dandi-archive construct
Dandiset
objects usingDandiset.model_construct()
to allow extra attributes to be passed to the resultingDandiset
objects.
could you please elaborate/point to what you mean since I find no model_construct in dandi-archive codebase and if there is some custom use like that I wonder if that is something we should aim to avoid.
Here is the reason why this PR is needed.
Before the deprecation of the json_dict
method, the method was a workaround to generate a dictionary representation of DandiBaseModel
objects that's JSON serializable. I found that such workaround was not necessary and deprecated it in https://github.com/dandi/dandi-schema/pull/203. However, in resolving the failures in https://github.com/dandi/dandi-archive/pull/1823, I learned that dandi-archive attaches extra attributes to Dandiset
objects (extra in the sense that these attributes are not defined as fields in the Dandiset
model). To have these extra attributes included in the dictionary representation of the Dandiset
objects generated by the facilities provided by Pydantic, the model has to be marked explicitly to allow extra attributes, and the change in this PR is the explicit marking.
ATM, packages such as dandi-archive construct
Dandiset
objects usingDandiset.model_construct()
to allow extra attributes to be passed to the resultingDandiset
objects.could you please elaborate/point to what you mean since I find no model_construct in dandi-archive codebase and if there is some custom use like that I wonder if that is something we should aim to avoid.
The two deprecated methods in this line is the cause of the problem.
unvalidated
calls model_construct()
and json_dict
calls model_dump()
.
@jwodder and @satra please review on either you bless such changes.
If the JSON Schema has changed, we need to bump the schema version.
we would need to release again , so labeling accordingly
Once https://github.com/dandi/dandi-schema/pull/221 is merged to master. This PR should be ready for merge.
@yarikoptic This one is ready to merge.
ok, let's see where it would get us
This PR allows the dictionary representation of
Dandiset
to have extra attributes.ATM, packages such as dandi-archive construct
Dandiset
objects usingDandiset.model_construct()
to allow extra attributes to be passed to the resultingDandiset
objects. While extra attributes can be passed to the resultingDandiset
objects this way, the dictionary representations of theseDandiset
objects will not contain the extra attributes unlessDandiset
is explicitly configured to allow extra attributes.dandi-archive requires extra attributes passed in constructing a
Dandiset
object to be present in the dictionary representation of the object. This change in this PR explicitly configuresDandiset
to allow extra attributes to meet this requirement, and meeting this requirement will eliminate some of the failures encountered in https://github.com/dandi/dandi-archive/pull/1823.Please note, the change in this PR will modify the JSON schemata for
Dandiset
andPublishedDandiset
slightly. Both schemata will contain the additional key of"additionalProperties"
with the value oftrue
. Please consider increase the version number of the JSON schemas to 0.6.6.Note: This PR is a follow up to #203 to make a new version of dandi-schema with Pydantic 2.0 working for dandi-archive.