tinyflux 0.4.2__tar.gz → 1.0.1__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.
Files changed (31) hide show
  1. {tinyflux-0.4.2/tinyflux.egg-info → tinyflux-1.0.1}/PKG-INFO +24 -21
  2. {tinyflux-0.4.2 → tinyflux-1.0.1}/README.rst +19 -17
  3. {tinyflux-0.4.2 → tinyflux-1.0.1}/setup.cfg +2 -2
  4. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux/database.py +1 -74
  5. tinyflux-1.0.1/tinyflux/decorators.py +94 -0
  6. tinyflux-1.0.1/tinyflux/version.py +3 -0
  7. {tinyflux-0.4.2 → tinyflux-1.0.1/tinyflux.egg-info}/PKG-INFO +24 -21
  8. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux.egg-info/SOURCES.txt +1 -0
  9. tinyflux-0.4.2/tinyflux/version.py +0 -3
  10. {tinyflux-0.4.2 → tinyflux-1.0.1}/LICENSE +0 -0
  11. {tinyflux-0.4.2 → tinyflux-1.0.1}/MANIFEST.in +0 -0
  12. {tinyflux-0.4.2 → tinyflux-1.0.1}/pyproject.toml +0 -0
  13. {tinyflux-0.4.2 → tinyflux-1.0.1}/tests/__init__.py +0 -0
  14. {tinyflux-0.4.2 → tinyflux-1.0.1}/tests/conftest.py +0 -0
  15. {tinyflux-0.4.2 → tinyflux-1.0.1}/tests/test_index.py +0 -0
  16. {tinyflux-0.4.2 → tinyflux-1.0.1}/tests/test_measurement.py +0 -0
  17. {tinyflux-0.4.2 → tinyflux-1.0.1}/tests/test_point.py +0 -0
  18. {tinyflux-0.4.2 → tinyflux-1.0.1}/tests/test_queries.py +0 -0
  19. {tinyflux-0.4.2 → tinyflux-1.0.1}/tests/test_storages.py +0 -0
  20. {tinyflux-0.4.2 → tinyflux-1.0.1}/tests/test_tinyflux.py +0 -0
  21. {tinyflux-0.4.2 → tinyflux-1.0.1}/tests/test_utils.py +0 -0
  22. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux/__init__.py +0 -0
  23. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux/index.py +0 -0
  24. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux/measurement.py +0 -0
  25. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux/point.py +0 -0
  26. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux/py.typed +0 -0
  27. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux/queries.py +0 -0
  28. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux/storages.py +0 -0
  29. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux/utils.py +0 -0
  30. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux.egg-info/dependency_links.txt +0 -0
  31. {tinyflux-0.4.2 → tinyflux-1.0.1}/tinyflux.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: tinyflux
3
- Version: 0.4.2
3
+ Version: 1.0.1
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
@@ -17,19 +17,20 @@ Classifier: Topic :: Database
17
17
  Classifier: Topic :: Database :: Database Engines/Servers
18
18
  Classifier: Topic :: Utilities
19
19
  Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.7
21
20
  Classifier: Programming Language :: Python :: 3.8
22
21
  Classifier: Programming Language :: Python :: 3.9
23
22
  Classifier: Programming Language :: Python :: 3.10
24
23
  Classifier: Programming Language :: Python :: 3.11
25
24
  Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
27
27
  Classifier: Programming Language :: Python :: Implementation :: PyPy
28
28
  Classifier: Operating System :: OS Independent
29
29
  Classifier: Typing :: Typed
30
- Requires-Python: >=3.7
30
+ Requires-Python: >=3.8
31
31
  Description-Content-Type: text/x-rst
32
32
  License-File: LICENSE
33
+ Dynamic: license-file
33
34
 
34
35
  .. image:: https://github.com/citrusvanilla/tinyflux/blob/master/artwork/tinyfluxdb-light.png?raw=true#gh-dark-mode-only
35
36
  :width: 500px
@@ -37,11 +38,11 @@ License-File: LICENSE
37
38
  .. image:: https://github.com/citrusvanilla/tinyflux/blob/master/artwork/tinyfluxdb-dark.png?raw=true#gh-light-mode-only
38
39
  :width: 500px
39
40
 
