Skip to content

Commit 06aa6dd

Browse files
authored
Feature/cleanup packaging (#50)
* fix license in pyproject.toml * add temporary script (before creating GH action) * src is not a package * add variants of venv to .gitignore * revert most of 382f374 * move agrirouter/ to src/agrirouter/ * remove all imports from root __init__ for a clean start * re-add agrirouter package reference to test imports * fix some reverting issues * fix imports in tests * fix import path * fix header encoding for Python >= 3.8 * fix imports and linting * add Python 3.12 to linting and add internal tests to CI * add manual trigger for integration tests, including version selection * also need to install requirements, module alone is not enough * remove upper Python version boundary * explicitly list client side requirements * update flake8 version in requirements * clean up some requirements * clean up some requirements * clean up some requirements * final requirements fix :) * ignore E721 (type checking) for flake8 * add JUnit-style test output & report * beautify check names for test reports
1 parent c713cf0 commit 06aa6dd

91 files changed

Lines changed: 801 additions & 895 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/continuous-integration.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ name: Continuous Integration
66
on:
77
push:
88
branches: [ main ]
9+
workflow_dispatch:
10+
inputs:
11+
python-version:
12+
description: 'Python versions'
13+
required: true
14+
default: '["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]'
915

1016
jobs:
1117
build:
@@ -15,7 +21,7 @@ jobs:
1521
max-parallel: 1
1622
fail-fast: false
1723
matrix:
18-
python-version: [ "3.11" ]
24+
python-version: ${{ github.event_name == 'push' && '3.11' || fromJson(github.event.inputs.python-version) }}
1925

2026
steps:
2127
- uses: actions/checkout@v4
@@ -27,12 +33,21 @@ jobs:
2733
run: |
2834
python -m pip install --upgrade pip
2935
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
36+
pip install -e .
3037
- name: Lint with flake8
3138
run: |
3239
flake8 .
3340
- name: Test with pytest
3441
run: |
35-
pytest
42+
pytest --junitxml=junit/test-results.xml
3643
- name: Dry run building the wheel
3744
run: |
3845
python -m build --sdist --wheel
46+
- name: Publish Test Report
47+
uses: mikepenz/action-junit-report@v4
48+
if: success() || failure()
49+
with:
50+
check_name: "Test Report (${{ matrix.python-version }})"
51+
report_paths: 'junit/test-results.xml'
52+
detailed_summary: true
53+
include_passed: true

.github/workflows/linting-for-all-versions.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Continuous Integration
4+
name: Linting & Internal tests for all versions
55

66
on:
77
push:
@@ -17,7 +17,7 @@ jobs:
1717
max-parallel: 1
1818
fail-fast: false
1919
matrix:
20-
python-version: [ "3.7","3.8", "3.9", "3.10", "3.11" ]
20+
python-version: [ "3.7","3.8", "3.9", "3.10", "3.11", "3.12" ]
2121

2222
steps:
2323
- uses: actions/checkout@v4
@@ -29,9 +29,21 @@ jobs:
2929
run: |
3030
python -m pip install --upgrade pip
3131
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32+
pip install -e .
3233
- name: Lint with flake8
3334
run: |
3435
flake8 .
36+
- name: Run internal tests
37+
run: |
38+
pytest tests/agrirouter/internal --junitxml=junit/test-results.xml
3539
- name: Dry run building the wheel
3640
run: |
3741
python -m build --sdist --wheel
42+
- name: Publish Test Report
43+
uses: mikepenz/action-junit-report@v4
44+
if: success() || failure()
45+
with:
46+
check_name: "Test Report (${{ matrix.python-version }})"
47+
report_paths: 'junit/test-results.xml'
48+
detailed_summary: true
49+
include_passed: true

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
build
22
dist
3+
34
venv
5+
env
6+
virtualenv
7+
48
.idea
59
**/__pycache__
610
*.egg-info
@@ -10,6 +14,5 @@ venv
1014
.pytest_cache
1115
/paho/
1216
/paho_mqtt-1.6.1.dist-info/
13-
agrirouter.egg-info/
14-
build/
15-
dist/
17+
/paho/
18+
/paho_mqtt-1.6.1.dist-info/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![agrirouter logo](./assets/images/agrirouter.svg)
1+
<img src="https://files.my-agrirouter.com/agrirouter_logo.svg" height="100" />
22

33
# About the project
44

example_script.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import time
2+
import agrirouter as ar
3+
from agrirouter.onboarding.enums import Gateways
4+
from agrirouter.generated.messaging.request.payload.endpoint.subscription_pb2 import Subscription
5+
from agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification
6+
from agrirouter.messaging.services.commons import HttpMessagingService, MqttMessagingService
7+
from agrirouter.utils.uuid_util import new_uuid
28

39
from google.protobuf.timestamp_pb2 import Timestamp
410

5-
from src.agrirouter.generated.messaging.request.payload.account.endpoints_pb2 import ListEndpointsQuery
6-
from src.agrirouter.generated.messaging.request.payload.feed.feed_requests_pb2 import ValidityPeriod
7-
from src.agrirouter.onboarding.response import OnboardResponse
11+
from agrirouter.generated.messaging.request.payload.account.endpoints_pb2 import ListEndpointsQuery
12+
from agrirouter.generated.messaging.request.payload.feed.feed_requests_pb2 import ValidityPeriod
13+
from agrirouter.onboarding.response import OnboardResponse
814

