pygidata 0.4.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. pygidata-0.4.1/LICENSE +21 -0
  2. pygidata-0.4.1/PKG-INFO +212 -0
  3. pygidata-0.4.1/README.md +183 -0
  4. pygidata-0.4.1/pyproject.toml +49 -0
  5. pygidata-0.4.1/requirements.txt +7 -0
  6. pygidata-0.4.1/setup.cfg +4 -0
  7. pygidata-0.4.1/src/gi_data/__init__.py +3 -0
  8. pygidata-0.4.1/src/gi_data/dataclient.py +378 -0
  9. pygidata-0.4.1/src/gi_data/drivers/__init__.py +0 -0
  10. pygidata-0.4.1/src/gi_data/drivers/base.py +114 -0
  11. pygidata-0.4.1/src/gi_data/drivers/cloud_gql.py +545 -0
  12. pygidata-0.4.1/src/gi_data/drivers/kafka_stream.py +95 -0
  13. pygidata-0.4.1/src/gi_data/drivers/local_http.py +284 -0
  14. pygidata-0.4.1/src/gi_data/drivers/ws_stream.py +137 -0
  15. pygidata-0.4.1/src/gi_data/infra/__init__.py +0 -0
  16. pygidata-0.4.1/src/gi_data/infra/auth.py +132 -0
  17. pygidata-0.4.1/src/gi_data/infra/http.py +195 -0
  18. pygidata-0.4.1/src/gi_data/infra/ws.py +92 -0
  19. pygidata-0.4.1/src/gi_data/mapping/__init__.py +0 -0
  20. pygidata-0.4.1/src/gi_data/mapping/enums.py +37 -0
  21. pygidata-0.4.1/src/gi_data/mapping/models.py +264 -0
  22. pygidata-0.4.1/src/gi_data/utils/__init__.py +0 -0
  23. pygidata-0.4.1/src/gi_data/utils/logging.py +37 -0
  24. pygidata-0.4.1/src/gi_data/ws/__init__.py +0 -0
  25. pygidata-0.4.1/src/gi_data/ws/enums.py +34 -0
  26. pygidata-0.4.1/src/pygidata.egg-info/PKG-INFO +212 -0
  27. pygidata-0.4.1/src/pygidata.egg-info/SOURCES.txt +29 -0
  28. pygidata-0.4.1/src/pygidata.egg-info/dependency_links.txt +1 -0
  29. pygidata-0.4.1/src/pygidata.egg-info/requires.txt +11 -0
  30. pygidata-0.4.1/src/pygidata.egg-info/top_level.txt +1 -0
  31. pygidata-0.4.1/tests/test_dummy.py +26 -0