40
- TinyFlux is the tiny time series database optimized for your happiness :)
41
+ TinyFlux is the tiny time series database optimized for your happiness 😎
41
42
 
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
+ TinyFlux is the time series version of `TinyDB <https://tinydb.readthedocs.io/en/latest/index.html>`__ that is 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 120,000 downloads, and no open issues.
43
44
 
44
- |Build Status| |Coverage| |Version| |Downloads|
45
+ |Docs| |Version| |Downloads| |Coverage| |Build Status|
45
46
 
46
47
 
47
48
  Quick Links
@@ -57,7 +58,7 @@ Quick Links
57
58
  Installation
58
59
  ************
59
60
 
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.
61
+ TinyFlux is hosted at `PyPI <https://pypi.org/project/tinyflux/>`__ and is easily downloadable with ``pip``. TinyFlux has been tested with Python 3.8 - 3.13 and PyPy-3.9 on Linux and Windows platforms.
61
62
 
62
63
  .. code-block:: bash
63
64
 
@@ -69,19 +70,19 @@ Introduction
69
70
 
70
71
  TinyFlux is:
71
72
 
72
- - **time-centric:** Python datetime objects are first-class citizens and queries are optimized for time, above all else.
73
+ - **optimized for your happiness:** TinyFlux is designed to be simple and fun to use by providing a clean API that can be learned in about 90 seconds.
73
74
 
74
- - **optimized for your happiness:** TinyFlux is designed to be simple and
75
- fun to use by providing a simple and clean API that can be learned in 5 minutes.
75
+ - **time-centric:** Python datetime objects are first-class citizens, and both the storage and queries are optimized for time above all else.
76
76
 
77
- - **tiny:** The current source code has 4,000 lines of code (with about 50%
78
- documentation) and 4,000 lines of tests. TinyFlux is about 150kb, unzipped.
77
+ - **human-friendly:** The primary datastore is a CSV, making your database human-readable from the very first write. No need to use SQL to investigate your data, just open the DB file in any tabular-friendly application.
79
78
 
80
- - **written in pure Python:** TinyFlux needs neither an external server nor any dependencies.
79
+ - **pure Python:** TinyFlux needs neither an external server nor any dependencies.
81
80
 
82
- - **works on Python 3.7+ and PyPy-3.9:** TinyFlux works on all modern versions of Python and PyPy.
81
+ - **tiny:** TinyFlux is about 150kb, unzipped. The current source code has 4,000 lines of code (with about 50% documentation) and 4,000 lines of tests.
83
82
 
84
- - **100% test coverage:** No explanation needed.
83
+ - **developed for modern Python:** TinyFlux works on all modern versions of Python (3.8 - 3.13) and PyPy (3.9).
84
+
85
+ - **100% covered by tests:** No explanation needed.
85
86
 
86
87
  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>`__.
87
88
 
@@ -135,7 +136,7 @@ Querying TinyFlux
135
136
  Full Example Notebooks and Workflows
136
137
  ************************************
137
138
 
138
- The `examples <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`__ directory of this repository contains three common uses cases for TinyFlux and the associated boilerplate to get you started:
139
+ The `examples <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`__ directory of this repository contains four common uses cases for TinyFlux and the associated boilerplate to get you started:
139
140
 
140
141
  1. `Loading a TinyFlux DB from a CSV <https://github.com/citrusvanilla/tinyflux/blob/master/examples/1_initializing_and_loading_new_db.ipynb>`__
141
142
  2. `Local Analytics Workflow with a TinyFlux Database <https://github.com/citrusvanilla/tinyflux/blob/master/examples/2_analytics_workflow.ipynb>`__
@@ -151,16 +152,16 @@ Checkout some tips for working with TinyFlux `here <https://tinyflux.readthedocs
151
152
  TinyFlux Across the Internet
152
153
  ****************************
153
154
 
154
- Articles, tutorials, and other instances of TinyFlux:
155
+ Articles, tutorials, and other instances of TinyFlux in the wild:
155
156
 
156
157
  - `"Introducing TinyFlux: The Tiny Time Series Database for Python-based IoT & Analytics Applications" <https://citrusvanilla.medium.com/introducing-tinyflux-the-tiny-time-series-database-for-python-based-iot-analytics-applications-c3ef3c3bedf>`__: A Medium.com article announcing the release of TinyFlux
157
158
  - `"Storing Time Series Data in Python Using TinyFluxDB" <http://www.steves-internet-guide.com/storing-time-series-data-python-using-tinyflux-db/>`__: A tutorial from `Steve's Internet Guide <http://www.steves-internet-guide.com/>`__, a portal for learning MQTT and IoT development for Python