915
public_key = """-----BEGIN PUBLIC KEY-----
1016
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzGt41/+kSOTlO1sJvLIN
@@ -64,15 +70,6 @@
6470
}
6571
}
6672

67-
import src as ar
68-
from src.agrirouter.onboarding.enums import Gateways
69-
from src.agrirouter.api.enums import CapabilityType
70-
from src.agrirouter.generated.messaging.request.payload.endpoint.subscription_pb2 import Subscription
71-
from src.agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification
72-
from src.agrirouter.messaging.services.commons import HttpMessagingService, MqttMessagingService
73-
from src import ListEndpointsParameters, ListEndpointsService, SubscriptionService, SubscriptionParameters, \
74-
QueryHeaderService, QueryHeaderParameters, CapabilitiesService, CapabilitiesParameters
75-
from src.agrirouter.utils.uuid_util import new_uuid
7673

7774
application_id = "8c947a45-c57d-42d2-affc-206e21d63a50" # # store here your application id. You can find it in AR UI
7875
certification_version_id = "edd5d6b7-45bb-4471-898e-ff9c2a7bf56f" # # store here your certification version id. You can find it in AR UI
@@ -298,9 +295,9 @@ def example_query_header_message_mqtt(onboarding_response_data, on_msg_callback)
298295
def on_message_callback(client, userdata, msg):
299296
# Define here the way receiving messages will be processed
300297

301-
from src.agrirouter.messaging.decode import decode_response
302-
from src.agrirouter.messaging.decode import decode_details
303-
from src.agrirouter.messaging.messages import OutboxMessage
298+
from agrirouter.messaging.decode import decode_response
299+
from agrirouter.messaging.decode import decode_details
300+
from agrirouter.messaging.messages import OutboxMessage
304301

305302
outbox_message = OutboxMessage()
306303
outbox_message.json_deserialize(msg.payload.decode().replace("'", '"'))

examples.txt

Lines changed: 0 additions & 154 deletions
This file was deleted.

pyproject.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
[project]
22
name = "agrirouter"
3-
version = "2.0.0"
3+
version = "2.0.0b1"
44
description = "Python SDK for the agrirouter API. This project contains the API for the communication with the agrirouter. Everything you need for the onboarding process, secure communication and much more."
55
authors = [
66
{ name = "Alexey Petrovsky", email = "petrovsky.lexey@gmail.com" },
77
{ name = "Oliver Rahner", email = "o.rahner@dke-data.com" },
88
{ name = "Sascha Dömer", email = "Cf4ThQgxcnxAovOUXTNv@saschadoemer.de" },
99
]
1010
readme = "README.md"
11-
requires-python = ">=3.7, <=3.11"
11+
requires-python = ">=3.7" # no upper boundary according to https://discuss.python.org/t/requires-python-upper-limits/12663
1212
urls = { "Source" = "https://github.com/DKE-Data/agrirouter-sdk-python" }
1313
classifiers = [
1414
"Intended Audience :: Developers",
15-
"License :: Apache License 2.0",
15+
"License :: OSI Approved :: Apache Software License",
1616
"Programming Language :: Python :: 3.7",
1717
"Programming Language :: Python :: 3.8",
1818
"Programming Language :: Python :: 3.9",
1919
"Programming Language :: Python :: 3.10",
2020
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
2122
"Topic :: Software Development :: Libraries",
2223
"Topic :: Software Development :: Libraries :: Python Modules"
2324
]
25+
dependencies = [
26+
"requests",
27+
"protobuf~=3.18.0"
28+
]
2429

2530
[build-system]
2631
requires = ["setuptools", "wheel"]
File renamed without changes.

requirements.txt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
pytest==6.2.5
2-
black==21.9b0
3-
flake8==3.9.2
4-
pyflakes==2.3.1
1+
2+
pytest~=8.1.1; python_version >= "3.8"
3+
pytest~=7.4.4; python_version <= "3.7"
4+
build~=1.2.1; python_version >= "3.8"
5+
build~=0.10.0; python_version <= "3.7"
6+
flake8~=7.0.0; python_version >= "3.8"
7+
flake8~=5.0.4; python_version <= "3.7"
8+
59
cryptography~=3.4.8
610
setuptools~=68.0.0
7-
pycparser~=2.20
8-
idna~=3.2
9-
urllib3~=1.26.18
10-
certifi~=2023.7.22
1111
requests~=2.31.0
1212
paho-mqtt~=1.5.1
1313
protobuf~=3.18.0
1414
google~=3.0.0
1515
toml~=0.10.2
16-
build~=1.1.1
17-
importlib-metadata<5.0

src/agrirouter/api/enums.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class ContentTypes(BaseEnum):
2020
APPLICATION_JSON = "application/json"
2121

2222

23+
class Environments(BaseEnum):
24+
PRODUCTION: str = "production"
25+
QA: str = "qa"
26+
27+
2328
class RequestHeaders(BaseEnum):
2429
AUTHORIZATION: str = "Authorization"
2530
X_AGRIROUTER_SIGNATURE: str = "X-Agrirouter-Signature"

0 commit comments

Comments
 (0)