From f0c28bb6b85f1d20303bf769603acdf09d6c91ce Mon Sep 17 00:00:00 2001 From: franktore Date: Fri, 5 Dec 2025 08:59:29 +0100 Subject: [PATCH 1/6] update opentelemetry-instrumentation-requests requirement to >=0.54b1. cleaner pyproject.toml --- .gitignore | 3 +++ pyproject.toml | 32 +++++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 201b91a..ed6d915 100644 --- a/.gitignore +++ b/.gitignore @@ -97,6 +97,9 @@ __pypackages__/ # Test output test-output.xml +# Poetry +poetry.lock + # VS Code .vscode/ diff --git a/pyproject.toml b/pyproject.toml index 98012e3..a86cfe3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,30 +1,28 @@ -[project] +[tool.poetry] name = "omnia_timeseries" version = "1.3.13" -authors = [ - { name = "Equinor Omnia Industrial IoT Team", email = "omniaindiot@equinor.com" } -] description = "Official Python SDK for the Omnia Timeseries API" readme = "README.md" -requires-python = ">=3.8,<4.0" +authors = ["Equinor Omnia Industrial IoT Team "] +license = { file = "LICENSE" } -dependencies =[ -"requests", -"azure-identity >=1.19.0", -"azure-core", -"opentelemetry-instrumentation-requests >=0.48b0,<1.0.0", -"opentelemetry-api >=1.27.0,<2.0.0", -"cryptography >=43.0.1", -"pyjwt >=2.9.0" -] +[tool.poetry.dependencies] +python = ">=3.8,<4.0" +requests = ">=2.28.0,<3.0.0" +azure-identity = ">=1.19.0,<2.0.0" +azure-core = ">=1.30.0,<2.0.0" +opentelemetry-instrumentation-requests = ">=0.54b1,<1.0.0" +opentelemetry-api = ">=1.27.0,<2.0.0" +cryptography = ">=43.0.1,<45.0.0" +pyjwt = ">=2.9.0,<3.0.0" [tool.poetry.group.test.dependencies] -pytest = "*" -requests-mock = "*" +pytest = ">=7.4.0,<8.0.0" +requests-mock = ">=1.9.0,<2.0.0" [tool.poetry.group.dev.dependencies] -[project.urls] +[tool.poetry.urls] repository = "https://github.com/equinor/omnia-timeseries-python" [build-system] From 139abfdb1f5917ed266a19ad108867aaa4b500ff Mon Sep 17 00:00:00 2001 From: franktore Date: Fri, 5 Dec 2025 12:02:39 +0100 Subject: [PATCH 2/6] fix .toml file reference. modify method args type-info --- pyproject.toml | 2 +- src/omnia_timeseries/http_client.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a86cfe3..ee8a612 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ version = "1.3.13" description = "Official Python SDK for the Omnia Timeseries API" readme = "README.md" authors = ["Equinor Omnia Industrial IoT Team "] -license = { file = "LICENSE" } +license = "LICENSE" [tool.poetry.dependencies] python = ">=3.8,<4.0" diff --git a/src/omnia_timeseries/http_client.py b/src/omnia_timeseries/http_client.py index f1587fc..41e301a 100644 --- a/src/omnia_timeseries/http_client.py +++ b/src/omnia_timeseries/http_client.py @@ -1,4 +1,4 @@ -from typing import Literal, Optional, TypedDict, Union, Dict, Any +from typing import Literal, List, Optional, Union, Dict, Any from azure.identity._internal.msal_credentials import MsalCredential import requests import logging @@ -26,7 +26,7 @@ def _request( request_type: RequestType, url: str, headers: Dict[str, Any], - payload: Optional[Union[TypedDict, dict, list]] = None, + payload: Optional[Union[Dict, Dict, List]] = None, params: Optional[Dict[str, Any]] = None ) -> Union[Dict[str, Any], bytes]: @@ -34,7 +34,7 @@ def _request( request_type, url, headers=headers, json=payload, params=params) if not response.ok: raise TimeseriesRequestFailedException(response) - if not "Accept" in headers or headers["Accept"] == "application/json": + if "Accept" not in headers or headers["Accept"] == "application/json": return response.json() else: return response.content @@ -50,7 +50,7 @@ def request( request_type: RequestType, url: str, accept: ContentType = "application/json", - payload: Optional[Union[TypedDict, dict, list]] = None, + payload: Optional[Union[Dict, Dict, List]] = None, params: Optional[Dict[str, Any]] = None ) -> Any: From 93d20b8ee8425d89f93ee4d6e0c502c4bad6a6c0 Mon Sep 17 00:00:00 2001 From: franktore Date: Fri, 5 Dec 2025 12:23:09 +0100 Subject: [PATCH 3/6] add pre-commit hook. add black dependency and configuration --- .pre-commit-config.yaml | 5 +++++ pyproject.toml | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..77a8ee3 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: + - repo: https://github.com/pre-commit/mirrors-black + rev: v24.8.0 + hooks: + - id: black diff --git a/pyproject.toml b/pyproject.toml index ee8a612..e4c07d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,10 +21,24 @@ pytest = ">=7.4.0,<8.0.0" requests-mock = ">=1.9.0,<2.0.0" [tool.poetry.group.dev.dependencies] +pre-commit = ">=3.0.0,<5.0.0" +black = ">=22.0,<26.0" [tool.poetry.urls] repository = "https://github.com/equinor/omnia-timeseries-python" +[tool.black] +line-length = 88 +target-version = ['py39'] +include = '\.pyi?$' +exclude = '^/src/version.py' +extend-exclude = ''' +( +^/foo.py +| .*_pb2.py +) +''' + [build-system] requires = ["poetry-core>=2.0,<3.0"] build-backend = "poetry.core.masonry.api" From 7d28786d82aedd4f760a4bf0785eb4c36f63d34b Mon Sep 17 00:00:00 2001 From: franktore Date: Fri, 5 Dec 2025 12:28:15 +0100 Subject: [PATCH 4/6] fix black version --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 77a8ee3..6b9e556 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ repos: - - repo: https://github.com/pre-commit/mirrors-black - rev: v24.8.0 + - repo: https://github.com/psf/black + rev: 24.8.0 hooks: - id: black From ecad4806e354ae2d65e162b22f346fad922fc389 Mon Sep 17 00:00:00 2001 From: franktore Date: Fri, 5 Dec 2025 12:36:57 +0100 Subject: [PATCH 5/6] update contribution guidelines --- CONTRIBUTING.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22424ad..427aa72 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,12 @@ Here are some resources to help you get started with open source contributions: ### Contribution guidelines ### -* Create new branch from develop +* Clone the repository or Create new branch from develop +* Navigate to the project root directory +* Setup pre-commit hook + * poetry install - Installs all dependencies, including pre-commit + * poetry run pre-commit install - Installs pre-commit hooks +* Write code * Write tests * Create a PR * Code review From 4a1bc06a9bab27ba0f4b23c70c91b8238aa5d453 Mon Sep 17 00:00:00 2001 From: franktore Date: Fri, 5 Dec 2025 13:24:52 +0100 Subject: [PATCH 6/6] update deploy workflow to use poetry for installation --- .github/workflows/deploy.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2bf0c2e..cf9056c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -61,11 +61,18 @@ jobs: python-version-file: 'pyproject.toml' cache: 'pip' + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + echo "$HOME/.local/bin" >> $GITHUB_PATH # Add Poetry to PATH + + - name: Install dependencies + run: | + poetry install --without dev --no-interaction --no-root + - name: Run tests run: | - pip install --upgrade pip - pip install -e . - python -m pytest + poetry run pytest # Use Poetry to run your tests build: needs: [detectenv, run-tests] @@ -82,11 +89,18 @@ jobs: python-version-file: 'pyproject.toml' cache: 'pip' + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + echo "$HOME/.local/bin" >> $GITHUB_PATH # Add Poetry to PATH + + - name: Install dependencies + run: | + poetry install --without dev,test --no-interaction --no-root # Install only main dependencies + - name: Build SDK run: | - pip install --upgrade pip - pip install -e . - python -m build + poetry build # Use Poetry to build the project - name: Release uses: ncipollo/release-action@v1