Skip to main content

Language specific uProtocol library for building and using UUri, UUID, UAttributes, UTransport, and more.

Project description

= Eclipse uProtocol Python Library
:toc:

== Overview

This library implements the https://github.com/eclipse-uprotocol/uprotocol-spec/blob/main/languages.adoc[uProtocol Language Specific Library Requirements] for Python defined in https://github.com/eclipse-uprotocol/uprotocol-spec/tree/main[uProtocol Specifications]. The library is organized into packages that are described in <<sdk-packages>> below and organized by the layers of the protocol.

Each package contains a README.adoc file that describes the purpose of the package and how to use it.

The module contains the factory methods, serializers, and validators for all data types defined in the specifications, and any data models that either haven't or couldn't be defined in uprotocol-core-api yet (ex. UPayload) This library fits into the big picture of the uProtocol SDK as seen in the diagram below.

.uProtocol SDK
image:https://raw.githubusercontent.com/eclipse-uprotocol/up-spec/main/up_libraries.drawio.svg[#uprotocol-sdk,width=100%,align="center"]


== Getting Started

=== Prerequisites
Before proceeding with the setup of this project, ensure that the following prerequisites are met:

* Maven is installed and configured in your environment. You can verify this by running the following command in your terminal:
[,bash]
----
mvn -version
----
If Maven is properly installed, you should see information about the Maven version and configuration. +

NOTE: Ensure you are using Java 17 with your Maven installation before continuing with the next steps. Other versions of Java may not be supported.

=== Importing the Library

To set up SDK, follow the steps below:

. Clone the code from the GitHub repository:
+
[source]
----
git clone https://github.com/eclipse-uprotocol/up-python.git
----

. Execute the `pull_and_compile_protos.py` script using the following commands:
+
[source]
----
cd scripts
python pull_and_compile_protos.py
----
This script automates the following tasks:

1. **Cloning and Compilation of Protos:**
Clones the `up-core-api` protos from the `up-spec` repository, compiles them, and generates Python protofiles in the protos folder.

. Install up-python
+
[source]
----
python -m pip install ../
----

*This will install up-python, making its classes and modules available for import in your python code.*

=== Using the Library

The Library is broken up into different packages that are described in <<sdk-packages>> below. Each package contains a README.adoc file that describes the purpose of the package and how to use it. Packages are organized into the following directories:


.SDK Packages
[#sdk-packages,width=100%,cols="1,2,5",options="header"]
|===

| Package | Protocol Layer | Purpose

| link:uprotocol/client/README.adoc[`*client*`]
| https://github.com/eclipse-uprotocol/up-spec/tree/main/up-l3[Application Layer (uP-L3)]
| Top level client-facing interfaces to communication with USubscription, UDiscovery, and UTwin services.

| link:uprotocol/communication/README.adoc[`*communication*`]
| https://github.com/eclipse-uprotocol/up-spec/tree/main/up-l2[communication layer (uP-L2)]
| Common implementation of communication messaging patterns (publisher, subscriber, Rpcclient, RpcServer, etc..) that is build on top of the L1 transport interface (see below)

| link:uprotocol/transport/README.adoc[`*transport*`]
| https://github.com/eclipse-uprotocol/uprotocol-spec/blob/main/up-l1/README.adoc[Transport Layer (uP-L1)]
| Interface and data model for how to send() and receive() messages in a common way across various transport technologies (ex. zenoh, mqtt, http, etc...). the interface is implemented by transports (ex. up-transport-zenoh-python), and the interface is then used to build the uProtocol layer 2 communication layer implementation.

| link:uprotocol/uri/README.adoc[`*uri*`]
|
| Uniform Resource Identifier (RFC3986), how uProtocol addresses things (devices, software, methods, topics, etc...) on the network.

| link:uprotocol/uuid/README.adoc[`*uuid*`]
|
| Identifier used to uniquely identify (and timestamp) messages that are sent.

|===

NOTE: Please visit the READMEs in <<sdk-packages>> for examples of how to use the different data types and their factories, validators, and serializers.


=== Cleaning Up

Clean up by running the command:
`python clean_project.py`

=== Running the Tests

- Execute below command from up-python directory

[source]
----
python -m coverage run --source uprotocol/ -m pytest
----
=== Generate coverage report

[source]
----
python -m coverage report
python -m coverage html
----
This generates the HTML report to htmlcov\index.html


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

up_python-0.2.0.dev0.tar.gz (66.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

up_python-0.2.0.dev0-py3-none-any.whl (115.0 kB view details)

Uploaded Python 3

File details

Details for the file up_python-0.2.0.dev0.tar.gz.

File metadata

  • Download URL: up_python-0.2.0.dev0.tar.gz
  • Upload date:
  • Size: 66.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for up_python-0.2.0.dev0.tar.gz
Algorithm Hash digest
SHA256 c1bbd9dce7a0ca54d28aba7c35575cd3b68ade2269ee36a3c871e4a158adcb2f
MD5 56c1f622c09468e66f9f42c500aad6d2
BLAKE2b-256 fac3281427a457e854d74597d7a2dc6a1bf9d76115087d6e37f15c07ae31eab4

See more details on using hashes here.

File details

Details for the file up_python-0.2.0.dev0-py3-none-any.whl.

File metadata

  • Download URL: up_python-0.2.0.dev0-py3-none-any.whl
  • Upload date:
  • Size: 115.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for up_python-0.2.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 02b0d6a831bbd8d4297f0204a4c256222343c43bfb515fb88590240ca1da6bd7
MD5 76d1af41d5f1a2fffa4026a200ddb591
BLAKE2b-256 4f2ec988da72bc775fe7ef637dc6b2fdbb7a38144cf16f648df76c14b9e9cf90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page