Skip to content

Add up_rust_py package with documentation and examples#1

Draft
sachinkum0009 wants to merge 14 commits intoeclipse-uprotocol:mainfrom
sachinkum0009:feat/pyo3-rs-bindings
Draft

Add up_rust_py package with documentation and examples#1
sachinkum0009 wants to merge 14 commits intoeclipse-uprotocol:mainfrom
sachinkum0009:feat/pyo3-rs-bindings

Conversation

@sachinkum0009
Copy link

Introduce the up_rust_py package, providing Python bindings for uProtocol. Include necessary modules, documentation, and example scripts for usage. This addition enhances the project's functionality and usability.

Copy link
Contributor

@sophokles73 sophokles73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have provided a few hints and proposals for improvement. My Python knowledge is very limited so I the review of the python code might not be as thorough as you would expect.

I do like the clear structuring and that you already thought about including proper documentation 👍

In general, the Eclipse license header is missing in all files. You may want to take a look a the up-rust repository for the format of the header and where to add it.

pyproject.toml Outdated
requires-python = ">=3.8"
description = "Python bindings for Eclipse uProtocol Rust implementation"
readme = "README.md"
license = { text = "Apache-2.0" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I see at https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license-and-license-files this should probably be

license = "Apache-2.0"

or am I mistaken?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, you're right. I will fix it.

description = "Python bindings for Eclipse uProtocol Rust implementation"
readme = "README.md"
license = { text = "Apache-2.0" }
authors = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it would also be good to include

license-files = "LICENSE"

to refer to the license file in the root folder?

Comment on lines +45 to +46
mqtt = [] # MQTT transport (future)
someip = [] # SOME/IP automotive protocol (future)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we should omit these until there actually is support for them ...

Comment on lines +49 to +52
discovery = [] # Service discovery (udiscovery feature)
subscription = [] # Advanced subscription management (usubscription feature)
twin = [] # Digital twin support (utwin feature)
cloudevents = [] # CloudEvents format support
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, FMPOV it is totally ok to only start with what is really supported. Once you add more bindings, e.g. for the uSubscription service interface, you can add a corresponding feature extension ..


1. Clone the repository:
```bash
git clone https://github.com/sachinkum0009/up-rust-py.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should become https://github.com/eclipse-uprotocol/up-rust-py.git, right?

- Python 3.8 or higher
- pip (Python package installer)

## Install from PyPI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we should add a section recommending to use a virtual environment?

docs/usage.md Outdated

Here's a simple example that demonstrates publishing and receiving messages:

```python
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of pasting the code in here (where we will have a hard time keeping it in sync with the code base), we should probably simply refer to a file in the examples folder?

entity ID, and version to create unique identifiers.
"""

def __init__(self, authority: str, entity_id: int, version: int) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if I provide a version value that is out of range?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found out that the PyO3 automatically converts Python types to Rust Types with validation.

If the value is out of range, it will return a OverflowError.

Will be called when messages arrive.

Raises:
Exception: If registration fails.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not too familiar with error handling in Python but Exception looks very generic to me. Isn't there a concept for having more specific errors being reported?

@sachinkum0009
Copy link
Author

sachinkum0009 commented Mar 4, 2026

To Do

  • small paragraph describing what this repo contains and what it is good for
  • update license text
  • omit libs until there actually is support for them
  • update repo link to new
  • update pytest to latest
  • update code to include binding which are currently implemented
  • tooling to generate docs from API
  • refer to files with examples
  • section to virtualenv
  • handle version value that is out of range
  • add exception handling to manage edge cases
  • add eclipse license header in all files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants