Skip to main content

aitana-storage

Store time series feature data as NetCDF or Zarr archives, organised in a directory hierarchy, and access them through a FastAPI service.

Installation

pip install aitana-storage

to_pytorch() requires PyTorch, which is an optional dependency:

pip install aitana-storage[pytorch]

Usage

Saving and querying features

Storage organises features in a directory tree (e.g. site/sensor/channel) and stores each feature as a NetCDF or Zarr archive on disk.

from datetime import datetime
from aitana.storage import Storage, generate_test_data

g = Storage('Whakaari', '/tmp', backend='zarr')
c = g.get_substore('WIZ', '00', 'HHZ')
c.save(generate_test_data(dim=1))

g.starttime = datetime(2012, 1, 1)
g.endtime = datetime(2012, 1, 2, 23, 59, 59)
rsam = c('rsam')  # -> xarray.DataArray indexed by datetime

PyTorch dataset

from torch.utils.data import DataLoader

dataset = c.to_pytorch(['rsam', 'dsar'])
dataloader = DataLoader(dataset, batch_size=32, shuffle=True)

to_pytorch(..., lazy=True) reads from disk per batch instead of loading everything up front; iterate it with SliceBatchSampler so each batch is one contiguous read:

from aitana.storage.storage import SliceBatchSampler

dataset = c.to_pytorch(['rsam', 'dsar'], window_size=36, lazy=True)
sampler = SliceBatchSampler(range(len(dataset)), 64)
dataloader = DataLoader(dataset, batch_sampler=sampler)

FastAPI service

aitana.storage.api.StorageAPI exposes /feature and /inventory endpoints over HTTP. aitana-api runs it.

aitana-api --rootdir /data --port 8003

Labelling in Grafana

To label what a detector flagged, draw on any dashboard: Ctrl/Cmd + click on a time series panel marks a point, Ctrl/Cmd + click and drag marks a span. Tag it:

  • label:<class> makes the annotation a label, e.g. label:noise, label:instrument, label:tremor. Annotations without one are ignored.
  • volcano:<name>, e.g. volcano:ruapehu. Labels belong to a volcano, not to the dashboard they were drawn on.
  • series:<site>.<loc>.<cha>.<feature>, only for a label about particular series rather than the whole volcano, e.g. an instrument fault: series:FWVZ.10.HHZ.rsam. Add one per series. The address matches the storage tree (ruapehu/FWVZ/10/HHZ/rsam). Scope by tag rather than by panel, because panel ids change when a dashboard is rebuilt.

To show a volcano's labels on a dashboard, whichever dashboard they were drawn on, set its built-in Annotations & Alerts query to Filter by: Tags with volcano:ruapehu (or volcano:$volcano on a templated dashboard). Change the built-in query rather than adding a second one, or labels drawn on that dashboard show twice. Check once that Ctrl/Cmd + click still adds annotations with that setting.

Then sync all labels, from every dashboard and volcano, with one label file. Run it on a schedule and after every Grafana deploy:

export GRAFANA_USER=… GRAFANA_PASSWORD=…   # a user allowed to read, create and edit annotations
grafana_annotations http://<grafana-host>:<port> --file /data/labels.json

The credentials are sent as HTTP Basic authentication. Without GRAFANA_USER and GRAFANA_PASSWORD, they can go in the URL instead (http://<user>:<password>@<grafana-host>:<port>). On the default branch, .gitlab-ci.yml deploys the sync as the aitana-label-sync container, which runs it every 10 minutes.

The file is a JSON list ordered by time. Each label has time and timeEnd (ms since epoch; timeEnd is null for a point), title, description, tags, a stable id, and where it was made (user, dashboardUID, panelId).

Labels are human judgements only. What a detector decides is stored as series next to its index, e.g. rsam_mp_alarm and rsam_mp_threshold, not as labels.

  • Each label gets a stable id, kept as an Id: <id> line at the end of the annotation text; the sync appends it to new annotations. Leave that line in place when editing.
  • The sync is a union. Edits to text, tags and times in Grafana win, and new labels are added to the file.
  • Stored labels missing from Grafana are posted back as organization annotations (tied to no dashboard), so a freshly deployed Grafana gets every label back on the first sync. They show on every dashboard whose annotation query filters on the volcano tag.
  • Deleting an annotation in Grafana therefore doesn't stick. To withdraw a label, retag it (e.g. label:retracted) and filter it out downstream.
  • Keep annotation retention off (max_age and max_annotations_to_keep under [annotations.dashboard] and [annotations.api]), or the sync re-posts every aged-out label.
  • Keep a label: tag on every label. An annotation that loses it no longer counts, and the sync posts the stored copy back.
  • Labels with no volcano: tag are stored, and listed after the sync, because no volcano dashboard shows them.

The command prints how often each tag occurs, which shows typos such as label:eruptoin.

License

See the repository root for license information.

Metadata

Release files for aitana-storage 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aitana-storage 0.1.4
File Size Uploaded Provenance Actions
aitana_storage-0.1.4.tar.gz 44.3 kB Without provenance Details for aitana_storage-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aitana-storage 0.1.4
File Interpreter ABI Platform Actions
aitana_storage-0.1.4-py3-none-any.whl Python 3 none any Details for aitana_storage-0.1.4-py3-none-any.whl

Total release size: 77.9 kB

Release files / aitana_storage-0.1.4.tar.gz

Download URL aitana_storage-0.1.4.tar.gz
Size 44.3 kB
Tags Source
SHA-256 checksum
How to use checksums
496a12e5170e41d565d557e185320bb2e3ee2df92629bf8a16715a820c107b02
BLAKE2b-256 checksum
How to use checksums
65344102b7d527c8f9cba4ca91a7b5ea7dbf1d6a40fc326081d65b5352d18b41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / aitana_storage-0.1.4-py3-none-any.whl

Download URL aitana_storage-0.1.4-py3-none-any.whl
Size 33.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
257a06cb1479d33b5c7f6034bd970d0946841d71856355659ca179d6b287c26f
BLAKE2b-256 checksum
How to use checksums
c42974e2a752214d6e7c63ee71e6b68b1318e6e80c0d09b6db50ab6447d0828b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Security for aitana-storage 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page