Skip to main content

Data migration utilities

Project description

Build Status Documentation Status

https://binstar.org/blaze/odo/badges/build.svg https://binstar.org/blaze/odo/badges/version.svg

Data migration in Python

Documentation

Example

Odo migrates data between different containers

>>> from odo import odo
>>> odo((1, 2, 3), list)
[1, 2, 3]

It operates on small, in-memory containers (as above) and large, out-of-core containers (as below)

>>> odo('myfile.hdf5::/data', 'postgresql://user:pass@host::my-table')
Table('my-table', MetaData(bind=Engine(postgresql://user:****@host)), ...)

Odo leverages the existing Python ecosystem. The example above uses sqlalchemy for SQL interation and h5py for HDF5 interaction.

Method

Odo migrates data using network of small data conversion functions between type pairs. That network is below:

odo conversions

Each node is a container type (like pandas.DataFrame or sqlalchemy.Table) and each directed edge is a function that transforms or appends one container into or onto another. We annotate these functions/edges with relative costs.

This network approach allows odo to select the shortest path between any two types (thank you networkx). For performance reasons these functions often leverage non-Pythonic systems like NumPy arrays or native CSV->SQL loading functions. Odo is not dependent on only Python iterators.

This network approach is also robust. When libraries go missing or runtime errors occur odo can work around these holes and find new paths.

This network approach is extensible. It is easy to write small functions and register them to the overall graph. In the following example showing how we convert from pandas.DataFrame to a numpy.ndarray.

from odo import convert

@convert.register(np.ndarray, pd.DataFrame, cost=1.0)
def dataframe_to_numpy(df, **kwargs):
    return df.to_records(index=False)

We decorate convert functions with the target and source types as well as a relative cost. This decoration establishes a contract that the underlying function must fulfill, in this case with the fast DataFrame.to_records method. Similar functions exist for append, to add to existing data, and resource for URI resolution.

  • convert: Transform dataset into new container

  • append: Add dataset onto existing container

  • resource: Given a URI find the appropriate data resource

  • odo: Call one of the above based on inputs. E.g. odo((1, 2, 3), list) -> convert(list, (1, 2, 3)) while L = []; odo((1, 2, 3), L) -> append(L, (1, 2, 3))

Finally, odo is also aware of which containers must reside in memory and which do not. In the graph above the red-colored nodes are robust to larger-than-memory datasets. Transformations between two out-of-core datasets operate only on the subgraph of the red nodes.

LICENSE

New BSD. See License File.

History

Odo was factored out from the Blaze project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sangreal-odo-0.0.5.tar.gz (145.3 kB view details)

Uploaded Source

Built Distribution

sangreal_odo-0.0.5-py3-none-any.whl (143.6 kB view details)

Uploaded Python 3

File details

Details for the file sangreal-odo-0.0.5.tar.gz.

File metadata

  • Download URL: sangreal-odo-0.0.5.tar.gz
  • Upload date:
  • Size: 145.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for sangreal-odo-0.0.5.tar.gz
Algorithm Hash digest
SHA256 2829f7854a7f76ff77389173d203cb58c3c144088fe7990c941a1b52640d50f5
MD5 8e18689287cd6a4a0a25103462af4262
BLAKE2b-256 7ace3cbd4067f84fdcdf2e8fdb27e9dfc57228c560158b328dd415c3d0a3a392

See more details on using hashes here.

File details

Details for the file sangreal_odo-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: sangreal_odo-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 143.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for sangreal_odo-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 07b7845b2f87176538868feb8932110ae58d324d337805222774c763186fe8f4
MD5 774bf21d68e6148aca549992dd3a017a
BLAKE2b-256 7af912c8c28fb322052f90123636a4a9e8075f7a05946fcd28d0d99852fc0ec7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page