demantoid 0.2.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nikita Moroshkin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: demantoid
3
+ Version: 0.2.0
4
+ Summary: A tiny library for recording evolutionary algorithm metrics into TimescaleDB
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Keywords: evolutionary-algorithms,optimization,metrics,postgresql,timescaledb,benchmarking
8
+ Author: Nikita Moroshkin
9
+ Author-email: seed.suboty@gmail.com
10
+ Requires-Python: >=3.13
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: C
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Scientific/Engineering
18
+ Classifier: Topic :: Database
19
+ Provides-Extra: examples
20
+ Requires-Dist: matplotlib ; extra == "examples"
21
+ Requires-Dist: numpy ; extra == "examples"
22
+ Requires-Dist: thefittest ; extra == "examples"
23
+ Project-URL: Homepage, https://github.com/suboty/demantoid
24
+ Project-URL: Issues, https://github.com/suboty/demantoid/issues
25
+ Project-URL: Repository, https://github.com/suboty/demantoid
26
+ Description-Content-Type: text/markdown
27
+
28
+ # demantoid v0.2.0
29
+
30
+ A tiny library for recording evolutionary algorithm metrics into TimescaleDB.
31
+
32
+ Read about versions [here](CHANGELOG.md).
33
+
@@ -0,0 +1,5 @@
1
+ # demantoid v0.2.0
2
+
3
+ A tiny library for recording evolutionary algorithm metrics into TimescaleDB.
4
+
5
+ Read about versions [here](CHANGELOG.md).
@@ -0,0 +1,6 @@
1
+ from ._core import Demantoid, WriteMode
2
+
3
+ __all__ = [
4
+ "Demantoid",
5
+ "WriteMode",
6
+ ]
@@ -0,0 +1,150 @@
1
+ import ctypes
2
+ import os
3
+ import platform
4
+ from pathlib import Path
5
+
6
+ _platform = platform.system()
7
+
8
+ match _platform:
9
+ case "Darwin":
10
+ lib_name = "libdemantoid.so"
11
+ case "Windows":
12
+ lib_name = "demantoid.dll"
13
+ case _:
14
+ lib_name = "libdemantoid.so"
15
+
16
+ _possible_paths = [
17
+ Path(os.path.dirname(__file__), lib_name),
18
+ Path(os.path.dirname(__file__), "..", "..", "build", lib_name),
19
+ ]
20
+
21
+ _lib_path = None
22
+ for p in _possible_paths:
23
+ if os.path.exists(p):
24
+ _lib_path = os.path.abspath(p)
25
+ break
26
+
27
+ if _lib_path is None:
28
+ raise OSError(
29
+ f"Could not find {lib_name}!"
30
+ )
31
+
32
+ _lib = ctypes.CDLL(_lib_path)
33
+
34
+ class DemantoidConn(ctypes.Structure):
35
+ pass
36
+
37
+ DemantoidConnPtr = ctypes.POINTER(DemantoidConn)
38
+
39
+ class DemantoidWriteMode(ctypes.c_char_p):
40
+ pass
41
+
42
+ class DemantoidMetric(ctypes.Structure):
43
+ pass
44
+
45
+ DemantoidMetricPtr = ctypes.POINTER(DemantoidMetric)
46
+
47
+ _lib.demantoid_connect.argtypes = [ctypes.c_char_p]
48
+ _lib.demantoid_connect.restype = DemantoidConnPtr
49
+
50
+ _lib.demantoid_close.argtypes = [DemantoidConnPtr]
51
+ _lib.demantoid_close.restype = None
52
+
53
+ _lib.create_experiment.argtypes = [DemantoidConnPtr, ctypes.c_char_p]
54
+ _lib.create_experiment.restype = ctypes.c_bool
55
+
56
+ _lib.create_run.argtypes = [DemantoidConnPtr, ctypes.c_char_p]
57
+ _lib.create_run.restype = ctypes.c_bool
58
+
59
+ _lib.create_run_json.argtypes = [DemantoidConnPtr, ctypes.c_char_p]
60
+ _lib.create_run_json.restype = ctypes.c_bool
61
+
62
+ _lib.finish_run.argtypes = [DemantoidConnPtr]
63
+ _lib.finish_run.restype = ctypes.c_bool
64
+
65
+ _lib.set_write_mode.argtypes = [DemantoidConnPtr, DemantoidWriteMode]
66
+ _lib.set_write_mode.restype = ctypes.c_bool
67
+
68
+ _lib.set_batch_size.argtypes = [DemantoidConnPtr, ctypes.c_size_t]
69
+ _lib.set_batch_size.restype = ctypes.c_bool
70
+
71
+ _lib.flush_metrics.argtypes = [DemantoidConnPtr]
72
+ _lib.flush_metrics.restype = ctypes.c_bool
73
+
74
+ _lib.add_metric.argtypes = [
75
+ DemantoidConnPtr,
76
+ ctypes.c_int,
77
+ ctypes.c_char_p,
78
+ ctypes.c_float
79
+ ]
80
+ _lib.add_metric.restype = ctypes.c_bool
81
+
82
+ _lib.add_metrics.argtypes = [
83
+ DemantoidConnPtr,
84
+ DemantoidMetricPtr,
85
+ ctypes.c_size_t
86
+ ]
87
+ _lib.add_metric.restype = ctypes.c_bool
88
+
89
+ def demantoid_connect(connection_info: str) -> DemantoidConnPtr:
90
+ return _lib.demantoid_connect(connection_info.encode("utf-8"))
91
+
92
+ def demantoid_close(conn: DemantoidConnPtr) -> None:
93
+ return _lib.demantoid_close(conn)
94
+
95
+ def create_experiment(conn: DemantoidConnPtr, experiment_info: str) -> bool:
96
+ return _lib.create_experiment(
97
+ conn,
98
+ experiment_info.encode("utf-8")
99
+ )
100
+
101
+ def create_run(conn: DemantoidConnPtr, run_info: str) -> bool:
102
+ return _lib.create_run(
103
+ conn,
104
+ run_info.encode("utf-8")
105
+ )
106
+
107
+ def create_run_json(conn: DemantoidConnPtr, run_json: str) -> bool:
108
+ return _lib.create_run_json(
109
+ conn,
110
+ run_json.encode("utf-8")
111
+ )
112
+
113
+ def finish_run(conn: DemantoidConnPtr) -> bool:
114
+ return _lib.finish_run(conn)
115
+
116
+ def set_write_mode(
117
+ conn: DemantoidConnPtr,
118
+ mode: DemantoidWriteMode
119
+ ) -> bool:
120
+ return _lib.set_write_mode(conn, mode)
121
+
122
+ def set_batch_size(conn: DemantoidConnPtr, size: int) -> bool:
123
+ return _lib.set_batch_size(conn, size)
124
+
125
+ def flush_metrics(conn: DemantoidConnPtr) -> bool:
126
+ return _lib.flush_metrics(conn)
127
+
128
+ def add_metric(
129
+ conn: DemantoidConnPtr,
130
+ pop_number: int,
131
+ metric_name: str,
132
+ metric_value: float
133
+ ) -> bool:
134
+ return _lib.add_metric(
135
+ conn,
136
+ pop_number,
137
+ metric_name.encode("utf-8"),
138
+ metric_value
139
+ )
140
+
141
+ def add_metrics(
142
+ conn: DemantoidConnPtr,
143
+ metrics: DemantoidMetricPtr,
144
+ count: int
145
+ ) -> bool:
146
+ return _lib.add_metrics(
147
+ conn,
148
+ metrics,
149
+ count
150
+ )
@@ -0,0 +1,55 @@
1
+ [project]
2
+ name = "demantoid"
3
+ version = "0.2.0"
4
+ description = "A tiny library for recording evolutionary algorithm metrics into TimescaleDB"
5
+
6
+ authors = [
7
+ {name = "Nikita Moroshkin", email = "seed.suboty@gmail.com"}
8
+ ]
9
+
10
+ license = "MIT"
11
+ readme = "README.md"
12
+ requires-python = ">=3.13"
13
+
14
+ keywords = [
15
+ "evolutionary-algorithms",
16
+ "optimization",
17
+ "metrics",
18
+ "postgresql",
19
+ "timescaledb",
20
+ "benchmarking"
21
+ ]
22
+
23
+ classifiers = [
24
+ "Development Status :: 3 - Alpha",
25
+ "Intended Audience :: Developers",
26
+ "Intended Audience :: Science/Research",
27
+ "Programming Language :: C",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Topic :: Scientific/Engineering",
31
+ "Topic :: Database"
32
+ ]
33
+
34
+ dependencies = []
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/suboty/demantoid"
38
+ Repository = "https://github.com/suboty/demantoid"
39
+ Issues = "https://github.com/suboty/demantoid/issues"
40
+
41
+ [project.optional-dependencies]
42
+ examples = [
43
+ "thefittest",
44
+ "numpy",
45
+ "matplotlib"
46
+ ]
47
+
48
+ [tool.poetry]
49
+ packages = [
50
+ {include = "demantoid"}
51
+ ]
52
+
53
+ [build-system]
54
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
55
+ build-backend = "poetry.core.masonry.api"