Python package providing an interface to the Gantner Instruments Data API
Project description
pygidata
Usage
Install from PyPi
pip install pygidata
Import module in python script and call functions.
A detailed description of the package and other APIs can be found under docs/ or in the Gantner Documentation.
from gi_data.dataclient import GIDataClient
import os
PROFILES = {
"qstation": {
"base": os.getenv("GI_QSTATION_BASE", "http://10.1.50.36:8090"),
"auth": {"username": os.getenv("GI_QSTATION_USER", "admin"),
"password": os.getenv("GI_QSTATION_PASS", "admin")},
},
"cloud": {
"base": os.getenv("GI_CLOUD_BASE", "https://demo.gi-cloud.io"),
"auth": {"access_token": os.getenv("GI_CLOUD_TOKEN", "")},
},
}
ACTIVE_PROFILE = os.getenv("GI_PROFILE", "qstation")
def get_client(profile: str = ACTIVE_PROFILE) -> GIDataClient:
cfg = PROFILES[profile]
if cfg["auth"].get("access_token"):
return GIDataClient(cfg["base"], access_token=cfg["auth"]["access_token"])
return GIDataClient(cfg["base"],
username=cfg["auth"].get("username"),
password=cfg["auth"].get("password"))
client = get_client()
Development
Used as submodule in
- gi-sphinx
- gi-jupyterlab
- gi-analytics-examples
Information on how to manually distribute this package can be found here
https://packaging.python.org/en/latest/tutorials/packaging-projects/
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.
%load_ext autoreload
%autoreload 2
Distribute with CI / CD
Edit pyproject.toml version number and create a release. -> Creating a release will trigger the workflow to push the package to PyPi
Tests
run tests locally:
pipenv run test -v
or
pytest
Generate loose requirements
Do this in a bash shell using the lowest version you want to support!
Install uv to easily install all needed python versions (coss-platform)
pip install uv
python -m pip install -U pip tox
python -m pip install pip-tools
python -m pip install pipreqs
To ensure we support multiple python versions we don't want to pin every dependency. Instead, we pin everything on the lowest version (that we support) and make it loose for every version above.
from root package dir (/gimodules-python)
./gen-requirements.sh
Ensure python-package version compatibility
uv python install 3.10 3.11 3.12 3.13 3.14
Now run for all envs
tox
of for a specific version only -> look what you defined in pyproject.toml
tox -e py310
NOTE: Remove the old gimodules version from requirements.txt before pushing (dependency conflict).
Documentation
The documentation is being built as extern script in the GI.Sphinx repository.
The documentation consists of partially generated content. To generate .rst files from the code package, run the following command from the root directory of the project:
sphinx-apidoc -o docs/source/ src
You need pandoc installed on the system itself first to build:
sudo apt install pandoc
Then, to build the documentation, run the following commands:
cd docs
sudo apt update
pip install -r requirements.txt
make html
Linting / Type hints
This project follows the codestyle PEP8 and uses the linter flake8 (with line length = 100).
You can format and check the code using lint.sh:
./lint.sh [directory/]
Type hints are highly recommended. Type hints in Python specify the expected data types of variables, function arguments, and return values, improving code readability, catching errors early, and aiding in IDE autocompletion.
To include type hints in the check:
mpypy=true ./lint.sh [directory])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygidata-0.4.1.tar.gz.
File metadata
- Download URL: pygidata-0.4.1.tar.gz
- Upload date:
- Size: 24.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea18e9a23ead8056f9b066351d3cfc98dbfdd036485fc4986bfe712b70542149
|
|
| MD5 |
66ab977d10c982b35f0b0b87b0504540
|
|
| BLAKE2b-256 |
f4cd5df4be348910529f97e52ea9d932bf1f56951a94cbf34d071e0ce7616dc6
|
File details
Details for the file pygidata-0.4.1-py3-none-any.whl.
File metadata
- Download URL: pygidata-0.4.1-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26118b4e7dd21c78bffcc7ccf59c3029697c5753d907c9a934b0442dccc9f85b
|
|
| MD5 |
fa3b22f25ef32a04d79f10c7e0f044de
|
|
| BLAKE2b-256 |
d479bdb8b7d4b4884e54af6f38689170d650531154cb0c0dfbb8965450bb7edb
|