Closed approxit closed 1 year ago
as mentioned in the original issue: https://github.com/golemfactory/yapapi/issues/1090
the ultimate goal here is to have a helper function able to generate a valid manifest with minimal, obligatory input, e.g.:
manifest = generate_manifest(
{
"payload": manifest_payload("sha3:05270a8a938ff5f5e30b0e61bc983a8c3e286c5cd414a32e1a077657"),
"net.inet.out.urls": ["http://bor.golem.network"],
}
)
What I've done:
.dict(by_alias)
and.parse_obj(obj)
methods that reflects methods found inpydantic
as this kind of models are justpydantic
aim.parse_imploded_obj(obj)
to ease with providing nested structuresAs this kind of DTOs should be implemented in pydantic, this should be mentioned as work item in https://github.com/golemfactory/golem-core-python/issues/54.
Keep in mind, that parsing object is quite a complex task. This implementation is not mentioned to be so robust as pydantic's.
.parse_obj(obj)
is just "base minimum".Also exploding nested dicts is very easy task, but supporting exploding dicts with lists... oh boy, code complexity explodes too... I'm not very happy how it turned out, but at least its working and its covered with tests.