158
-
159
+ - `"KaiCode 2024 Shortlist" <https://www.kaicode.org/2024.html>`__: TinyFlux came in 10th place out of 412 entrants in the 7th edition of this open-source festival, a festival dedicated to recognizing projects with high-quality open-source principles.
159
160
 
160
161
  Contributing
161
162
  ************
162
163
 
163
- New ideas, new developer tools, improvements, and bugfixes are always welcome. Follow these guidelines before getting started:
164
+ New ideas, developer tools, improvements, and bugfixes are always welcome. Follow these guidelines before getting started:
164
165
 
165
166
  1. Make sure to read `Getting Started <https://tinyflux.readthedocs.io/en/latest/getting-started.html>`__ and the `Contributing Tooling and Conventions <https://tinyflux.readthedocs.io/en/latest/contributing-tooling.html>`__ section of the documentation.
166
167
  2. Check GitHub for `existing open issues <https://github.com/citrusvanilla/tinyflux/issues>`__, `open a new issue <https://github.com/citrusvanilla/tinyflux/issues/new>`__ or `start a new discussion <https://github.com/citrusvanilla/tinyflux/discussions/new>`__.
@@ -168,11 +169,13 @@ New ideas, new developer tools, improvements, and bugfixes are always welcome.
168
169
  4. Write unit tests, ensure the code is 100% covered, update documentation where necessary, and format and style the code correctly.
169
170
  5. Send a pull request.
170
171
 
172
+ .. |Docs| image:: https://img.shields.io/readthedocs/docs
173
+ :target: https://tinyflux.readthedocs.io/en/latest/
171
174
  .. |Build Status| image:: https://github.com/citrusvanilla/tinyflux/actions/workflows/build.yml/badge.svg
172
175
  :target: https://github.com/citrusvanilla/tinyflux/actions
173
176
  .. |Coverage| image:: https://codecov.io/gh/citrusvanilla/tinyflux/branch/master/graph/badge.svg?token=IEGQ4E57VA
174
177
  :target: https://app.codecov.io/gh/citrusvanilla/tinyflux
175
178
  .. |Version| image:: http://img.shields.io/pypi/v/tinyflux.svg
176
179
  :target: https://pypi.python.org/pypi/tinyflux/
177
- .. |Downloads| image:: https://img.shields.io/pypi/dm/tinyflux.svg
180
+ .. |Downloads| image:: https://img.shields.io/pepy/dt/tinyflux
178
181
  :target: https://pypi.python.org/pypi/tinyflux/
@@ -4,11 +4,11 @@
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 :)
7
+ TinyFlux is the tiny time series database optimized for your happiness 😎
8
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.
9
+ TinyFlux is the time series version of `TinyDB <https://tinydb.readthedocs.io/en/latest/index.html>`__ that is 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 120,000 downloads, and no open issues.
10
10
 
11
- |Build Status| |Coverage| |Version| |Downloads|
11
+ |Docs| |Version| |Downloads| |Coverage| |Build Status|
12
12
 
13
13
 
14
14
  Quick Links
@@ -24,7 +24,7 @@ Quick Links
24
24
  Installation
25
25
  ************
26
26
 
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.
27
+ TinyFlux is hosted at `PyPI <https://pypi.org/project/tinyflux/>`__ and is easily downloadable with ``pip``. TinyFlux has been tested with Python 3.8 - 3.13 and PyPy-3.9 on Linux and Windows platforms.
28
28
 
29
29
  .. code-block:: bash
30
30
 
@@ -36,19 +36,19 @@ Introduction
36
36
 
37
37
  TinyFlux is:
38
38
 
39
- - **time-centric:** Python datetime objects are first-class citizens and queries are optimized for time, above all else.
39
+ - **optimized for your happiness:** TinyFlux is designed to be simple and fun to use by providing a clean API that can be learned in about 90 seconds.
40
40
 
41
- - **optimized for your happiness:** TinyFlux is designed to be simple and
42
- fun to use by providing a simple and clean API that can be learned in 5 minutes.
41
+ - **time-centric:** Python datetime objects are first-class citizens, and both the storage and queries are optimized for time above all else.
43
42
 
