tinyflux 0.4.0__tar.gz → 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tinyflux might be problematic. Click here for more details.

Files changed (31) hide show
  1. tinyflux-0.4.2/MANIFEST.in +2 -0
  2. {tinyflux-0.4.0/tinyflux.egg-info → tinyflux-0.4.2}/PKG-INFO +12 -38
  3. {tinyflux-0.4.0 → tinyflux-0.4.2}/README.rst +10 -37
  4. {tinyflux-0.4.0 → tinyflux-0.4.2}/setup.cfg +2 -1
  5. {tinyflux-0.4.0 → tinyflux-0.4.2}/tests/conftest.py +1 -0
  6. {tinyflux-0.4.0 → tinyflux-0.4.2}/tests/test_index.py +3 -2
  7. {tinyflux-0.4.0 → tinyflux-0.4.2}/tests/test_measurement.py +3 -2
  8. {tinyflux-0.4.0 → tinyflux-0.4.2}/tests/test_point.py +2 -1
  9. {tinyflux-0.4.0 → tinyflux-0.4.2}/tests/test_queries.py +5 -4
  10. {tinyflux-0.4.0 → tinyflux-0.4.2}/tests/test_storages.py +7 -6
  11. {tinyflux-0.4.0 → tinyflux-0.4.2}/tests/test_tinyflux.py +2 -1
  12. {tinyflux-0.4.0 → tinyflux-0.4.2}/tests/test_utils.py +2 -1
  13. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux/__init__.py +1 -0
  14. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux/database.py +7 -6
  15. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux/index.py +9 -8
  16. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux/measurement.py +3 -2
  17. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux/point.py +2 -2
  18. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux/queries.py +10 -9
  19. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux/storages.py +4 -3
  20. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux/utils.py +2 -1
  21. tinyflux-0.4.2/tinyflux/version.py +3 -0
  22. {tinyflux-0.4.0 → tinyflux-0.4.2/tinyflux.egg-info}/PKG-INFO +12 -38
  23. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux.egg-info/SOURCES.txt +1 -1
  24. tinyflux-0.4.0/MANIFEST.in +0 -3
  25. tinyflux-0.4.0/version.txt +0 -1
  26. {tinyflux-0.4.0 → tinyflux-0.4.2}/LICENSE +0 -0
  27. {tinyflux-0.4.0 → tinyflux-0.4.2}/pyproject.toml +0 -0
  28. {tinyflux-0.4.0 → tinyflux-0.4.2}/tests/__init__.py +0 -0
  29. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux/py.typed +0 -0
  30. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux.egg-info/dependency_links.txt +0 -0
  31. {tinyflux-0.4.0 → tinyflux-0.4.2}/tinyflux.egg-info/top_level.txt +0 -0
@@ -0,0 +1,2 @@
1
+ include LICENSE
2
+ recursive-include tests *.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinyflux
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: The Tiny Time-Series Database Optimized for Your Happiness
5
5
  Home-page: https://github.com/citrusvanilla/tinyflux
6
6
  Author: Justin Fung
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3.8
22
22
  Classifier: Programming Language :: Python :: 3.9
23
23
  Classifier: Programming Language :: Python :: 3.10
24
24
  Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
25
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
26
27
  Classifier: Programming Language :: Python :: Implementation :: PyPy
27
28
  Classifier: Operating System :: OS Independent
@@ -36,8 +37,13 @@ License-File: LICENSE
36
37
  .. image:: https://github.com/citrusvanilla/tinyflux/blob/master/artwork/tinyfluxdb-dark.png?raw=true#gh-light-mode-only
37
38
  :width: 500px
38
39
 
40
+ TinyFlux is the tiny time series database optimized for your happiness :)
41
+
42
+ TinyFlux is a time series version of `TinyDB <https://tinydb.readthedocs.io/en/latest/index.html>`__ that is also written in Python and has no external dependencies. It's a great companion for small analytics workflows and apps, as well as at-home IOT data stores. TinyFlux has 100% test coverage, over 50,000 downloads, and no open issues.
43
+
39
44
  |Build Status| |Coverage| |Version| |Downloads|
40
45
 
46
+
41
47
  Quick Links
42
48
  ***********
43
49
 
@@ -48,49 +54,19 @@ Quick Links
48
54
  - `Contributing`_
49
55
 
50
56
 
