datawork.instances.data

Instances of Data for common data payloads.

class datawork.instances.data.FileData(desc=None, name=None)[source]

Base class for any disk-native data.

For example, SQLiteData will use this as a base class.

static check_type(value)[source]

Check that value is a filename.

read(filename)[source]

Read by setting the filename.

static serialize(data)[source]

Simply return the filename.

write(filename)[source]

Copy file to new location.

class datawork.instances.data.JSONData(desc=None, name=None)[source]

A Data class for primitive JSON serializable types.

The so-called “primitive types” in JSON are:
  • string
  • numeric types
  • object (in python this is a dict)
  • array
  • boolean
  • null
In this class, hierarchies of the following types are supported:

Note that although other types than these may be serializable in Python (by subclassing json.JSONEncoder), the primitive types can be serialized/deserialized unambiguously. For example, we do not support tuples, although the json module supports serializing them by casting them to lists.

static check_type(value)[source]

Check that value is a hierarchy of primitive JSON types.

read(filename)[source]

Read JSON text.

static serialize(data)[source]

Convert to JSON text.

write(filename)[source]

Write as JSON text.

class datawork.instances.data.KerasModelData(desc=None, name=None)[source]

A Data class for Keras models.

static check_type(value)[source]

Check that value is a keras.models.Model.

read(filename)[source]

Read from HDF5.

write(filename)[source]

Write to HDF5.

class datawork.instances.data.PandasData(*args, **kwargs)[source]

Data type for Pandas DataFrames and Series.

__init__(*args, **kwargs)[source]

Construct PandasData.

static check_type(value)[source]

Check that value is a DataFrame or Series.

read(filename)[source]

Read from msgpack.

static serialize(data)[source]

Write to msgpack.

write(filename)[source]

Write msgpack.

class datawork.instances.data.TorchModelData(desc=None, name=None)[source]

A Data class for PyTorch models.

static check_type(value)[source]

Check that value is a torch.nn.Module.

read(filename)[source]

Load state dict and module class.

write(filename)[source]

Write state dict and serialize module class.