44
- - **tiny:** The current source code has 4,000 lines of code (with about 50%
45
- documentation) and 4,000 lines of tests. TinyFlux is about 150kb, unzipped.
43
+ - **human-friendly:** The primary datastore is a CSV, making your database human-readable from the very first write. No need to use SQL to investigate your data, just open the DB file in any tabular-friendly application.
46
44
 
47
- - **written in pure Python:** TinyFlux needs neither an external server nor any dependencies.
45
+ - **pure Python:** TinyFlux needs neither an external server nor any dependencies.
48
46
 
49
- - **works on Python 3.7+ and PyPy-3.9:** TinyFlux works on all modern versions of Python and PyPy.
47
+ - **tiny:** TinyFlux is about 150kb, unzipped. The current source code has 4,000 lines of code (with about 50% documentation) and 4,000 lines of tests.
50
48
 
51
- - **100% test coverage:** No explanation needed.
49
+ - **developed for modern Python:** TinyFlux works on all modern versions of Python (3.8 - 3.13) and PyPy (3.9).
50
+
51
+ - **100% covered by tests:** No explanation needed.
52
52
 
53
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>`__.
54
54
 
@@ -102,7 +102,7 @@ Querying TinyFlux
102
102
  Full Example Notebooks and Workflows
103
103
  ************************************
104
104
 
105
- The `examples <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`__ directory of this repository contains three common uses cases for TinyFlux and the associated boilerplate to get you started:
105
+ The `examples <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`__ directory of this repository contains four common uses cases for TinyFlux and the associated boilerplate to get you started:
106
106
 
107
107
  1. `Loading a TinyFlux DB from a CSV <https://github.com/citrusvanilla/tinyflux/blob/master/examples/1_initializing_and_loading_new_db.ipynb>`__
108
108
  2. `Local Analytics Workflow with a TinyFlux Database <https://github.com/citrusvanilla/tinyflux/blob/master/examples/2_analytics_workflow.ipynb>`__
@@ -118,16 +118,16 @@ Checkout some tips for working with TinyFlux `here <https://tinyflux.readthedocs
118
118
  TinyFlux Across the Internet
119
119
  ****************************
120
120
 
121
- Articles, tutorials, and other instances of TinyFlux:
121
+ Articles, tutorials, and other instances of TinyFlux in the wild:
122
122
 
123
123
  - `"Introducing TinyFlux: The Tiny Time Series Database for Python-based IoT & Analytics Applications" <https://citrusvanilla.medium.com/introducing-tinyflux-the-tiny-time-series-database-for-python-based-iot-analytics-applications-c3ef3c3bedf>`__: A Medium.com article announcing the release of TinyFlux
124
124
  - `"Storing Time Series Data in Python Using TinyFluxDB" <http://www.steves-internet-guide.com/storing-time-series-data-python-using-tinyflux-db/>`__: A tutorial from `Steve's Internet Guide <http://www.steves-internet-guide.com/>`__, a portal for learning MQTT and IoT development for Python
125
-
125
+ - `"KaiCode 2024 Shortlist" <https://www.kaicode.org/2024.html>`__: TinyFlux came in 10th place out of 412 entrants in the 7th edition of this open-source festival, a festival dedicated to recognizing projects with high-quality open-source principles.
126
126
 
127
127
  Contributing
128
128
  ************
129
129
 
130
- New ideas, new developer tools, improvements, and bugfixes are always welcome. Follow these guidelines before getting started:
130
+ New ideas, developer tools, improvements, and bugfixes are always welcome. Follow these guidelines before getting started:
131
131
 
132
132
  1. Make sure to read `Getting Started <https://tinyflux.readthedocs.io/en/latest/getting-started.html>`__ and the `Contributing Tooling and Conventions <https://tinyflux.readthedocs.io/en/latest/contributing-tooling.html>`__ section of the documentation.
133
133
  2. Check GitHub for `existing open issues <https://github.com/citrusvanilla/tinyflux/issues>`__, `open a new issue <https://github.com/citrusvanilla/tinyflux/issues/new>`__ or `start a new discussion <https://github.com/citrusvanilla/tinyflux/discussions/new>`__.
@@ -135,11 +135,13 @@ New ideas, new developer tools, improvements, and bugfixes are always welcome.
135
135
  4. Write unit tests, ensure the code is 100% covered, update documentation where necessary, and format and style the code correctly.
136
136
  5. Send a pull request.
137
137
 
138
+ .. |Docs| image:: https://img.shields.io/readthedocs/docs
139
+ :target: https://tinyflux.readthedocs.io/en/latest/
138
140
  .. |Build Status| image:: https://github.com/citrusvanilla/tinyflux/actions/workflows/build.yml/badge.svg
139
141
  :target: https://github.com/citrusvanilla/tinyflux/actions
140
142
  .. |Coverage| image:: https://codecov.io/gh/citrusvanilla/tinyflux/branch/master/graph/badge.svg?token=IEGQ4E57VA
141
143
  :target: https://app.codecov.io/gh/citrusvanilla/tinyflux
142
144
  .. |Version| image:: http://img.shields.io/pypi/v/tinyflux.svg
143
145
  :target: https://pypi.python.org/pypi/tinyflux/
144
- .. |Downloads| image:: https://img.shields.io/pypi/dm/tinyflux.svg
146
+ .. |Downloads| image:: https://img.shields.io/pepy/dt/tinyflux
145
147
  :target: https://pypi.python.org/pypi/tinyflux/
@@ -29,12 +29,12 @@ classifiers =
29
29
  Topic :: Database :: Database Engines/Servers
30
30
  Topic :: Utilities
31
31
  Programming Language :: Python :: 3
32
- Programming Language :: Python :: 3.7
33
32
  Programming Language :: Python :: 3.8
34
33
  Programming Language :: Python :: 3.9
35
34
  Programming Language :: Python :: 3.10
36
35
  Programming Language :: Python :: 3.11
37
36
  Programming Language :: Python :: 3.12
37
+ Programming Language :: Python :: 3.13
38
38
  Programming Language :: Python :: Implementation :: CPython
39
39
  Programming Language :: Python :: Implementation :: PyPy
40
40
  Operating System :: OS Independent
@@ -42,7 +42,7 @@ classifiers =
42
42
 
43
43
  [options]
44
44
  packages = tinyflux
45
- python_requires = >=3.7
45
+ python_requires = >=3.8
46
46
 
47
47
  [options.package_data]
48
48
  tinyflux = py.typed
@@ -2,7 +2,6 @@
2
2
 
3
3
  import copy
4
4
  from datetime import datetime, timezone