51
- Recent Updates
52
- **************
53
-
54
- v0.4.0 - March 27, 2023
55
- =======================
56
-
57
- * Tags and Fields can be removed from individual points. See `the documentation <https://tinyflux.readthedocs.io/en/latest/updating-data.html#removing-tags-and-fields-with-update>`__ for more (resolves issue #27).
58
-
59
- v0.3.1 - March 27, 2023
60
- =======================
61
-
62
- * Fixed bug that allowed user to delete key/field tags with `.update()` and `.update_all()` (resolves issue #36).
63
-
64
- v0.3.0 - March 23, 2023
65
- =======================
66
-
67
- * Tag and field keys can be compacted when using CSVStorage, saving potentially many bytes per Point (resolves issue #32).
68
- * Fixed bug that causes tag values of `""` to be serialized as `"_none"` (resolves issue #33).
69
-
70
- See the `Changelog <https://tinyflux.readthedocs.io/en/latest/changelog.html>`__ for more.
71
-
72
-
73
57
  Installation
74
58
  ************
75
59
 
76
- .. code-block:: bash
77
-
78
- $ pip install tinyflux
79
-
80
- Or, download this repository, ``cd`` into it, and:
60
+ TinyFlux is hosted at `PyPI <https://pypi.org/project/tinyflux/>`__ and is easily downloadable with ``pip``. TinyFlux has been tested with Python 3.7 - 3.12 and PyPy-3.9 on Linux and Windows platforms.
81
61
 
82
62
  .. code-block:: bash
83
63
 
84
- $ pip install .
64
+ $ pip install tinyflux
85
65
 
86
66
 
87
67
  Introduction
88
68
  ************
89
69
 
90
- TinyFlux is the tiny time series database optimized for your happiness :)
91
-
92
- TinyFlux is a time series version of `TinyDB <https://tinydb.readthedocs.io/en/latest/index.html>`__ that is also written in Python and has no external dependencies. It's a great companion for small analytics workflows and apps, as well as at-home IOT data stores.
93
-
94
70
  TinyFlux is:
95
71
 
96
72
  - **time-centric:** Python datetime objects are first-class citizens and queries are optimized for time, above all else.
@@ -109,10 +85,6 @@ TinyFlux is:
109
85
 
110
86
  To get started, head over to the `TinyFlux docs <https://tinyflux.readthedocs.io/>`__. Examples can be found in the `examples directory <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`__. You can also discuss topics related to TinyFlux including general development, extensions, or showcase your TinyFlux-based projects on the `GitHub discussion forum <https://github.com/citrusvanilla/tinyflux/discussions>`__.
111
87
 
112
- Supported Python Versions
113
- *************************
114
-
115
- TinyFlux has been tested with Python 3.7 - 3.11 and PyPy-3.9 on Linux and Windows platforms.
116
88
 
117
89
  Example Code Snippets
118
90
  *********************
@@ -168,6 +140,7 @@ The `examples <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`_
168
140
  1. `Loading a TinyFlux DB from a CSV <https://github.com/citrusvanilla/tinyflux/blob/master/examples/1_initializing_and_loading_new_db.ipynb>`__
169
141
  2. `Local Analytics Workflow with a TinyFlux Database <https://github.com/citrusvanilla/tinyflux/blob/master/examples/2_analytics_workflow.ipynb>`__
170
142
  3. `TinyFlux as a MQTT Datastore for IoT Devices <https://github.com/citrusvanilla/tinyflux/blob/master/examples/3_iot_datastore_with_mqtt.py>`__
143
+ 4. `TinyFlux at the Edge (with Backup Strategy) <https://github.com/citrusvanilla/tinyflux/blob/master/examples/4_backing_up_tinyflux_at_the_edge.py>`__
171
144
 
172
145
  Tips
173
146
  ****
@@ -196,8 +169,9 @@ New ideas, new developer tools, improvements, and bugfixes are always welcome.
196
169
  5. Send a pull request.
197
170
 
198
171
  .. |Build Status| image:: https://github.com/citrusvanilla/tinyflux/actions/workflows/build.yml/badge.svg
172
+ :target: https://github.com/citrusvanilla/tinyflux/actions
199
173
  .. |Coverage| image:: https://codecov.io/gh/citrusvanilla/tinyflux/branch/master/graph/badge.svg?token=IEGQ4E57VA
200
- :target: https://app.codecov.io/gh/citrusvanilla
174
+ :target: https://app.codecov.io/gh/citrusvanilla/tinyflux
201
175
  .. |Version| image:: http://img.shields.io/pypi/v/tinyflux.svg
202
176
  :target: https://pypi.python.org/pypi/tinyflux/
203
177
  .. |Downloads| image:: https://img.shields.io/pypi/dm/tinyflux.svg
@@ -4,8 +4,13 @@
4
4
  .. image:: https://github.com/citrusvanilla/tinyflux/blob/master/artwork/tinyfluxdb-dark.png?raw=true#gh-light-mode-only
5
5
  :width: 500px
6
6
 
7
+ TinyFlux is the tiny time series database optimized for your happiness :)
8
+
9
+ TinyFlux is a time series version of `TinyDB <https://tinydb.readthedocs.io/en/latest/index.html>`__ that is also written in Python and has no external dependencies. It's a great companion for small analytics workflows and apps, as well as at-home IOT data stores. TinyFlux has 100% test coverage, over 50,000 downloads, and no open issues.
10
+
7
11
  |Build Status| |Coverage| |Version| |Downloads|
8
12
 
13
+
9
14
  Quick Links
10
15
  ***********
11
16
 
@@ -16,49 +21,19 @@ Quick Links
16
21
  - `Contributing`_
17
22
 
18
23
 
19
- Recent Updates
20
- **************
21
-
22
- v0.4.0 - March 27, 2023
23
- =======================
24
-
25
- * Tags and Fields can be removed from individual points. See `the documentation <https://tinyflux.readthedocs.io/en/latest/updating-data.html#removing-tags-and-fields-with-update>`__ for more (resolves issue #27).
26
-
27
- v0.3.1 - March 27, 2023
28
- =======================
29
-
30
- * Fixed bug that allowed user to delete key/field tags with `.update()` and `.update_all()` (resolves issue #36).
31
-
32
- v0.3.0 - March 23, 2023
33
- =======================
34
-
35
- * Tag and field keys can be compacted when using CSVStorage, saving potentially many bytes per Point (resolves issue #32).
36
- * Fixed bug that causes tag values of `""` to be serialized as `"_none"` (resolves issue #33).
37
-
38
- See the `Changelog <https://tinyflux.readthedocs.io/en/latest/changelog.html>`__ for more.
39
-
40
-
41
24
  Installation
42
25
  ************
43
26
 
44
- .. code-block:: bash
45
-
46
- $ pip install tinyflux
47
-
48
- Or, download this repository, ``cd`` into it, and:
27
+ TinyFlux is hosted at `PyPI <https://pypi.org/project/tinyflux/>`__ and is easily downloadable with ``pip``. TinyFlux has been tested with Python 3.7 - 3.12 and PyPy-3.9 on Linux and Windows platforms.
49
28
 
50
29
  .. code-block:: bash
51
30
 
52
- $ pip install .
31
+ $ pip install tinyflux
53
32
 
54
33
 
55
34
  Introduction
56
35
  ************
57
36
 
58
- TinyFlux is the tiny time series database optimized for your happiness :)
59
-
60
- TinyFlux is a time series version of `TinyDB <https://tinydb.readthedocs.io/en/latest/index.html>`__ that is also written in Python and has no external dependencies. It's a great companion for small analytics workflows and apps, as well as at-home IOT data stores.
61
-
62
37
  TinyFlux is:
63
38
 
64
39
  - **time-centric:** Python datetime objects are first-class citizens and queries are optimized for time, above all else.
@@ -77,10 +52,6 @@ TinyFlux is:
77
52
 
78
53
  To get started, head over to the `TinyFlux docs <https://tinyflux.readthedocs.io/>`__. Examples can be found in the `examples directory <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`__. You can also discuss topics related to TinyFlux including general development, extensions, or showcase your TinyFlux-based projects on the `GitHub discussion forum <https://github.com/citrusvanilla/tinyflux/discussions>`__.
79
54
 
80
- Supported Python Versions
81
- *************************
82
-
83
- TinyFlux has been tested with Python 3.7 - 3.11 and PyPy-3.9 on Linux and Windows platforms.
84
55
 
85
56
  Example Code Snippets
86
57
  *********************
@@ -136,6 +107,7 @@ The `examples <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`_
136
107
  1. `Loading a TinyFlux DB from a CSV <https://github.com/citrusvanilla/tinyflux/blob/master/examples/1_initializing_and_loading_new_db.ipynb>`__
137
108
  2. `Local Analytics Workflow with a TinyFlux Database <https://github.com/citrusvanilla/tinyflux/blob/master/examples/2_analytics_workflow.ipynb>`__
138
109
  3. `TinyFlux as a MQTT Datastore for IoT Devices <https://github.com/citrusvanilla/tinyflux/blob/master/examples/3_iot_datastore_with_mqtt.py>`__
110
+ 4. `TinyFlux at the Edge (with Backup Strategy) <https://github.com/citrusvanilla/tinyflux/blob/master/examples/4_backing_up_tinyflux_at_the_edge.py>`__
139
111
 
140
112
  Tips
141
113
  ****
@@ -164,8 +136,9 @@ New ideas, new developer tools, improvements, and bugfixes are always welcome.
164
136
  5. Send a pull request.
165
137
 
166
138
  .. |Build Status| image:: https://github.com/citrusvanilla/tinyflux/actions/workflows/build.yml/badge.svg
139
+ :target: https://github.com/citrusvanilla/tinyflux/actions
167
140
  .. |Coverage| image:: https://codecov.io/gh/citrusvanilla/tinyflux/branch/master/graph/badge.svg?token=IEGQ4E57VA
168
- :target: https://app.codecov.io/gh/citrusvanilla
141
+ :target: https://app.codecov.io/gh/citrusvanilla/tinyflux
169
142
  .. |Version| image:: http://img.shields.io/pypi/v/tinyflux.svg
170
143
  :target: https://pypi.python.org/pypi/tinyflux/
171
144
  .. |Downloads| image:: https://img.shields.io/pypi/dm/tinyflux.svg
@@ -8,7 +8,7 @@ extend-ignore = E203
8
8
 
9
9
  [metadata]
10
10
  name = tinyflux
11
- version = file: version.txt
11
+ version = attr: tinyflux.version.__version__
12
12
  author = Justin Fung
13
13
  author_email = justincaseyfung@gmail.com
14
14
  description = The Tiny Time-Series Database Optimized for Your Happiness
@@ -34,6 +34,7 @@ classifiers =
34
34
  Programming Language :: Python :: 3.9
35
35
  Programming Language :: Python :: 3.10
36
36
  Programming Language :: Python :: 3.11
37
+ Programming Language :: Python :: 3.12
37
38
  Programming Language :: Python :: Implementation :: CPython
38
39
  Programming Language :: Python :: Implementation :: PyPy
39
40
  Operating System :: OS Independent
@@ -1,4 +1,5 @@
1
1
  """PyTest configuration and test fixtures."""
2
+
2
3
  import pytest
3
4
 
4
5
  from tinyflux.storages import CSVStorage, MemoryStorage
@@ -1,4 +1,5 @@
1
1
  """Tests for tinyflux.index module."""
2
+
2
3
  from datetime import datetime, timezone, timedelta
3
4
  import pytest
4
5
 
@@ -118,7 +119,7 @@ def test_insert_time_method():
118
119
  assert index._timestamps == [t1.timestamp(), t2.timestamp()]
119
120
 
120
121
 
121
- def test_index_measuments_method():
122
+ def test_index_measurements_method():
122
123
  """Test _insert_measurements helper of Index."""
123
124
  index = Index()
124
125
 
@@ -381,7 +382,7 @@ def test_search_compound_query_not():
381
382
  rst = index.search(~fiel_q)
382
383
  assert rst.items == {0, 1}
383
384
 
384
- # Compount NOT FieldQuery.
385
+ # Compound NOT FieldQuery.
385
386
  rst = index.search(~fiel_q & tags_q)
386
387
  assert rst.items == {0}
387
388
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  Tests are generally organized by Measurement class method.
4
4
  """
5
+
5
6
  from datetime import datetime, timezone, timedelta
6
7
  import re
7
8
  from typing import Generator
@@ -43,7 +44,7 @@ def test_iter():
43
44
 
44
45
 
45
46
  def test_len():
46
- """Test __len__ of Measuremnt."""
47
+ """Test __len__ of Measurement."""
47
48
  db = TinyFlux(storage=MemoryStorage)
48
49
  m = db.measurement("a")
49
50
  assert len(m) == 0
@@ -468,7 +469,7 @@ def test_insert():
468
469
  assert len(m1) == 1
469
470
  assert len(m2) == 0
470
471
 
471
- # Insert in-order, into a different measurment.
472
+ # Insert in-order, into a different measurement.
472
473
  assert m2.insert(p2) == 1
473
474
  assert db.index.valid and not db.index.empty
474
475
  assert len(db.index) == 2
@@ -1,4 +1,5 @@
1
1
  """Tests for the tinyflux.point module."""
2
+
2
3
  from datetime import datetime, timezone, timedelta
3
4
  import pytest
4
5
  from tinyflux.point import Point, validate_tags, validate_fields
@@ -284,7 +285,7 @@ def test_points_are_equal():
284
285
 
285
286
 
286
287
  def test_serialize_point():
287
- """Test serializaiton of a Point object."""
288
+ """Test serialization of a Point object."""
288
289
  time_now = datetime.now(timezone.utc)
289
290
  time_now_str = time_now.replace(tzinfo=None).isoformat()
290
291
 
@@ -1,4 +1,5 @@
1
1
  """Tests for the tinyflux.queries module."""
2
+
2
3
  import operator
3
4
  from datetime import datetime, timezone, timedelta
4
5
  from itertools import combinations
@@ -75,7 +76,7 @@ def test_repr():
75
76
 
76
77
 
77
78
  def test_no_path():
78
- """Test absense of path for Tag and Field queries.
79
+ """Test absence of path for Tag and Field queries.
79
80
 
80
81
  TagQuery and FieldQuery should have paths.
81
82
  """
@@ -226,7 +227,7 @@ def test_lt():
226
227
  # Test for tag key "city".
227
228
  taq_q = TagQuery().city < "melbourne"
228
229
  assert taq_q(Point(tags={"city": "amsterdam"}))
229
- assert not taq_q(Point(tags={"city": "zansibar"}))
230
+ assert not taq_q(Point(tags={"city": "zanzibar"}))
230
231
  assert not taq_q(Point())
231
232
  assert hash(taq_q)
232
233
 
@@ -258,7 +259,7 @@ def test_le():
258
259
  # Test for tag key "city".
259
260
  taq_q = TagQuery().city <= "melbourne"
260
261
  assert taq_q(Point(tags={"city": "melbourne"}))
261
- assert not taq_q(Point(tags={"city": "zansibar"}))
262
+ assert not taq_q(Point(tags={"city": "zanzibar"}))
262
263
  assert not taq_q(Point())
263
264
  assert hash(taq_q)
264
265
 
@@ -289,7 +290,7 @@ def test_gt():
289
290
  """Test simple greater than comparison."""
290
291
  # Test for tag key "city".
291
292
  taq_q = TagQuery().city > "melbourne"
292
- assert taq_q(Point(tags={"city": "zansibar"}))
293
+ assert taq_q(Point(tags={"city": "zanzibar"}))
293
294
  assert not taq_q(Point(tags={"city": "amsterdam"}))
294
295
  assert not taq_q(Point())
295
296
  assert hash(taq_q)
@@ -1,4 +1,5 @@
1
1
  """Tests for the tinyflux.storages module."""
2
+
2
3
  import csv
3
4
  from datetime import datetime, timezone, timedelta
4
5
  import os
@@ -102,7 +103,7 @@ def test_csv_write_read(tmpdir):
102
103
 
103
104
 
104
105
  def test_csv_kwargs(tmpdir):
105
- """Test kwargs propogation."""
106
+ """Test kwargs propagation."""
106
107
  dbfile = os.path.join(tmpdir, "test.csv")
107
108
 
108
109
  # Pass the 'delimiter' kwarg from csv module.
@@ -133,9 +134,9 @@ def test_create_dirs():
133
134
  temp_dir = tempfile.gettempdir()
134
135
 
135
136
  while True:
136
- dname = os.path.join(temp_dir, str(random.getrandbits(20)))
137
- if not os.path.exists(dname):
138
- dbdir = dname
137
+ dbname = os.path.join(temp_dir, str(random.getrandbits(20)))
138
+ if not os.path.exists(dbname):
139
+ dbdir = dbname
139
140
  dbfile = os.path.join(dbdir, "db.json")
140
141
  break
141
142
 
@@ -363,7 +364,7 @@ def test_connect_to_existing_csv(tmpdir, csv_storage_with_counters):
363
364
  storage.append([storage._serialize_point(p3)])
364
365
  assert storage.reindex_count == 0
365
366
 
366
- # Read without reindexing.
367
+ # Read without re-indexing.
367
368
  assert storage.read() == [p2, p1, p3]
368
369
  assert storage.reindex_count == 0
369
370
  assert storage.write_count == 0
@@ -441,7 +442,7 @@ def test_reindex_on_read_memory(mem_storage_with_counters):
441
442
  assert storage.reindex_count == 0
442
443
  assert storage.write_count == 0
443
444
 
444
- # Read contents with reindexing.
445
+ # Read contents with re-indexing.
445
446
  storage.read()
446
447
  assert storage.append_count == 3
447
448
  assert storage.reindex_count == 0
@@ -2,6 +2,7 @@
2
2
 
3
3
  Tests are generally organized by TinyFlux class method.
4
4
  """
5
+
5
6
  import csv
6
7
  from datetime import datetime, timezone, timedelta
7
8
  import os
@@ -625,7 +626,7 @@ def test_measurement():
625
626
  assert not db._measurements
626
627
  assert not db.get_measurements()
627
628
 
628
- # Create a reference to a measurment that does not exist.
629
+ # Create a reference to a measurement that does not exist.
629
630
  m = db.measurement("a")
630
631
  assert "a" in db._measurements
631
632
  assert not len(m)
@@ -1,4 +1,5 @@
1
1
  """Tests for tinyflux.utils module."""
2
+
2
3
  import pytest
3
4
 
4
5
  from tinyflux.utils import (
@@ -35,7 +36,7 @@ def test_freeze():
35
36
 
36
37
 
37
38
  def test_frozen_dict_hash():
38
- """Tesh the hash function on FrozenDict class."""
39
+ """Test the hash function on FrozenDict class."""
39
40
  my_frozen_set1 = FrozenDict({"city": "la", "state": "ca"})
40
41
  my_frozen_set2 = FrozenDict({"state": "ca", "city": "la"})
41
42
  my_frozen_set3 = FrozenDict({"temp": 70})
@@ -27,6 +27,7 @@ Usage:
27
27
  >>> q2 = FieldQuery().aqi > 100
28
28
  >>> hazardous_days_in_LA_2020 = db.search(q1 & q2)
29
29
  """
30
+
30
31
  from .database import TinyFlux
31
32
  from .point import Point
32
33
  from .queries import TagQuery, FieldQuery, MeasurementQuery, TimeQuery
@@ -1,4 +1,5 @@
1
1
  """The main module of the TinyFlux package, containing the TinyFlux class."""
2
+
2
3
  import copy
3
4
  from datetime import datetime, timezone
4
5
  from functools import wraps
@@ -164,7 +165,7 @@ class TinyFlux:
164
165
  'auto-index' to False.
165
166
 
166
167
  Args:
167
- auto_index: Reindexing of data will be performed automatically.
168
+ auto_index: Re-indexing of data will be performed automatically.
168
169
  storage: Class of Storage instance.
169
170
  """
170
171
  self._auto_index = auto_index
@@ -213,7 +214,7 @@ class TinyFlux:
213
214
  return
214
215
 
215
216
  def __iter__(self) -> Iterator[Point]:
216
- """Return an iterater for all Points in the storage layer."""
217
+ """Return an iterator for all Points in the storage layer."""
217
218
  for item in self._storage:
218
219
  yield self._storage._deserialize_storage_item(item)
219
220
 
@@ -687,7 +688,7 @@ class TinyFlux:
687
688
  1 if success.
688
689
 
689
690
  Raises:
690
- OSError if storage cannot be appendex to.
691
+ OSError if storage cannot be appended to.
691
692
  TypeError if point is not a Point instance.
692
693
  """
693
694
  return self._insert_helper([point], measurement, compact_key_prefixes)
@@ -710,7 +711,7 @@ class TinyFlux:
710
711
  The count of inserted points.
711
712
 
712
713
  Raises:
713
- OSError if storage cannot be appendex to.
714
+ OSError if storage cannot be appended to.
714
715
  TypeError if point is not a Point instance.
715
716
  """
716
717
  return self._insert_helper(points, measurement, compact_key_prefixes)
@@ -896,7 +897,7 @@ class TinyFlux:
896
897
  ) -> List[Union[Any, Tuple[Any, ...]]]:
897
898
  """Get specified attributes from Points specified by a query.
898
899
 
899
- 'select_keys' should be an iterable of attributres including 'time',
900
+ 'select_keys' should be an iterable of attributes including 'time',
900
901
  'measurement', and tag keys and tag values. Passing 'tags' or 'fields'
901
902
  in the 'select_keys' iterable will not retrieve all tag and/or field
902
903
  values. Tag and field keys must be specified individually.
@@ -1330,7 +1331,7 @@ class TinyFlux:
1330
1331
  if self._auto_index and self._index.valid:
1331
1332
  if (
1332
1333
  not self._index.empty
1333
- and point.time < self._index.lateset_time
1334
+ and point.time < self._index.latest_time
1334
1335
  ):
1335
1336
  self._index.invalidate()
1336
1337
  else:
@@ -1,13 +1,14 @@
1
- """Defintion of the TinyFlux Index.
1
+ """Definition of the TinyFlux Index.
2
2
 
3
3
  Class descriptions for Index and IndexResult. An Index acts like a singleton,
4
4
  and is initialized at creation time with the TinyFlux instance. It provides
5
5
  efficient in-memory data structures and getters for TinyFlux operations. An
6
6
  Index instance is not a part of the TinyFlux interface.
7
7
 
8
- An IndexResult returns the indicies of revelant TinyFlux queries for further
8
+ An IndexResult returns the indices of relevant TinyFlux queries for further
9
9
  handling, usually as an input to a storage retrieval.
10
10
  """
11
+
11
12
  from datetime import datetime, timezone
12
13
  import operator
13
14
  from typing import Dict, Iterable, List, Optional, Set, Tuple, Union
@@ -18,12 +19,12 @@ from .utils import find_eq, find_lt, find_le, find_gt, find_ge
18
19
 
19
20
 
20
21
  class IndexResult:
21
- """Returns indicies of TinyFlux queries that are handled by an Index.
22
+ """Returns indices of TinyFlux queries that are handled by an Index.
22
23
 
23
24
  IndexResults instances are generated by an Index.
24
25
 
25
- Arritributes:
26
- items: A set of indicies as ints.
26
+ Attributes:
27
+ items: A set of indices as ints.
27
28
 
28
29
  Usage:
29
30
  >>> IndexResult(items=set(), index_count=0)
@@ -36,7 +37,7 @@ class IndexResult:
36
37
  """Init IndexResult.
37
38
 
38
39
  Args:
39
- items: Matching items from a query as indicies.
40
+ items: Matching items from a query as indices.
40
41
  index_count: Number of items in the index..
41
42
  """
42
43
  self._items = items
@@ -148,8 +149,8 @@ class Index:
148
149
  return self._valid
149
150
 
150
151
  @property
151
- def lateset_time(self) -> datetime:
152
- """Return the lastest time in the index."""
152
+ def latest_time(self) -> datetime:
153
+ """Return the latest time in the index."""
153
154
  return datetime.fromtimestamp(self._timestamps[-1]).astimezone(
154
155
  timezone.utc
155
156
  )
@@ -1,4 +1,4 @@
1
- """Defintion of TinyFlux measurement class.
1
+ """Definition of TinyFlux measurement class.
2
2
 
3
3
  The measurement class provides a convenient interface into a subset of
4
4
  data points with a common measurement name. A measurement is analogous to a
@@ -8,6 +8,7 @@ Usage:
8
8
  >>> db = TinyFlux(storage=MemoryStorage)
9
9
  >>> m = db.measurement("my_measurement")
10
10
  """
11
+
11
12
  from __future__ import annotations
12
13
 
13
14
  from datetime import datetime
@@ -298,7 +299,7 @@ class Measurement:
298
299
  ) -> List[Tuple[Union[datetime, str, int, float, None]]]:
299
300
  """Get specified attributes from Points specified by a query.
300
301
 
301
- 'keys' should be an iterable of attributres including 'time',
302
+ 'keys' should be an iterable of attributes including 'time',
302
303
  'measurement', and tag keys and tag values. Passing 'tags' or 'fields'
303
304
  in the 'keys' iterable will not retrieve all tag and/or field values.
304
305
  Tag and field keys must be specified individually.
@@ -1,8 +1,8 @@
1
- """Defintion of the TinyFlux Point class.
1
+ """Definition of the TinyFlux Point class.
2
2
 
3
3
  A Point is the data type upon which TinyFlux manages. It contains the time
4
4
  data and metadata for an individual observation. Points are serialized and
5
- deserialized from Storage. SimpleQuerys act upon individual Points.
5
+ deserialized from Storage. SimpleQuery act upon individual Points.
6
6
 
7
7
  A Point is comprised of a timestamp, a measurement, fields, and tags.
8
8
 
@@ -1,4 +1,4 @@
1
- """Defintion of TinyFlux Queries.
1
+ """Definition of TinyFlux Queries.
2
2
 
3
3
  A query contains logic in the form of a test and it acts upon a single Point
4
4
  when it is eventually evaluated.
@@ -10,10 +10,11 @@ instances support logical AND, OR, and NOT operations, which result in the
10
10
  initialization of a new CompoundQuery object.
11
11
 
12
12
  Each SimpleQuery instance contains attributes that constitute the
13
- "deconstuction" of a query into several key parts (e.g. the operator, the
14
- right-hand side) so that the other consumers of queries, includng an Index, may
13
+ "deconstruction" of a query into several key parts (e.g. the operator, the
14
+ right-hand side) so that the other consumers of queries, including an Index, may
15
15
  use them for their own purposes.
16
16
  """
17
+
17
18
  from datetime import datetime
18
19
  import operator
19
20
  import re
@@ -214,7 +215,7 @@ class SimpleQuery:
214
215
  operator: The operator portion of a test.
215
216
  rhs: The value that a test should evaluated against.
216
217
  test: The combined logic as a callable.
217
- path_resolver: A fetcher/translater for Point metadata that the
218
+ path_resolver: A fetcher/translator for Point metadata that the
218
219
  query will be evaluated on.
219
220
  hashval: The hash value for the query.
220
221
  """
@@ -323,10 +324,10 @@ class SimpleQuery:
323
324
  class BaseQuery:
324
325
  """A base class for the different TinyFlux query types.
325
326
 
326
- A query type that explicity unifies the divergent interfaces of TimeQuery,
327
+ A query type that explicitly unifies the divergent interfaces of TimeQuery,
327
328
  MeasurementQuery, TagQuery, and FieldQuery.
328
329
 
329
- A BaseQuery is not iteslf callable. When it is combined with test logic,
330
+ A BaseQuery is not itself callable. When it is combined with test logic,
330
331
  it generates a SimpleQuery, which is callable without exception.
331
332
 
332
333
  Usage:
@@ -421,7 +422,7 @@ class BaseQuery:
421
422
  Args:
422
423
  operator: A Callable.
423
424
  rhs: A value to test against.
424
- test_against_rhs: Whether the test should evaulate against RHS.
425
+ test_against_rhs: Whether the test should evaluate against RHS.
425
426
  hashval: The hash value for the query.
426
427
  """
427
428
  # Make sure this query has some keys if they are required.
@@ -468,7 +469,7 @@ class BaseQuery:
468
469
  raise TypeError("FieldQuery comparison value must be numeric.")
469
470
 
470
471
  def test(x: Any) -> bool:
471
- """The test function from an operator and righthand side."""
472
+ """The test function from an operator and right-hand side."""
472
473
  if not test_against_rhs:
473
474
  return operator(x, *args) if args else operator(x)
474
475
 
@@ -655,7 +656,7 @@ class BaseQuery:
655
656
  >>> FieldQuery()["my field"].test(test_func)
656
657
 
657
658
  Warning:
658
- The test fuction provided needs to be deterministic (returning the
659
+ The test function provided needs to be deterministic (returning the
659
660
  same value when provided with the same arguments), otherwise this
660
661
  may mess up the query cache that :class:`~tinyflux.table.Table`
661
662
  implements.
@@ -1,4 +1,4 @@
1
- """Defintion of TinyFlux storages classes.
1
+ """Definition of TinyFlux storages classes.
2
2
 
3
3
  Storage defines an abstract base case using the built-in ABC of python. This
4
4
  class defines the requires abstract methods of read, write, and append, as well
@@ -13,6 +13,7 @@ Usage:
13
13
  >>> my_mem_db = TinyFlux(storage=MemoryStorage)
14
14
  >>> my_csv_db = TinyFlux('path/to/my.csv', storage=CSVStorage)
15
15
  """
16
+
16
17
  from abc import ABC, abstractmethod
17
18
  import csv
18
19
  from datetime import datetime
@@ -58,7 +59,7 @@ class Storage(ABC): # pragma: no cover
58
59
  Defines an extensible, static interface with required read/write ops and
59
60
  index-related getter/setters.
60
61
 
61
- Custom storage classes should inheret like so:
62
+ Custom storage classes should inherit like so:
62
63
  >>> from tinyflux import Storage
63
64
  >>> class MyStorageClass(Storage):
64
65
  ...
@@ -96,7 +97,7 @@ class Storage(ABC): # pragma: no cover
96
97
  """Append points to the store.
97
98
 
98
99
  Args:
99
- points: A list of Point objets.
100
+ points: A list of Point objects.
100
101
  temporary: Whether or not to append to temporary storage.
101
102
  """
102
103
  ...
@@ -1,4 +1,5 @@
1
- """Defintion of TinyFlux utils."""
1
+ """Definition of TinyFlux utils."""
2
+
2
3
  import bisect
3
4
  from typing import Any, List, Optional
4
5
 
@@ -0,0 +1,3 @@
1
+ """Version."""
2
+
3
+ __version__ = "0.4.2" # pragma: no cover
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinyflux
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: The Tiny Time-Series Database Optimized for Your Happiness
5
5
  Home-page: https://github.com/citrusvanilla/tinyflux
6
6
  Author: Justin Fung
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3.8
22
22
  Classifier: Programming Language :: Python :: 3.9
23
23
  Classifier: Programming Language :: Python :: 3.10
24
24
  Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
25
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
26
27
  Classifier: Programming Language :: Python :: Implementation :: PyPy
27
28
  Classifier: Operating System :: OS Independent
@@ -36,8 +37,13 @@ License-File: LICENSE
36
37
  .. image:: https://github.com/citrusvanilla/tinyflux/blob/master/artwork/tinyfluxdb-dark.png?raw=true#gh-light-mode-only
37
38
  :width: 500px
38
39
 
40
+ TinyFlux is the tiny time series database optimized for your happiness :)
41
+
42
+ TinyFlux is a time series version of `TinyDB <https://tinydb.readthedocs.io/en/latest/index.html>`__ that is also written in Python and has no external dependencies. It's a great companion for small analytics workflows and apps, as well as at-home IOT data stores. TinyFlux has 100% test coverage, over 50,000 downloads, and no open issues.
43
+
39
44
  |Build Status| |Coverage| |Version| |Downloads|
40
45
 
46
+
41
47
  Quick Links
42
48
  ***********
43
49
 
@@ -48,49 +54,19 @@ Quick Links
48
54
  - `Contributing`_
49
55
 
50
56
 
51
- Recent Updates
52
- **************
53
-
54
- v0.4.0 - March 27, 2023
55
- =======================
56
-
57
- * Tags and Fields can be removed from individual points. See `the documentation <https://tinyflux.readthedocs.io/en/latest/updating-data.html#removing-tags-and-fields-with-update>`__ for more (resolves issue #27).
58
-
59
- v0.3.1 - March 27, 2023
60
- =======================
61
-
62
- * Fixed bug that allowed user to delete key/field tags with `.update()` and `.update_all()` (resolves issue #36).
63
-
64
- v0.3.0 - March 23, 2023
65
- =======================
66
-
67
- * Tag and field keys can be compacted when using CSVStorage, saving potentially many bytes per Point (resolves issue #32).
68
- * Fixed bug that causes tag values of `""` to be serialized as `"_none"` (resolves issue #33).
69
-
70
- See the `Changelog <https://tinyflux.readthedocs.io/en/latest/changelog.html>`__ for more.
71
-
72
-
73
57
  Installation
74
58
  ************
75
59
 
76
- .. code-block:: bash
77
-
78
- $ pip install tinyflux
79
-
80
- Or, download this repository, ``cd`` into it, and:
60
+ TinyFlux is hosted at `PyPI <https://pypi.org/project/tinyflux/>`__ and is easily downloadable with ``pip``. TinyFlux has been tested with Python 3.7 - 3.12 and PyPy-3.9 on Linux and Windows platforms.
81
61
 
82
62
  .. code-block:: bash
83
63
 
84
- $ pip install .
64
+ $ pip install tinyflux
85
65
 
86
66
 
87
67
  Introduction
88
68
  ************
89
69
 
90
- TinyFlux is the tiny time series database optimized for your happiness :)
91
-
92
- TinyFlux is a time series version of `TinyDB <https://tinydb.readthedocs.io/en/latest/index.html>`__ that is also written in Python and has no external dependencies. It's a great companion for small analytics workflows and apps, as well as at-home IOT data stores.
93
-
94
70
  TinyFlux is:
95
71
 
96
72
  - **time-centric:** Python datetime objects are first-class citizens and queries are optimized for time, above all else.
@@ -109,10 +85,6 @@ TinyFlux is:
109
85
 
110
86
  To get started, head over to the `TinyFlux docs <https://tinyflux.readthedocs.io/>`__. Examples can be found in the `examples directory <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`__. You can also discuss topics related to TinyFlux including general development, extensions, or showcase your TinyFlux-based projects on the `GitHub discussion forum <https://github.com/citrusvanilla/tinyflux/discussions>`__.
111
87
 
112
- Supported Python Versions
113
- *************************
114
-
115
- TinyFlux has been tested with Python 3.7 - 3.11 and PyPy-3.9 on Linux and Windows platforms.
116
88
 
117
89
  Example Code Snippets
118
90
  *********************
@@ -168,6 +140,7 @@ The `examples <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`_
168
140
  1. `Loading a TinyFlux DB from a CSV <https://github.com/citrusvanilla/tinyflux/blob/master/examples/1_initializing_and_loading_new_db.ipynb>`__
169
141
  2. `Local Analytics Workflow with a TinyFlux Database <https://github.com/citrusvanilla/tinyflux/blob/master/examples/2_analytics_workflow.ipynb>`__
170
142
  3. `TinyFlux as a MQTT Datastore for IoT Devices <https://github.com/citrusvanilla/tinyflux/blob/master/examples/3_iot_datastore_with_mqtt.py>`__
143
+ 4. `TinyFlux at the Edge (with Backup Strategy) <https://github.com/citrusvanilla/tinyflux/blob/master/examples/4_backing_up_tinyflux_at_the_edge.py>`__
171
144
 
172
145
  Tips
173
146
  ****
@@ -196,8 +169,9 @@ New ideas, new developer tools, improvements, and bugfixes are always welcome.
196
169
  5. Send a pull request.
197
170
 
198
171
  .. |Build Status| image:: https://github.com/citrusvanilla/tinyflux/actions/workflows/build.yml/badge.svg
172
+ :target: https://github.com/citrusvanilla/tinyflux/actions
199
173
  .. |Coverage| image:: https://codecov.io/gh/citrusvanilla/tinyflux/branch/master/graph/badge.svg?token=IEGQ4E57VA
200
- :target: https://app.codecov.io/gh/citrusvanilla
174
+ :target: https://app.codecov.io/gh/citrusvanilla/tinyflux
201
175
  .. |Version| image:: http://img.shields.io/pypi/v/tinyflux.svg
202
176
  :target: https://pypi.python.org/pypi/tinyflux/
203
177
  .. |Downloads| image:: https://img.shields.io/pypi/dm/tinyflux.svg
@@ -3,7 +3,6 @@ MANIFEST.in
3
3
  README.rst
4
4
  pyproject.toml
5
5
  setup.cfg
6
- version.txt
7
6
  tests/__init__.py
8
7
  tests/conftest.py
9
8
  tests/test_index.py
@@ -22,6 +21,7 @@ tinyflux/py.typed
22
21
  tinyflux/queries.py
23
22
  tinyflux/storages.py
24
23
  tinyflux/utils.py
24
+ tinyflux/version.py
25
25
  tinyflux.egg-info/PKG-INFO
26
26
  tinyflux.egg-info/SOURCES.txt
27
27
  tinyflux.egg-info/dependency_links.txt
@@ -1,3 +0,0 @@
1
- include LICENSE
2
- include version.txt
3
- recursive-include tests *.py
@@ -1 +0,0 @@
1
- v0.4.0
File without changes
File without changes
File without changes
File without changes