Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ data:
max: # Maximum value (optional)
```

Measurements are stored in the `data` folder next to your script (e.g. `data/data.csv`). With the `csv` and `sqlite` formats, each measurement is appended to the file, so storing it takes the same time however much data is already stored, which keeps succulent fast on limited hardware such as a Raspberry Pi. Measurements that arrive at the same time, also from several server processes (e.g. gunicorn workers), are all stored. A small lock file (e.g. `data/.data.csv.lock`) is used for this; it can be ignored.

To collect images, create a `configuration.yml` file in the root directory and define the following:
```yml
data:
Expand Down
2 changes: 2 additions & 0 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ In the root directory, create a ``configuration.yml`` file and define the follow
min: # Minimum value (optional)
max: # Maximum value (optional)

Measurements are stored in the ``data`` folder next to your script (e.g. ``data/data.csv``). With the ``csv`` and ``sqlite`` formats, each measurement is appended to the file, so storing it takes the same time however much data is already stored, which keeps succulent fast on limited hardware such as a Raspberry Pi. Measurements that arrive at the same time, also from several server processes (e.g. gunicorn workers), are all stored. A small lock file (e.g. ``data/.data.csv.lock``) is used for this; it can be ignored.

To collect images, create a ``configuration.yml`` file in the root directory and define the following:

.. code:: yaml
Expand Down
19 changes: 3 additions & 16 deletions succulent/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import math
import os
import secrets
import sqlite3
from datetime import datetime, timedelta

import numpy as np
Expand Down Expand Up @@ -292,21 +291,9 @@ def load(self):
pandas.DataFrame: The stored data (empty if there is none yet).
"""
path = os.path.join(self.processing.directory, f'data.{self.processing.format}')
if not os.path.exists(path):
return pd.DataFrame()

fmt = self.processing.format
if fmt == 'csv':
return pd.read_csv(path, sep=',')
if fmt == 'json':
return pd.read_json(path, orient='records')
if fmt == 'xml':
return pd.read_xml(path)
conn = sqlite3.connect(path)
try:
return pd.read_sql_query('SELECT * FROM data', conn)
finally:
conn.close()
# Locked, so a measurement being written is never read half-way
with self.processing.storage_lock():
return self.processing.load(path)

def bounds(self):
"""Map each column with a boundary to its minimum and maximum.
Expand Down
Loading
Loading