5
- from functools import wraps
6
5
  from typing import (
7
6
  Any,
8
7
  Callable,
@@ -16,6 +15,7 @@ from typing import (
16
15
  Union,
17
16
  )
18
17
 
18
+ from .decorators import read_op, write_op, temp_storage_op, append_op
19
19
  from .index import Index
20
20
  from .measurement import Measurement
21
21
  from .point import (
@@ -36,79 +36,6 @@ from .queries import (
36
36
  from .storages import CSVStorage, Storage
37
37
 
38
38
 
39
- def append_op(method: Callable[..., Any]) -> Callable[..., Any]:
40
- """Decorate an append operation with assertion.
41
-
42
- Ensures storage can be appended to before doing anything.
43
- """
44
-
45
- @wraps(method)
46
- def op(self: Any, *args: Any, **kwargs: Any) -> Any:
47
- """Decorate."""
48
- assert self._storage.can_append
49
- return method(self, *args, **kwargs)
50
-
51
- return op
52
-
53
-
54
- def read_op(method: Callable[..., Any]) -> Callable[..., Any]:
55
- """Decorate a read operation with assertion.
56
-
57
- Ensures storage can be read from before doing anything.
58
- """
59
-
60
- @wraps(method)
61
- def op(self: Any, *args: Any, **kwargs: Any) -> Any:
62
- """Decorate."""
63
- assert self._storage.can_read
64
-
65
- if self._auto_index and not self._index.valid:
66
- self.reindex()
67
-
68
- return method(self, *args, **kwargs)
69
-
70
- return op
71
-
72
-
73
- def temp_storage_op(method: Callable[..., Any]) -> Callable[..., Any]:
74
- """Decorate a db operation that requires auxiliary storage.
75
-
76
- Initializes temporary storage, invokes method, and cleans-up storage after
77
- op has run.
78
- """
79
-
80
- @wraps(method)
81
- def op(self: Any, *args: Any, **kwargs: Any) -> Any:
82
- """Decorate."""
83
- # Init temp storage in the storage class.
84
- self._storage._init_temp_storage()
85
-
86
- # Invoke op.
87
- rst = method(self, *args, **kwargs)
88
-
89
- # Clean-up temp storage.
90
- self._storage._cleanup_temp_storage()
91
-
92
- return rst
93
-
94
- return op
95
-
96
-
97
- def write_op(method: Callable[..., Any]) -> Callable[..., Any]:
98
- """Decorate a write operation with assertion.
99
-
100
- Ensures storage can be written to before doing anything.
101
- """
102
-
103
- @wraps(method)
104
- def op(self: Any, *args: Any, **kwargs: Any) -> Any:
105
- """Decorate."""
106
- assert self._storage.can_write
107
- return method(self, *args, **kwargs)
108
-
109
- return op
110
-
111
-
112
39
  class TinyFlux:
113
40
  """The TinyFlux class containing the interface for the TinyFlux package.
114
41
 
@@ -0,0 +1,94 @@
1
+ """
2
+ This module contains decorators for various operations related to \
3
+ storage management.
4
+
5
+ The decorators ensure certain preconditions are met before executing methods,
6
+ such as checking if the storage is appendable, readable, or writable. They also
7
+ handle temporary storage initialization and cleanup when required.
8
+
9
+ Decorators included:
10
+ - `append_op`: Ensures storage can be appended to before executing the method.
11
+ - `read_op`: Ensures storage can be read from, with optional reindexing.
12
+ - `temp_storage_op`: Handles temporary storage initialization and cleanup for
13
+ operations.
14
+ - `write_op`: Ensures storage can be written to before executing the method.
15
+ """
16
+
17
+ from functools import wraps
18
+ from typing import (
19
+ Any,
20
+ Callable,
21
+ )
22
+
23
+
24
+ def append_op(method: Callable[..., Any]) -> Callable[..., Any]:
25
+ """Decorate an append operation with assertion.
26
+
27
+ Ensures storage can be appended to before doing anything.
28
+ """
29
+
30
+ @wraps(method)
31
+ def op(self: Any, *args: Any, **kwargs: Any) -> Any:
32
+ """Decorate."""
33
+ assert self._storage.can_append
34
+ return method(self, *args, **kwargs)
35
+
36
+ return op
37
+
38
+
39
+ def read_op(method: Callable[..., Any]) -> Callable[..., Any]:
40
+ """Decorate a read operation with assertion.
41
+
42
+ Ensures storage can be read from before doing anything.
43
+ """
44
+
45
+ @wraps(method)
46
+ def op(self: Any, *args: Any, **kwargs: Any) -> Any:
47
+ """Decorate."""
48
+ assert self._storage.can_read
49
+
50
+ if self._auto_index and not self._index.valid:
51
+ self.reindex()
52
+
53
+ return method(self, *args, **kwargs)
54
+
55
+ return op
56
+
57
+
58
+ def temp_storage_op(method: Callable[..., Any]) -> Callable[..., Any]:
59
+ """Decorate a db operation that requires auxiliary storage.
60
+
61
+ Initializes temporary storage, invokes method, and cleans-up storage after
62
+ op has run.
63
+ """
64
+
65
+ @wraps(method)
66
+ def op(self: Any, *args: Any, **kwargs: Any) -> Any:
67
+ """Decorate."""
68
+ # Init temp storage in the storage class.
69
+ self._storage._init_temp_storage()
70
+
71
+ # Invoke op.
72
+ rst = method(self, *args, **kwargs)
73
+
74
+ # Clean-up temp storage.
75
+ self._storage._cleanup_temp_storage()
76
+
77
+ return rst
78
+
79
+ return op
80
+
81
+
82
+ def write_op(method: Callable[..., Any]) -> Callable[..., Any]:
83
+ """Decorate a write operation with assertion.
84
+
85
+ Ensures storage can be written to before doing anything.
86
+ """
87
+
88
+ @wraps(method)
89
+ def op(self: Any, *args: Any, **kwargs: Any) -> Any:
90
+ """Decorate."""
91
+ assert self._storage.can_write
92
+ return method(self, *args, **kwargs)
93
+
94
+ return op
@@ -0,0 +1,3 @@
1
+ """Version."""
2
+
3
+ __version__ = "1.0.1" # pragma: no cover
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: tinyflux
3
- Version: 0.4.2
3
+ Version: 1.0.1
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
@@ -17,19 +17,20 @@ Classifier: Topic :: Database
17
17
  Classifier: Topic :: Database :: Database Engines/Servers
18
18
  Classifier: Topic :: Utilities
19
19
  Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.7
21
20
  Classifier: Programming Language :: Python :: 3.8
22
21
  Classifier: Programming Language :: Python :: 3.9
23
22
  Classifier: Programming Language :: Python :: 3.10
24
23
  Classifier: Programming Language :: Python :: 3.11
25
24
  Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
27
27
  Classifier: Programming Language :: Python :: Implementation :: PyPy
28
28
  Classifier: Operating System :: OS Independent
29
29
  Classifier: Typing :: Typed
30
- Requires-Python: >=3.7
30
+ Requires-Python: >=3.8
31
31
  Description-Content-Type: text/x-rst
32
32
  License-File: LICENSE
33
+ Dynamic: license-file
33
34
 
34
35
  .. image:: https://github.com/citrusvanilla/tinyflux/blob/master/artwork/tinyfluxdb-light.png?raw=true#gh-dark-mode-only
35
36
  :width: 500px
@@ -37,11 +38,11 @@ License-File: LICENSE
37
38
  .. image:: https://github.com/citrusvanilla/tinyflux/blob/master/artwork/tinyfluxdb-dark.png?raw=true#gh-light-mode-only
38
39
  :width: 500px
39
40
 
40
- TinyFlux is the tiny time series database optimized for your happiness :)
41
+ TinyFlux is the tiny time series database optimized for your happiness 😎
41
42
 
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
+ TinyFlux is the time series version of `TinyDB <https://tinydb.readthedocs.io/en/latest/index.html>`__ that is 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 120,000 downloads, and no open issues.
43
44
 
44
- |Build Status| |Coverage| |Version| |Downloads|
45
+ |Docs| |Version| |Downloads| |Coverage| |Build Status|
45
46
 
46
47
 
47
48
  Quick Links
@@ -57,7 +58,7 @@ Quick Links
57
58
  Installation
58
59
  ************
59
60
 
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.
61
+ TinyFlux is hosted at `PyPI <https://pypi.org/project/tinyflux/>`__ and is easily downloadable with ``pip``. TinyFlux has been tested with Python 3.8 - 3.13 and PyPy-3.9 on Linux and Windows platforms.
61
62
 
62
63
  .. code-block:: bash
63
64
 
@@ -69,19 +70,19 @@ Introduction
69
70
 
70
71
  TinyFlux is:
71
72
 
72
- - **time-centric:** Python datetime objects are first-class citizens and queries are optimized for time, above all else.
73
+ - **optimized for your happiness:** TinyFlux is designed to be simple and fun to use by providing a clean API that can be learned in about 90 seconds.
73
74
 
74
- - **optimized for your happiness:** TinyFlux is designed to be simple and
75
- fun to use by providing a simple and clean API that can be learned in 5 minutes.
75
+ - **time-centric:** Python datetime objects are first-class citizens, and both the storage and queries are optimized for time above all else.
76
76
 
77
- - **tiny:** The current source code has 4,000 lines of code (with about 50%
78
- documentation) and 4,000 lines of tests. TinyFlux is about 150kb, unzipped.
77
+ - **human-friendly:** The primary datastore is a CSV, making your database human-readable from the very first write. No need to use SQL to investigate your data, just open the DB file in any tabular-friendly application.
79
78
 
80
- - **written in pure Python:** TinyFlux needs neither an external server nor any dependencies.
79
+ - **pure Python:** TinyFlux needs neither an external server nor any dependencies.
81
80
 
82
- - **works on Python 3.7+ and PyPy-3.9:** TinyFlux works on all modern versions of Python and PyPy.
81
+ - **tiny:** TinyFlux is about 150kb, unzipped. The current source code has 4,000 lines of code (with about 50% documentation) and 4,000 lines of tests.
83
82
 
84
- - **100% test coverage:** No explanation needed.
83
+ - **developed for modern Python:** TinyFlux works on all modern versions of Python (3.8 - 3.13) and PyPy (3.9).
84
+
85
+ - **100% covered by tests:** No explanation needed.
85
86
 
86
87
  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>`__.
87
88
 
@@ -135,7 +136,7 @@ Querying TinyFlux
135
136
  Full Example Notebooks and Workflows
136
137
  ************************************
137
138
 
138
- The `examples <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`__ directory of this repository contains three common uses cases for TinyFlux and the associated boilerplate to get you started:
139
+ The `examples <https://github.com/citrusvanilla/tinyflux/tree/master/examples>`__ directory of this repository contains four common uses cases for TinyFlux and the associated boilerplate to get you started:
139
140
 
140
141
  1. `Loading a TinyFlux DB from a CSV <https://github.com/citrusvanilla/tinyflux/blob/master/examples/1_initializing_and_loading_new_db.ipynb>`__
141
142
  2. `Local Analytics Workflow with a TinyFlux Database <https://github.com/citrusvanilla/tinyflux/blob/master/examples/2_analytics_workflow.ipynb>`__
@@ -151,16 +152,16 @@ Checkout some tips for working with TinyFlux `here <https://tinyflux.readthedocs
151
152
  TinyFlux Across the Internet
152
153
  ****************************
153
154
 
154
- Articles, tutorials, and other instances of TinyFlux:
155
+ Articles, tutorials, and other instances of TinyFlux in the wild:
155
156
 
156
157
  - `"Introducing TinyFlux: The Tiny Time Series Database for Python-based IoT & Analytics Applications" <https://citrusvanilla.medium.com/introducing-tinyflux-the-tiny-time-series-database-for-python-based-iot-analytics-applications-c3ef3c3bedf>`__: A Medium.com article announcing the release of TinyFlux
157
158
  - `"Storing Time Series Data in Python Using TinyFluxDB" <http://www.steves-internet-guide.com/storing-time-series-data-python-using-tinyflux-db/>`__: A tutorial from `Steve's Internet Guide <http://www.steves-internet-guide.com/>`__, a portal for learning MQTT and IoT development for Python
158
-
159
+ - `"KaiCode 2024 Shortlist" <https://www.kaicode.org/2024.html>`__: TinyFlux came in 10th place out of 412 entrants in the 7th edition of this open-source festival, a festival dedicated to recognizing projects with high-quality open-source principles.
159
160
 
160
161
  Contributing
161
162
  ************
162
163
 
163
- New ideas, new developer tools, improvements, and bugfixes are always welcome. Follow these guidelines before getting started:
164
+ New ideas, developer tools, improvements, and bugfixes are always welcome. Follow these guidelines before getting started:
164
165
 
165
166
  1. Make sure to read `Getting Started <https://tinyflux.readthedocs.io/en/latest/getting-started.html>`__ and the `Contributing Tooling and Conventions <https://tinyflux.readthedocs.io/en/latest/contributing-tooling.html>`__ section of the documentation.
166
167
  2. Check GitHub for `existing open issues <https://github.com/citrusvanilla/tinyflux/issues>`__, `open a new issue <https://github.com/citrusvanilla/tinyflux/issues/new>`__ or `start a new discussion <https://github.com/citrusvanilla/tinyflux/discussions/new>`__.
@@ -168,11 +169,13 @@ New ideas, new developer tools, improvements, and bugfixes are always welcome.
168
169
  4. Write unit tests, ensure the code is 100% covered, update documentation where necessary, and format and style the code correctly.
169
170
  5. Send a pull request.
170
171
 
172
+ .. |Docs| image:: https://img.shields.io/readthedocs/docs
173
+ :target: https://tinyflux.readthedocs.io/en/latest/
171
174
  .. |Build Status| image:: https://github.com/citrusvanilla/tinyflux/actions/workflows/build.yml/badge.svg
172
175
  :target: https://github.com/citrusvanilla/tinyflux/actions
173
176
  .. |Coverage| image:: https://codecov.io/gh/citrusvanilla/tinyflux/branch/master/graph/badge.svg?token=IEGQ4E57VA
174
177
  :target: https://app.codecov.io/gh/citrusvanilla/tinyflux
175
178
  .. |Version| image:: http://img.shields.io/pypi/v/tinyflux.svg
176
179
  :target: https://pypi.python.org/pypi/tinyflux/
177
- .. |Downloads| image:: https://img.shields.io/pypi/dm/tinyflux.svg
180
+ .. |Downloads| image:: https://img.shields.io/pepy/dt/tinyflux
178
181
  :target: https://pypi.python.org/pypi/tinyflux/
@@ -14,6 +14,7 @@ tests/test_tinyflux.py
14
14
  tests/test_utils.py
15
15
  tinyflux/__init__.py
16
16
  tinyflux/database.py
17
+ tinyflux/decorators.py
17
18
  tinyflux/index.py
18
19
  tinyflux/measurement.py
19
20
  tinyflux/point.py
@@ -1,3 +0,0 @@
1
- """Version."""
2
-
3
- __version__ = "0.4.2" # pragma: no cover
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes