Skip to content

Commit 6e133f0

Browse files
author
ajoino
authored
Merge pull request #29 from arrowhead-f/Development
Development
2 parents 2a02e4e + 78000c2 commit 6e133f0

File tree

103 files changed

+2850
-1077
lines changed

Some content is hidden

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

103 files changed

+2850
-1077
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
source = ./arrowhead_client/

.github/workflows/code_quality.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
name: Code quality check with flake8 and mypy
3+
4+
on:
5+
push:
6+
branches: [Development]
7+
pull_request:
8+
branches: [Development, master]
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python: [3.8]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Setup Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: ${{ matrix.python }}
24+
- name: Install flake8 and mypy
25+
run:
26+
pip install flake8 mypy -r requirements.txt
27+
- name: Run flake8
28+
run:
29+
flake8 --ignore=E501,E126,E127 arrowhead_client/ examples/
30+
- name: Run mypy
31+
if: ${{ always() }}
32+
run:
33+
mypy arrowhead_client/

.github/workflows/tox.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
name: Tox testing
3+
4+
on:
5+
push:
6+
branches: [Development]
7+
pull_request:
8+
branches: [Development, master]
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python: [3.7, 3.8, 3.9]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Setup Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: ${{ matrix.python }}
24+
- name: Install Tox and any other packages
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install tox tox-gh-actions setuptools wheel
28+
- name: Build library
29+
run: |
30+
python setup.py sdist bdist_wheel
31+
pip install -e .
32+
- name: Run Tox
33+
# Run tox using the version of Python in `PATH`
34+
run: tox
35+
- name: Upload coverage to Codecov
36+
uses: codecov/codecov-action@v1

README.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
11
# ARROWHEAD CLIENT PYTHON LIBRARY
22
This is a library for the creation of client service providers and consumer for the [Arrowhead Framework](www.arrowhead.eu), a service-oriented framework developed for industrial automation.
3+
To read more about the library, please go to the [documentation](https://arrowhead-client-python-library.readthedocs.io/en/latest/).
34

45
## About
56
The Arrowhead Client Python Library is a library to make it easy to create your own Arrowhead Framework systems and services in Python.
6-
This library provides classes that interface with the [Arrowhead Core Systems](https://github.com/arrowhead-f/core-java-spring), and uses Flask to provide services.
7+
This library provides interfaces to connect Python with the [Arrowhead Core Systems](https://github.com/arrowhead-f/core-java-spring).
78

89
### Development status
9-
This library has not yet reached a stable development version, and a lot will change.
10-
Currently, it is working, but it's still missing many crucial features, such as:
11-
- Error handling
12-
- Logging
13-
- Testing
14-
- Support for the following core services
15-
- Eventhandler
16-
- Support for the TOKEN security modes (access policy):
10+
This library is still in the Alpha stage of development, this means that the APIs haven't yet matured and may change at any time.
1711

18-
As more Arrowhead Core Systems mature and are added to the official docker container, those will be added to this list.
12+
The library currently supports the http and websockets protocols for service consumption.
13+
14+
The library only provides interfaces for he mandatory core systems at the moment, but inferfaces for the other core systems is planned.
1915

2016
### External Depencies
2117
To run an Arrowhead system you need to have the Arrowhead core systems up and running, and the correct certificates need to be provided.
2218
A guide on how to create your own certificates can be found on the [Arrowhead github](https://github.com/arrowhead-f/core-java-spring/blob/master/documentation/certificates/create_client_certificate.pdf).
2319

24-
### Requirements
25-
- Python 3.7 or higher
26-
- Requests
27-
- Flask
28-
- Gevent
29-
3020
## How To Use
31-
Install the library with `pip install arrowhead-client`.
21+
See the [quickstart guide](https://arrowhead-client-python-library.readthedocs.io/en/latest/quickstart.html).
3222

_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__lib_name__ = 'arrowhead-client'
2-
__version__ = '0.3.0a'
2+
__version__ = '0.4.2a'
33
__author__ = 'Jacob Nilsson'
44
__email__ = '[email protected]'

arrowhead_client/abc.py

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,15 @@
1-
from abc import abstractmethod, ABC
2-
3-
from arrowhead_client.response import Response
4-
from arrowhead_client.rules import OrchestrationRule, RegistrationRule
1+
from abc import ABC
52

63

74
class ProtocolMixin(ABC):
85
def __init_subclass__(cls, protocol='', **kwargs):
96
if protocol == '':
107
raise ValueError('No protocol specified.')
11-
elif not isinstance(protocol, str):
12-
raise TypeError('Protocol must be of type str.')
13-
cls._protocol = protocol.upper()
14-
15-
16-
class BaseConsumer(ProtocolMixin, ABC, protocol='<PROTOCOL>'):
17-
"""Abstract base class for consumers"""
18-
@abstractmethod
19-
def consume_service(
20-
self,
21-
rule: OrchestrationRule,
22-
**kwargs) -> Response:
23-
"""
24-
Consume service according to the consumation rule and return the response.
25-
26-
Args:
27-
rule: Orchestration rule.
28-
Returns:
29-
A Response object.
30-
"""
31-
32-
33-
class BaseProvider(ProtocolMixin, ABC, protocol='<PROTOCOL>'):
34-
"""Abstract base class for providers"""
35-
@abstractmethod
36-
def add_provided_service(self, rule: RegistrationRule, ) -> None:
37-
"""
38-
Adds the provided service to the provider according the provision rule.
39-
40-
Args:
41-
rule: Provision rule.
42-
"""
43-
44-
@abstractmethod
45-
def run_forever(
46-
self,
47-
address: str,
48-
port: int,
49-
keyfile: str,
50-
certfile: str,
51-
) -> None:
52-
"""
53-
Starts the provider and runs until interrupted.
54-
55-
Args:
56-
address: system ip address.
57-
port: system port.
58-
keyfile: client keyfile.
59-
certfile: client certfile.
60-
cafile: certificate authority file
61-
"""
8+
elif isinstance(protocol, set):
9+
if not all(isinstance(prot, str) for prot in protocol):
10+
raise ValueError('All protocols specified must be of type str')
11+
cls._protocol = set(prot.upper() for prot in protocol)
12+
elif isinstance(protocol, str):
13+
cls._protocol = {protocol.upper()}
14+
else:
15+
raise TypeError('protocol must be of type str or set')

arrowhead_client/api.py

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

arrowhead_client/client/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
from .client_core import ArrowheadClient, provided_service
1+
"""
2+
Client module
3+
"""
4+
from .client_core import provided_service, ArrowheadClient
5+
from .client_async import ArrowheadClientAsync
6+
from .implementations import AsyncClient
27

3-
__all__ = ['ArrowheadClient', 'provided_service']
8+
__all__ = [
9+
'provided_service',
10+
'ArrowheadClient',
11+
'ArrowheadClientAsync',
12+
'AsyncClient',
13+
]

0 commit comments

Comments
 (0)