Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blackhc/laaos
Logs as append-only source.
https://github.com/blackhc/laaos
experiments-results experiments-tracking logger logging-framework logging-library machine-learning ml python pytorch tensorflow
Last synced: 3 months ago
JSON representation
Logs as append-only source.
- Host: GitHub
- URL: https://github.com/blackhc/laaos
- Owner: BlackHC
- License: mit
- Created: 2018-12-10T21:51:55.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-05T23:02:35.000Z (over 3 years ago)
- Last Synced: 2024-10-10T15:16:40.142Z (4 months ago)
- Topics: experiments-results, experiments-tracking, logger, logging-framework, logging-library, machine-learning, ml, python, pytorch, tensorflow
- Language: Python
- Homepage:
- Size: 48.8 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Log as append-only source package
[![Build Status](https://travis-ci.org/BlackHC/laaos.svg?branch=master)](https://travis-ci.org/BlackHC/laaos)
Logs as append-only source: write your ML training results in Python without having to worry about crashes. Loading is a breeze: the logs are native Python code. The package supports unstructured data. The data can easily be imported into Jupyter Notebooks or elsewhere.
## Installation
To install using pip, use:
```
pip install laaos
```To run the tests, use:
```
python setup.py test
```## Append-only source logs
Storing training results as Python dictionaries or JSON files is problematic because the formats are not append-only,
which means that you have to rewrite the file every time something changes. (Or you only write results at the end,
which does not play well with interruptions or intermediate failures.)Alternatively, we can simply write the operations that create a structure to a file in an append-only fashion.
If the data structure itself is growing and not mutated, this only increases file-size by a constant factor.The advantage of this library is that the file format is very simple: it's valid Python code.
The only requirement is that you only store primitive types, lists, sets, dicts and immutable types.
Custom wrappers can be added by registering `TypeHandler`s when creating a `Store`. See `WeakEnumHandler` and `StrEnumHandler`.
## Example
```python
from laaos import open_file_store, safe_loadstore = open_file_store("test", suffix="", truncate=True)
print("Output file: ", store.uri)store['losses'] = []
losses = store["losses"]for i in range(10):
losses.append(1/(i+1))store.close()
```The resulting file `laaos/test.py` contains valid Python code:
```python
store = {}
store['losses']=[]
store['losses'].append(1.0)
store['losses'].append(0.5)
store['losses'].append(0.3333333333333333)
store['losses'].append(0.25)
store['losses'].append(0.2)
store['losses'].append(0.16666666666666666)
store['losses'].append(0.14285714285714285)
store['losses'].append(0.125)
store['losses'].append(0.1111111111111111)
```It can be loaded either with:
```python
form laaos.test import store
```or with the more secure:
```python
safe_load('laaos/test.py')
```### Slightly more sensible example
```python
from laaos import open_file_storeinitial_data = dict(config=dict(dataset="MNIST", learning_rate=1e-4, seed=1337), losses=[])
store = open_file_store("experiment_result", suffix="", initial_data=initial_data)
if store["config"] != initial_data["config"]:
raise ValueError("Experiment mismatch!")print("Output file: ", store.uri)
losses = store["losses"]
for i in range(len(losses), 10):
print("Epoch ", i)
losses.append(1 / (i + 1))if i % 3 == 0:
raise SystemError("Preemption!")store.close()
```