frictionlessdata / datapackage-py

A Python library for working with Data Packages.
https://frictionlessdata.io
MIT License
191 stars 43 forks source link

OO Design question #250

Closed ptvirgo closed 4 years ago

ptvirgo commented 4 years ago

Overview

Working with the PUDL coop, they asked me to touch base with you here as I'm getting used to the libraries. We're looking to do some archiving work that involves storing data packages via an api rather than saving directly to disk.

It would be handy if the data package objects were easily JSON serialized. Right now it looks to me like maintaining state between the descriptor, package contents, and serialization requires custom code written outside the datapackage objects' scope.

Any chance I'm missing something? Would it be feasible to work with datapackoge objects or restructure them such that serialization could be directly derived from the state of a given instance?


Please preserve this line to notify @roll (lead of this repository)

roll commented 4 years ago

Hi @ptvirgo,

Due to the long history of this lib and tight dependency on the specs it uses a slightly weird object model where the state is stored as package.descriptor and everything else are derived (e.g. instance variables).

Actually, at any time package.descriptor represents the full state of the package so it can be used as a JSON serialization.

ptvirgo commented 4 years ago

Okay - what I'm seeing with the spec and some tests is that I need to manage the descriptor as a large dict; I shouldn't be looking for a Contributor python class as a standalone object or anything.

roll commented 4 years ago

descriptor as a large dict Yes. It's the way we use it at the moment.

Please re-open if you'd like to discuss something else related to this matter