Skip to main content

Tools for managing pastas projects

Project description

pastastore Documentation Status Codacy Badge Codacy Badge PyPI

pastastore

This module contains a tool to manage Pastas timeseries and models in a database.

Storing timeseries and models in a database gives the user a simple way to manage Pastas projects with the added bonus of allowing the user to pick upwhere they left off, without having to (re)load everything into memory.

The connection to database/disk/memory is managed by a connector object. Currently, four connectors are included. The first implementation is an in-memory connector. The other three store data on disk or in a database. The PasConnector implementation writes human-readable JSON files to disk. The ArcticConnector and PystoreConnector implementations are designed to have fast read/write operations, while also compressing the stored data.

  • In-memory: uses dictionaries to hold timeseries and pastas Models in-memory. Does not require any additional packages to use.

  • Pastas: uses Pastas write and read methods to store data as JSON files on disk. Does not require any additional packages to use.

  • Arctic is a timeseries/dataframe database that sits atop MongoDB. Arctic supports pandas.DataFrames.

  • PyStore is a datastore (inspired by Arctic) created for storing pandas dataframes (especially timeseries) on disk. Data is stored using fastparquet and compressed with Snappy.

Installation

Install the module by typing pip install pastastore.

For installing in development mode, clone the repository and install by typing pip install -e . from the module root directory.

Please note that there are external dependencies when using connectors based on pystore or arctic. These dependencies are not automatically installed (see Dependencies section)!

Usage

The following snippets show typical usage. The general idea is to first define the connector object. The next step is to pass that connector to PastaStore.

Using in-memory dictionaries

This works out of the box after installing with pip without installing any additional Python dependencies or external software.

import pastastore as pst

# define connector
conn = pst.DictConnector("my_connector")

# create project for managing Pastas data and models
store = pst.PastaStore("my_project", conn)

Using Pastas read/load methods

Store data on disk as JSON files (with .pas extension) using Pastas read and load methods. This works out of the box after installing with pip without installing any additional Python dependencies or external software.

import pastastore as pst

# define connector
path = "./data/pas"
conn = pst.PasConnector("my_connector")

# create project for managing Pastas data and models
store = pst.PastaStore("my_project", conn)

Using Arctic

Store data in MongoDB using Arctic. Only works if there is an instance of MongoDB running somewhere.

import pastastore as pst

# define arctic connector
connstr = "mongodb://localhost:27017/"  # local instance of mongodb
conn = pst.ArcticConnector("my_connector", connstr)

# create project for managing Pastas data and models
store = pst.PastaStore("my_project", conn)

Using Pystore

Store data on disk as parquet files using compression. Only works if python-snappy and pystore are installed.

import pastastore as pst

# define pystore connector
path = "./data/pystore"  # path to a directory
conn = pst.PystoreConnector("my_connector", path)

# create project for managing Pastas data and models
store = pst.PastaStore("my_project", conn)

The database read/write/delete methods can be accessed through the reference to the connector object. For easy access, the most common methods are registered to the store object. E.g.

series = store.conn.get_oseries("my_oseries")

is equivalent to:

series = store.get_oseries("my_oseries")

Dependencies

This module has several dependencies (depending on which connector is used):

If using Dictconnector or PasConnector:

  • No additional dependencies are required.

If using ArcticConnector:

  • Arctic requires MongoDB, e.g. install the Community edition (Windows, MacOS).

  • OR, if you wish to use Docker for running MongoDB see the installation instructions here.

If using PystoreConnector:

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

pastastore-0.6.1.tar.gz (31.6 kB view details)

Uploaded Source

Built Distribution

pastastore-0.6.1-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file pastastore-0.6.1.tar.gz.

File metadata

  • Download URL: pastastore-0.6.1.tar.gz
  • Upload date:
  • Size: 31.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for pastastore-0.6.1.tar.gz
Algorithm Hash digest
SHA256 e016da8f1a808abbbf331a07d7eeb384fee8deb212be5243a067f1cdf223f7f4
MD5 bff0a44aa4f3b689ff9b87d7d3b3c882
BLAKE2b-256 00ed559b9699f6bf57b541422ed68b8f13efd6eda6e3c461bddf0161117e17dd

See more details on using hashes here.

File details

Details for the file pastastore-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: pastastore-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for pastastore-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46732c97f1d606cdb8cc82b0c1863773f8d7ba1a631082d0b3e5247818b9bb06
MD5 eea098d8b3ee8fec1a3f1396ca85cd35
BLAKE2b-256 7d0796c67d78045b15ac5643b45923a0a3a8cf5acb81c5d9b45fc1b0c5068912

See more details on using hashes here.

Supported by

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