-
Notifications
You must be signed in to change notification settings - Fork 6
Add Python version of the edge driver library #539
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
base: main
Are you sure you want to change the base?
Conversation
This now requires drivers to be run with `asyncio.run()`
2ebf46c to
0ab6f30
Compare
|
I've now made this such that drivers are intended to be run inside |
amrc-benmorrow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly there, I think. Has this had any real-world-ish testing against an actual Edge Agent?
| edge_password: str, | ||
| reconnect_delay: int = 500, | ||
| serial: bool = False, | ||
| ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can handle these superclass arguments more cleanly like this:
def __init__(self, serial: bool = False, **opts):
super().__init__(**opts)
self.serial_mode = serial
This way if the arguments to Driver change the subclasses don't need changing.
| raise ValueError(f"Invalid MQTT URL: Hostname not found.") | ||
|
|
||
| if not parsed.port: | ||
| raise ValueError(f"Invalid MQTT URL: Port not found.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to default the ports correctly here. The standard ACS deployment passes mqtt://localhost and expects the driver to understand port 1883. This is an irritating deficiency in urllib.
Overview
This adds a Python version of the JavaScript edge driver library to allow easy creation of edge drivers in Python. Python is often used by end users to interact with devices, so is a useful language for people to write their own drivers in as we move more towards a BYOD model.
The source is written as close to the original JS as possible with the addition of type hints from
typing.Building
This project was written using Poetry as a build system but can be used with any build system.
Testing
Simple unit tests have been implemented for this project. They require
pytestto run. You can run these tests usingpytest tests/.