Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cleanup packaging #50

Merged
merged 26 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b930b0a
fix license in pyproject.toml
oliverrahner Apr 11, 2024
ed290d0
add temporary script (before creating GH action)
oliverrahner Apr 12, 2024
e990d12
src is not a package
oliverrahner Apr 12, 2024
a975051
add variants of venv to .gitignore
oliverrahner Apr 12, 2024
4a69948
revert most of 382f374
oliverrahner Apr 12, 2024
5151735
move agrirouter/ to src/agrirouter/
oliverrahner Apr 12, 2024
eb80d02
remove all imports from root __init__ for a clean start
oliverrahner Apr 12, 2024
afb2a5b
re-add agrirouter package reference to test imports
oliverrahner Apr 15, 2024
035002f
fix some reverting issues
oliverrahner Apr 15, 2024
5376d83
fix imports in tests
oliverrahner Apr 15, 2024
c7ca594
fix import path
oliverrahner Apr 16, 2024
710f634
fix header encoding for Python >= 3.8
oliverrahner Apr 16, 2024
55c8d92
fix imports and linting
oliverrahner Apr 16, 2024
7993bf5
add Python 3.12 to linting and add internal tests to CI
oliverrahner Apr 16, 2024
e0bc689
add manual trigger for integration tests, including version selection
oliverrahner Apr 16, 2024
800777b
also need to install requirements, module alone is not enough
oliverrahner Apr 16, 2024
903a6d3
remove upper Python version boundary
oliverrahner Apr 16, 2024
45ea5d5
explicitly list client side requirements
oliverrahner Apr 16, 2024
f6deaff
update flake8 version in requirements
oliverrahner Apr 16, 2024
afa7c4f
clean up some requirements
oliverrahner Apr 16, 2024
44c2cff
clean up some requirements
oliverrahner Apr 16, 2024
b355e21
clean up some requirements
oliverrahner Apr 16, 2024
35bc161
final requirements fix :)
oliverrahner Apr 16, 2024
bf791bb
ignore E721 (type checking) for flake8
oliverrahner Apr 16, 2024
3dc97a1
add JUnit-style test output & report
oliverrahner Apr 16, 2024
17936c5
beautify check names for test reports
oliverrahner Apr 16, 2024
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
19 changes: 17 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ name: Continuous Integration
on:
push:
branches: [ main ]
workflow_dispatch:
inputs:
python-version:
description: 'Python versions'
required: true
default: '["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]'

jobs:
build:
Expand All @@ -15,7 +21,7 @@ jobs:
max-parallel: 1
fail-fast: false
matrix:
python-version: [ "3.11" ]
python-version: ${{ github.event_name == 'push' && '3.11' || fromJson(github.event.inputs.python-version) }}

steps:
- uses: actions/checkout@v4
Expand All @@ -27,12 +33,21 @@ jobs:
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
- name: Lint with flake8
run: |
flake8 .
- name: Test with pytest
run: |
pytest
pytest --junitxml=junit/test-results.xml
- name: Dry run building the wheel
run: |
python -m build --sdist --wheel
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
check_name: "Test Report (${{ matrix.python-version }})"
report_paths: 'junit/test-results.xml'
detailed_summary: true
include_passed: true
16 changes: 14 additions & 2 deletions .github/workflows/linting-for-all-versions.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Continuous Integration
name: Linting & Internal tests for all versions