pygidata-0.4.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Gantner Instruments GmbH. All rights reserved.
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,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: pygidata
3
+ Version: 0.4.1
4
+ Summary: Python package providing an interface to the Gantner Instruments Data API
5
+ Author: Gantner Instruments GmbH
6
+ Keywords: python
7
+ Classifier: Development Status :: 1 - Planning
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Operating System :: Unix
13
+ Classifier: Operating System :: MacOS :: MacOS X
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Requires-Python: <3.13,>=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: aiokafka
19
+ Requires-Dist: certifi
20
+ Requires-Dist: httpx
21
+ Requires-Dist: nest_asyncio
22
+ Requires-Dist: pandas
23
+ Requires-Dist: pydantic
24
+ Requires-Dist: websockets
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest; extra == "test"
27
+ Requires-Dist: pytest-xdist; extra == "test"
28
+ Dynamic: license-file
29
+
30
+ # pygidata
31
+
32
+ # Usage
33
+
34
+ ### Install from PyPi
35
+
36
+ ```bash
37
+ pip install pygidata
38
+ ```
39
+
40
+ Import module in python script and call functions.
41
+
42
+ A detailed description of the package and other APIs can be found under [docs/](docs/Usage.ipynb) or in the
43
+ Gantner Documentation.
44
+
45
+ ```python
46
+ from gi_data.dataclient import GIDataClient
47
+ import os
48
+
49
+ PROFILES = {
50
+ "qstation": {
51
+ "base": os.getenv("GI_QSTATION_BASE", "http://10.1.50.36:8090"),
52
+ "auth": {"username": os.getenv("GI_QSTATION_USER", "admin"),
53
+ "password": os.getenv("GI_QSTATION_PASS", "admin")},
54
+ },
55
+ "cloud": {
56
+ "base": os.getenv("GI_CLOUD_BASE", "https://demo.gi-cloud.io"),
57
+ "auth": {"access_token": os.getenv("GI_CLOUD_TOKEN", "")},
58
+ },
59
+ }
60
+
61
+ ACTIVE_PROFILE = os.getenv("GI_PROFILE", "qstation")
62
+
63
+ def get_client(profile: str = ACTIVE_PROFILE) -> GIDataClient:
64
+ cfg = PROFILES[profile]
65
+ if cfg["auth"].get("access_token"):
66
+ return GIDataClient(cfg["base"], access_token=cfg["auth"]["access_token"])
67
+ return GIDataClient(cfg["base"],
68
+ username=cfg["auth"].get("username"),
69
+ password=cfg["auth"].get("password"))
70
+
71
+ client = get_client()
72
+
73
+ ```
74
+
75
+
76
+ # Development
77
+
78
+ ### Used as submodule in
79
+ * gi-sphinx
80
+ * gi-jupyterlab
81
+ * gi-analytics-examples
82
+
83
+ ### Information on how to manually distribute this package can be found here
84
+
85
+ https://packaging.python.org/en/latest/tutorials/packaging-projects/
86
+
87
+ **Hint:** If you are debugging the source code with a jupyter notebook, run this code in the `first cell` to enable autoreloading source code changes.
88
+
89
+ ```bash
90
+ %load_ext autoreload
91
+ %autoreload 2
92
+ ```
93
+
94
+ ## Distribute with CI / CD
95
+
96
+ Edit pyproject.toml version number and create a release.
97
+ -> Creating a release will trigger the workflow to push the package to PyPi
98
+
99
+ ## Tests
100
+
101
+ run tests locally:
102
+
103
+ ```bash
104
+ pipenv run test -v
105
+ ```
106
+
107
+ or
108
+
109
+ ```bash
110
+ pytest
111
+ ```
112
+
113
+ ### Generate loose requirements
114
+
115
+ **Do this in a bash shell using the lowest version you want to support!**
116
+
117
+ Install uv to easily install all needed python versions (coss-platform)
118
+
119
+ ``` bash
120
+ pip install uv
121
+ ```
122
+
123
+ ```bash
124
+ python -m pip install -U pip tox
125
+ ```
126
+
127
+ ```bash
128
+ python -m pip install pip-tools
129
+ ```
130
+ ```bash
131
+ python -m pip install pipreqs
132
+ ```
133
+
134
+
135
+ To ensure we support multiple python versions we don't want to pin every dependency.
136
+ Instead, we pin everything on the lowest version (that we support) and make
137
+ it loose for every version above.
138
+
139
+ from root package dir (/gimodules-python)
140
+
141
+ ```bash
142
+ ./gen-requirements.sh
143
+ ```
144
+
145
+ #### Ensure python-package version compatibility
146
+
147
+ ```bash
148
+ uv python install 3.10 3.11 3.12 3.13 3.14
149
+ ```
150
+
151
+ Now run for all envs
152
+
153
+ ```bash
154
+ tox
155
+ ```
156
+
157
+ of for a specific version only -> look what you defined in pyproject.toml
158
+
159
+ ```bash
160
+ tox -e py310
161
+ ```
162
+ ---
163
+
164
+ **_NOTE:_** Remove the old gimodules version from requirements.txt before pushing (dependency conflict).
165
+
166
+ ---
167
+
168
+ ## Documentation
169
+
170
+ The documentation is being built as extern script in the GI.Sphinx repository.
171
+
172
+ The documentation consists of partially generated content.
173
+ To **generate .rst files** from the code package, run the following command from the root directory of the project:
174
+
175
+ ```bash
176
+ sphinx-apidoc -o docs/source/ src
177
+ ```
178
+ You need pandoc installed on the system itself first to build:
179
+
180
+ ```bash
181
+ sudo apt install pandoc
182
+ ```
183
+
184
+ Then, to **build the documentation**, run the following commands:
185
+
186
+ ```bash
187
+ cd docs
188
+ sudo apt update
189
+ pip install -r requirements.txt
190
+ make html
191
+ ```
192
+
193
+ ## Linting / Type hints
194
+
195
+ This project follows the codestyle PEP8 and uses the linter flake8 (with line length = 100).
196
+
197
+ You can format and check the code using lint.sh:
198
+
199
+ ```bash
200
+ ./lint.sh [directory/]
201
+ ```
202
+
203
+ Type hints are highly recommended.
204
+ Type hints in Python specify the expected data types of variables,
205
+ function arguments, and return values, improving code readability,
206
+ catching errors early, and aiding in IDE autocompletion.
207
+
208
+ To include type hints in the check:
209
+
210
+ ```bash
211
+ mpypy=true ./lint.sh [directory])
212
+ ```
@@ -0,0 +1,183 @@
1
+ # pygidata
2
+
3
+ # Usage
4
+
5
+ ### Install from PyPi
6
+
7
+ ```bash
8
+ pip install pygidata
9
+ ```
10
+
11
+ Import module in python script and call functions.
12
+
13
+ A detailed description of the package and other APIs can be found under [docs/](docs/Usage.ipynb) or in the
14
+ Gantner Documentation.
15
+
16
+ ```python
17
+ from gi_data.dataclient import GIDataClient
18
+ import os
19
+
20
+ PROFILES = {
21
+ "qstation": {
22
+ "base": os.getenv("GI_QSTATION_BASE", "http://10.1.50.36:8090"),
23
+ "auth": {"username": os.getenv("GI_QSTATION_USER", "admin"),
24
+ "password": os.getenv("GI_QSTATION_PASS", "admin")},
25
+ },
26
+ "cloud": {
27
+ "base": os.getenv("GI_CLOUD_BASE", "https://demo.gi-cloud.io"),
28
+ "auth": {"access_token": os.getenv("GI_CLOUD_TOKEN", "")},
29
+ },
30
+ }
31
+
32
+ ACTIVE_PROFILE = os.getenv("GI_PROFILE", "qstation")
33
+
34
+ def get_client(profile: str = ACTIVE_PROFILE) -> GIDataClient:
35
+ cfg = PROFILES[profile]
36
+ if cfg["auth"].get("access_token"):
37
+ return GIDataClient(cfg["base"], access_token=cfg["auth"]["access_token"])
38
+ return GIDataClient(cfg["base"],
39
+ username=cfg["auth"].get("username"),
40
+ password=cfg["auth"].get("password"))
41
+
42
+ client = get_client()
43
+
44
+ ```
45
+
46
+
47
+ # Development
48
+
49
+ ### Used as submodule in
50
+ * gi-sphinx
51
+ * gi-jupyterlab
52
+ * gi-analytics-examples
53
+
54
+ ### Information on how to manually distribute this package can be found here
55
+
56
+ https://packaging.python.org/en/latest/tutorials/packaging-projects/
57
+
58
+ **Hint:** If you are debugging the source code with a jupyter notebook, run this code in the `first cell` to enable autoreloading source code changes.
59
+
60
+ ```bash
61
+ %load_ext autoreload
62
+ %autoreload 2
63
+ ```
64
+
65
+ ## Distribute with CI / CD
66
+
67
+ Edit pyproject.toml version number and create a release.
68
+ -> Creating a release will trigger the workflow to push the package to PyPi
69
+
70
+ ## Tests
71
+
72
+ run tests locally:
73
+
74
+ ```bash
75
+ pipenv run test -v
76
+ ```
77
+
78
+ or
79
+
80
+ ```bash
81
+ pytest
82
+ ```
83
+
84
+ ### Generate loose requirements
85
+
86
+ **Do this in a bash shell using the lowest version you want to support!**
87
+
88
+ Install uv to easily install all needed python versions (coss-platform)
89
+
90
+ ``` bash
91
+ pip install uv
92
+ ```
93
+
94
+ ```bash
95
+ python -m pip install -U pip tox
96
+ ```
97
+
98
+ ```bash
99
+ python -m pip install pip-tools
100
+ ```
101
+ ```bash
102
+ python -m pip install pipreqs
103
+ ```
104
+
105
+
106
+ To ensure we support multiple python versions we don't want to pin every dependency.
107
+ Instead, we pin everything on the lowest version (that we support) and make
108
+ it loose for every version above.
109
+
110
+ from root package dir (/gimodules-python)
111
+
112
+ ```bash
113
+ ./gen-requirements.sh
114
+ ```
115
+
116
+ #### Ensure python-package version compatibility
117
+
118
+ ```bash
119
+ uv python install 3.10 3.11 3.12 3.13 3.14
120
+ ```
121
+
122
+ Now run for all envs
123
+
124
+ ```bash
125
+ tox
126
+ ```
127
+
128
+ of for a specific version only -> look what you defined in pyproject.toml
129
+
130
+ ```bash
131
+ tox -e py310
132
+ ```
133
+ ---
134
+
135
+ **_NOTE:_** Remove the old gimodules version from requirements.txt before pushing (dependency conflict).
136
+
137
+ ---
138
+
139
+ ## Documentation
140
+
141
+ The documentation is being built as extern script in the GI.Sphinx repository.
142
+
143
+ The documentation consists of partially generated content.
144
+ To **generate .rst files** from the code package, run the following command from the root directory of the project:
145
+
146
+ ```bash
147
+ sphinx-apidoc -o docs/source/ src
148
+ ```
149
+ You need pandoc installed on the system itself first to build:
150
+
151
+ ```bash
152
+ sudo apt install pandoc
153
+ ```
154
+
155
+ Then, to **build the documentation**, run the following commands:
156
+
157
+ ```bash
158
+ cd docs
159
+ sudo apt update
160
+ pip install -r requirements.txt
161
+ make html
162
+ ```
163
+
164
+ ## Linting / Type hints
165
+
166
+ This project follows the codestyle PEP8 and uses the linter flake8 (with line length = 100).
167
+
168
+ You can format and check the code using lint.sh:
169
+
170
+ ```bash
171
+ ./lint.sh [directory/]
172
+ ```
173
+
174
+ Type hints are highly recommended.
175
+ Type hints in Python specify the expected data types of variables,
176
+ function arguments, and return values, improving code readability,
177
+ catching errors early, and aiding in IDE autocompletion.
178
+
179
+ To include type hints in the check:
180
+
181
+ ```bash
182
+ mpypy=true ./lint.sh [directory])
183
+ ```
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pygidata"
7
+ version = "0.4.1"
8
+ description = "Python package providing an interface to the Gantner Instruments Data API"
9
+ readme = "README.md"
10
+ authors = [{ name = "Gantner Instruments GmbH" }]
11
+ requires-python = ">=3.10,<3.13"
12
+ keywords = ["python"]
13
+ classifiers = [
14
+ "Development Status :: 1 - Planning",
15
+ "Intended Audience :: Developers",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Operating System :: Unix",
20
+ "Operating System :: MacOS :: MacOS X",
21
+ "Operating System :: Microsoft :: Windows"
22
+ ]
23
+ dynamic = ["dependencies"]
24
+
25
+ [tool.setuptools]
26
+ include-package-data = true
27
+
28
+ [tool.setuptools.packages.find]
29
+ where = ["src"]
30
+ include = ["gi_data*"]
31
+
32
+ [tool.setuptools.dynamic]
33
+ dependencies = { file = ["requirements.txt"] }
34
+
35
+ [project.optional-dependencies]
36
+ test = ["pytest", "pytest-xdist"]
37
+
38
+ [tool.tox]
39
+ env_list = ["py310", "py311", "py312"]
40
+
41
+ [tool.tox.env_run_base]
42
+ deps = [
43
+ "pytest>=7",
44
+ "pytest-xdist",
45
+ ]
46
+ commands = [
47
+ ["pytest", "-q"]
48
+ ]
49
+ package = "wheel"
@@ -0,0 +1,7 @@
1
+ aiokafka
2
+ certifi
3
+ httpx
4
+ nest_asyncio
5
+ pandas
6
+ pydantic
7
+ websockets
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .dataclient import GIDataClient
2
+
3
+ __all__: list[str] = ["GIDataClient"]