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/validate and fix toml #46

Merged
merged 18 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
8 changes: 5 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ jobs:
python-version: [ "3.11" ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8 .
- name: Test with pytest
run: |
pytest
- name: Dry run building the wheel
run: |
python -m build --sdist --wheel
10 changes: 6 additions & 4 deletions .github/workflows/linting-for-all-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ jobs:
max-parallel: 1
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8 .
- name: Dry run building the wheel
run: |
python -m build --sdist --wheel
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ venv
.pytest_cache
/paho/
/paho_mqtt-1.6.1.dist-info/
/paho/
/paho_mqtt-1.6.1.dist-info/
agrirouter.egg-info/
build/
dist/
62 changes: 0 additions & 62 deletions README.adoc

This file was deleted.

65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
![agrirouter logo](./assets/images/agrirouter.svg)

# About the project

The agrirouter is a universal data exchange platform for farmers and
agricultural contractors that makes it possible to connect machinery
and agricultural software, regardless of vendor or manufacturer.
Agrirouter does not save data; it transfers data. As a universal data
exchange platform, agrirouter fills a gap on the way to Farming 4.0.
Its underlying concept unites cross-vendor and discrimination-free
data transfer. You retain full control over your data. Even data
exchange with service providers (e.g. agricultural contractors) and
other partners is uncomplicated: Data are very rapidly transferred via
the online connection, and if you wish, is intelligently connected to
other datasets.

# The current project you’re looking at

This project contains the SDK for the communication with the agrirouter.
Everything you need for the onboard process, secure communication and
much more.

# Installation

Create your virtual environment using any kind of `conda` setup you
would like to have. The SDK is tested with Python 3.8, 3.9, 3.10 and
3.11.

``` bash
conda create -n agrirouter-sdk-python python=3.8
conda create -n agrirouter-sdk-python python=3.9
conda create -n agrirouter-sdk-python python=3.10
conda create -n agrirouter-sdk-python python=3.11
```

Create one of the environments and activate it:

``` bash
conda activate agrirouter-sdk-python
```

After the activation you are ready to install the requirements for the
SDK:

``` bash
pip install -r requirements.txt
```

You are able to select the virtual environment when working with the
IDE.

# Running unit tests

`$ pytest`

# External resources

Here are some external resources for the development:

- [My Agrirouter Website](https://my-agrirouter.com)

- [Integration
Guide](https://github.com/DKE-Data/agrirouter-interface-documentation)

- [EFDI Protobuf Definition](https://www.aef-online.org)
14 changes: 0 additions & 14 deletions agrirouter/__init__.py

This file was deleted.

47 changes: 0 additions & 47 deletions agrirouter/utils/type_url.py

This file was deleted.

4 changes: 2 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pytest

from agrirouter.api.enums import Environments
from src.api.enums import Environments
from tests.common.constants import PUBLIC_KEY, PRIVATE_KEY, AUTH_RESULT_URL


@pytest.fixture(scope="session")
def authorization():
from agrirouter.auth.auth import Authorization
from src.auth.auth import Authorization

auth_client = Authorization(Environments.QA.value, public_key=PUBLIC_KEY, private_key=PRIVATE_KEY)
auth_response = auth_client.extract_auth_response(AUTH_RESULT_URL)
Expand Down
28 changes: 14 additions & 14 deletions example_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from google.protobuf.timestamp_pb2 import Timestamp

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
from src.generated.messaging.request.payload.account.endpoints_pb2 import ListEndpointsQuery
from src.generated.messaging.request.payload.feed.feed_requests_pb2 import ValidityPeriod
from src.onboarding.response import OnboardResponse

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

import agrirouter as ar
from agrirouter.onboarding.enums import Gateways
from agrirouter.messaging.enums import CapabilityType
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 import ListEndpointsParameters, ListEndpointsService, SubscriptionService, SubscriptionParameters, \
import src as ar
from src.onboarding.enums import Gateways
from src.messaging.enums import CapabilityType
from src.generated.messaging.request.payload.endpoint.subscription_pb2 import Subscription
from src.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification
from src.messaging.services.commons import HttpMessagingService, MqttMessagingService
from src import ListEndpointsParameters, ListEndpointsService, SubscriptionService, SubscriptionParameters, \
QueryHeaderService, QueryHeaderParameters, CapabilitiesService, CapabilitiesParameters
from agrirouter.utils.uuid_util import new_uuid
from src.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 +298,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 agrirouter.messaging.decode import decode_response
from agrirouter.messaging.decode import decode_details
from agrirouter.messaging.messages import OutboxMessage
from src.messaging.decode import decode_response
from src.messaging.decode import decode_details
from src.messaging.messages import OutboxMessage

outbox_message = OutboxMessage()
outbox_message.json_deserialize(msg.payload.decode().replace("'", '"'))
Expand Down
28 changes: 22 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
[project]
name = "agrirouter"
description = "agrirouter SDK"
version = "1.0.0b1"
dynamic = ["dependencies"]
version = "2.0.0"
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"
urls = { "Source" = "https://github.com/DKE-Data/agrirouter-sdk-python" }
classifiers = [
"Intended Audience :: Developers",
"License :: Apache License 2.0",
"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"
]

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["agrirouter"]

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ 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
Loading