Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ __pypackages__/
# Test output
test-output.xml

# Poetry
poetry.lock

# VS Code
.vscode/

Expand Down
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 29 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
[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 <omniaindiot@equinor.com>"]
license = "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]
pre-commit = ">=3.0.0,<5.0.0"
black = ">=22.0,<26.0"

[project.urls]
[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"
8 changes: 4 additions & 4 deletions src/omnia_timeseries/http_client.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -31,7 +31,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]:

Expand All @@ -40,7 +40,7 @@ def _request(
)
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
Expand All @@ -56,7 +56,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:

Expand Down