on:
push:
Expand All @@ -17,7 +17,7 @@ jobs:
max-parallel: 1
fail-fast: false
matrix:
python-version: [ "3.7","3.8", "3.9", "3.10", "3.11" ]
python-version: [ "3.7","3.8", "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v4
Expand All @@ -29,9 +29,21 @@ jobs:
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
- name: Lint with flake8
run: |
flake8 .
- name: Run internal tests
run: |
pytest tests/agrirouter/internal --junitxml=junit/test-results.xml
- name: Dry run building the wheel
run: |
python -m build --sdist --wheel
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
check_name: "Test Report (${{ matrix.python-version }})"
report_paths: 'junit/test-results.xml'
detailed_summary: true
include_passed: true
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
build
dist

venv
env
virtualenv

.idea
**/__pycache__
*.egg-info
Expand All @@ -10,6 +14,5 @@ venv
.pytest_cache
/paho/
/paho_mqtt-1.6.1.dist-info/
agrirouter.egg-info/
build/
dist/
/paho/
/paho_mqtt-1.6.1.dist-info/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![agrirouter logo](./assets/images/agrirouter.svg)
<img src="https://files.my-agrirouter.com/agrirouter_logo.svg" height="100" />

# About the project

Expand Down
27 changes: 12 additions & 15 deletions example_script.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import time
import agrirouter as ar
from agrirouter.onboarding.enums import Gateways
from agrirouter.generated.messaging.request.payload.endpoint.subscription_pb2 import Subscription
from agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification
from agrirouter.messaging.services.commons import HttpMessagingService, MqttMessagingService
from agrirouter.utils.uuid_util import new_uuid

from google.protobuf.timestamp_pb2 import Timestamp

from src.agrirouter.generated.messaging.request.payload.account.endpoints_pb2 import ListEndpointsQuery
from src.agrirouter.generated.messaging.request.payload.feed.feed_requests_pb2 import ValidityPeriod
from src.agrirouter.onboarding.response import OnboardResponse
from agrirouter.generated.messaging.request.payload.account.endpoints_pb2 import ListEndpointsQuery
from agrirouter.generated.messaging.request.payload.feed.feed_requests_pb2 import ValidityPeriod
from agrirouter.onboarding.response import OnboardResponse

public_key = """-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzGt41/+kSOTlO1sJvLIN
Expand Down Expand Up @@ -64,15 +70,6 @@
}
}

import src as ar
from src.agrirouter.onboarding.enums import Gateways
from src.agrirouter.api.enums import CapabilityType
from src.agrirouter.generated.messaging.request.payload.endpoint.subscription_pb2 import Subscription
from src.agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification
from src.agrirouter.messaging.services.commons import HttpMessagingService, MqttMessagingService
from src import ListEndpointsParameters, ListEndpointsService, SubscriptionService, SubscriptionParameters, \
QueryHeaderService, QueryHeaderParameters, CapabilitiesService, CapabilitiesParameters
from src.agrirouter.utils.uuid_util import new_uuid

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

from src.agrirouter.messaging.decode import decode_response
from src.agrirouter.messaging.decode import decode_details
from src.agrirouter.messaging.messages import OutboxMessage
from agrirouter.messaging.decode import decode_response
from agrirouter.messaging.decode import decode_details
from agrirouter.messaging.messages import OutboxMessage

outbox_message = OutboxMessage()
outbox_message.json_deserialize(msg.payload.decode().replace("'", '"'))
Expand Down
154 changes: 0 additions & 154 deletions examples.txt

This file was deleted.

11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
[project]
name = "agrirouter"
version = "2.0.0"
version = "2.0.0b1"
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."
authors = [
{ name = "Alexey Petrovsky", email = "[email protected]" },
{ name = "Oliver Rahner", email = "[email protected]" },
{ name = "Sascha Dömer", email = "[email protected]" },
]
readme = "README.md"
requires-python = ">=3.7, <=3.11"
requires-python = ">=3.7" # no upper boundary according to https://discuss.python.org/t/requires-python-upper-limits/12663
urls = { "Source" = "https://github.com/DKE-Data/agrirouter-sdk-python" }
classifiers = [
"Intended Audience :: Developers",
"License :: Apache License 2.0",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules"
]
dependencies = [
"requests",
"protobuf~=3.18.0"
]

[build-system]
requires = ["setuptools", "wheel"]
Expand Down
File renamed without changes.
18 changes: 8 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
pytest==6.2.5
black==21.9b0
flake8==3.9.2
pyflakes==2.3.1

pytest~=8.1.1; python_version >= "3.8"
pytest~=7.4.4; python_version <= "3.7"
build~=1.2.1; python_version >= "3.8"
build~=0.10.0; python_version <= "3.7"
flake8~=7.0.0; python_version >= "3.8"
flake8~=5.0.4; python_version <= "3.7"

cryptography~=3.4.8
setuptools~=68.0.0
pycparser~=2.20
idna~=3.2
urllib3~=1.26.18
certifi~=2023.7.22
requests~=2.31.0
paho-mqtt~=1.5.1
protobuf~=3.18.0
google~=3.0.0
toml~=0.10.2
build~=1.1.1
importlib-metadata<5.0
5 changes: 5 additions & 0 deletions src/agrirouter/api/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class ContentTypes(BaseEnum):
APPLICATION_JSON = "application/json"


class Environments(BaseEnum):
PRODUCTION: str = "production"
QA: str = "qa"


class RequestHeaders(BaseEnum):
AUTHORIZATION: str = "Authorization"
X_AGRIROUTER_SIGNATURE: str = "X-Agrirouter-Signature"
Expand Down
2 changes: 1 addition & 1 deletion src/agrirouter/api/environments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.agrirouter.api.keys import AR_QA_PUBLIC_KEY, AR_PROD_PUBLIC_KEY
from agrirouter.api.keys import AR_QA_PUBLIC_KEY, AR_PROD_PUBLIC_KEY


class BaseEnvironment:
Expand Down
Loading
Loading