Metadata-Version: 2.1
Name: pyphases
Version: 0.1.0
Summary: A Framework for creating progress based applications, like machine learning algroithms
Home-page: https://gitlab.com/tud.ibmt/pyphases
License: MIT
Author: fehrlich
Author-email: fehrlichd@gmail.com
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Dist: numpy (>=1.18.1,<2.0.0)
Requires-Dist: pandas (>=1.0.1,<2.0.0)
Requires-Dist: pyarrow (>=0.16.0,<0.17.0)
Project-URL: Repository, https://gitlab.com/tud.ibmt/pyphases
Description-Content-Type: text/markdown

# pyPhases

A small framework for python projects that are mainly progress based.

The main princible of the framework are `Phases`.

# Architecure

![arch](assets/achitektur.svg)

## Project

A Project is the composition of phases and the backend.

## Phase
A Phase has a `main` Method and can export data.

## Stage

A stage is a group of Phases and only have a name. A Stage can be run seperatly with `project.run("stagename")`

## Decorators

# Compontents

## Storage and Exporters

### Storage

You can add diffrent storage-engines to your project, with `project.addStorage(Engine())`. A storage you be inherited from `pyPhases.storage.Storage` and implement the methods `read(path: str)` and `write(path: str, data: bytes)`.
The order is important and the Storages should be ordered from fast to slow.

By Default there is a memory storage, that will save the data in the project, but is not persitent. The default persistent data layer is the filesystem(`storage.FileStorage`).

### Exporter

An Exporter can be registered to transform an Instance or primitive type into a `byte` string (`export(obj : MyObject): bytes`) and vice versa (`importData(bytes): MyObject`).

There is a default `ObjectExporter`, that is based on [pyarror](https://pypi.org/project/pyarrow/) and is compatible with diffrent fromats like pandas Dataframes and numpy arrays.

### register Data
When a phase wants to register data (`self.project.registerData("myDataId", myData)` within the phase), the data is passed to an exporter. If an exporter is found the data will be passed to alle the storages. They will save the data somewhere (persitent or not).

example:

![seq](assets/seq-save-data.svg)

### reading the data
A phase can request data with `self.project.getData("myDataId", MyDataType)`. The Data will be passed sequential to the storage layer and will pass the data from the first storage that is able to get it. If no storage can provide the data, the project will search for a phase that exports this data-id and run that specific phase.

example:

![get-data](assets/seq-get-data.svg)


### example

This is a example data layer with 3 storages: memory, file, database (`not default`)
![data-layer](assets/data-layer.svg)

