Giter Club home page Giter Club logo

zenoh-python's Introduction

CI Documentation Status Discussion Discord License License

Eclipse Zenoh

The Eclipse Zenoh: Zero Overhead Pub/sub, Store/Query and Compute.

Zenoh (pronounce /zeno/) unifies data in motion, data at rest and computations. It carefully blends traditional pub/sub with geo-distributed storages, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks.

Check the website zenoh.io and the roadmap for more detailed information.


Python API

This repository provides a Python binding based on the main Zenoh implementation written in Rust.


How to install it

The Eclipse zenoh-python library is available on Pypi.org. Install the latest available version using pip:

pip install eclipse-zenoh

⚠️WARNING⚠️ zenoh-python is developped in Rust. On Pypi.org we provide binary wheels for the most common platforms (Linux x86_64, i686, ARMs, MacOS universal2 and Windows amd64). But also a source distribution package for other platforms. However, for pip to be able to build this source distribution, there are some prerequisites:

  • pip version 19.3.1 minimum (for full support of PEP 517). (if necessary upgrade it with command: 'sudo pip install --upgrade pip' )
  • Have a Rust toolchain installed (instructions at rustup.rs)

Supported Python versions and platforms

zenoh-python has been tested with Python 3.7, 3.8, 3.9 and 3.10.

It relies on the zenoh Rust API which require the full std library. See the list in Rust Platform Support.


How to build it

⚠️ WARNING ⚠️ : Zenoh and its ecosystem are under active development. When you build from git, make sure you also build from git any other Zenoh repository you plan to use (e.g. binding, plugin, backend, etc.). It may happen that some changes in git are not compatible with the most recent packaged Zenoh release (e.g. deb, docker, pip). We put particular effort in mantaining compatibility between the various git repositories in the Zenoh project.

Requirements:

  • Python >= 3.7

  • pip >= 19.3.1

  • (Optional) A Python virtual environment (for instance virtualenv or miniconda)

  • Rust and Cargo. If you already have the Rust toolchain installed, make sure it is up-to-date with:

    rustup update

Steps:

  • Install developments requirements:

    pip install -r requirements-dev.txt
  • Ensure your system can find the building tool maturin (installed by previous step). For example, it is placed at $HOME/.local/bin/maturin by default on Ubuntu 20.04.

    export PATH="$HOME/.local/bin:$PATH"
  • Build and install zenoh-python:

    • With a virtual environment active:

      maturin develop --release
    • Without one:

      maturin build --release
      pip install ./target/wheels/<there should only be one .whl file here>

Running the Examples

You can install Zenoh Router first (See the instructions). Then, run the zenoh-python examples following the instructions in examples/README.md

zenoh-python's People

Contributors

cguimaraes avatar davidedellagiustina avatar denisbiryukov91 avatar diogomatsubara avatar eclipse-zenoh-bot avatar evshary avatar fuzzypixelz avatar gabrik avatar github-actions[bot] avatar imstevenpmwork avatar jenoch avatar knmcguire avatar kydos avatar mallets avatar olivierhecart avatar oteffahi avatar p-avital avatar sreeja avatar wiseaidev avatar wyfo avatar yuanyuyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zenoh-python's Issues

NameError: name 'key' is not defined

This is a copy of issue atolab/zenoh-python#2 :

i want to report that there is problem with zenoh class, so if i want to create a zenoh object that has a session and use that session to open a zenoh-net session it works fine if the key is user,
z = Zenoh.login(locator,{'user': b'123456789'})
but if we change it to z = Zenoh.login(locator,{'pass': b'123456789'})
it will throw a NameError.
key should be k in your code.

z_put.py example is not compatible with 0.10.0-rc

Describe the bug

There seem to be several issues at least with z_put.py in the latest release.

The Encoding library needs to imported from zenoh (line 20). Also the key expressions in the commented examples should not have a trailing '/'. Finally, I cannot get the JSON example to run. It throws following error:

raise TypeError("encoding was passed, but payload is not of type bytes")
TypeError: encoding was passed, but payload is not of type bytes

To reproduce

  1. add missing Encoding library, uncomment JSON example, and remove trailing '/' from key expression in z_put.py
  2. python3 z_put.py

System info

zenoh 0.10.0-rc

pip install not working on aarch64

Trying to install on nvidia jetson:

(venv) k@os:$ uname -i
aarch64
(venv) k@os:$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:        18.04
Codename:       bionic
(venv) k@os:$ python --version
Python 3.6.9

But fails with:

$ pip install eclipse-zenoh
Collecting eclipse-zenoh
  Downloading eclipse_zenoh-0.5.0_b8.tar.gz (74 kB)
     |████████████████████████████████| 74 kB 846 kB/s            
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing wheel metadata (pyproject.toml) ... done
Building wheels for collected packages: eclipse-zenoh
  Building wheel for eclipse-zenoh (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/alf/proj/zenoh_play/venv/bin/python3 /home/alf/proj/zenoh_play/venv/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmp0rv6g8c0
       cwd: /tmp/pip-install-zineoisv/eclipse-zenoh_8413ab83c85a404597df68fa8f7150a8
  Complete output (255 lines):
  Running `maturin pep517 build-wheel -i /home/alf/proj/zenoh_play/venv/bin/python3`
  ⚠️  Warning: Please use maturin in pyproject.toml with a version constraint, e.g. `requires = ["maturin>=0.11,<0.12"]`. This will become an error.
TLDR;
  error: could not compile `shared_memory`
  
  To learn more, run the command again with --verbose.
  warning: build failed, waiting for other jobs to finish...
  error: build failed
  💥 maturin failed
    Caused by: Failed to build a native library through cargo
    Caused by: Cargo build finished with "exit status: 101": `cargo rustc --message-format json --manifest-path Cargo.toml --release --lib --`
  🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.6
  🐍 Not using a specific python interpreter (With abi3, an interpreter is only required on windows)
  error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
    --> /home/alf/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:87:13
     |
  87 |         Err(nix::Error::Sys(Errno::EEXIST)) => return Err(ShmemError::MappingIdExists),
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
     |
     = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
  
  error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
    --> /home/alf/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:88:13
     |
  88 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapCreateFailed(e as u32)),
     |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
     |
     = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
  
  
  error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
     --> /home/alf/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:103:13
      |
  103 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::UnknownOsError(e as u32)),
      |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
      |
      = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
  
  
  error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
     --> /home/alf/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:119:13
      |
  119 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapCreateFailed(e as u32)),
      |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
      |
      = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
  
  
  error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
     --> /home/alf/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:135:13
      |
  135 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapOpenFailed(e as u32)),
      |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
      |
      = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
  
  
  error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
     --> /home/alf/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:150:13
      |
  150 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapOpenFailed(e as u32)),
      |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
      |
      = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
  
  
  error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
     --> /home/alf/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:166:13
      |
  166 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapOpenFailed(e as u32)),
      |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
      |
      = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
  
  
  error: aborting due to 7 previous errors
  
  
  For more information about this error, try `rustc --explain E0164`.
  
  Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/home/alf/proj/zenoh_play/venv/bin/python3'] returned non-zero exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for eclipse-zenoh
Failed to build eclipse-zenoh
ERROR: Could not build wheels for eclipse-zenoh, which is required to install pyproject.toml-based projects

Improve the CI checks

Describe the feature

We could speed up the CI checks by running the checks and tests in parallel as in zenoh rust.

Leverage new zenoh sync API

In addition to the traditional async API, Zenoh has recently added support for synchronous calls (eclipse-zenoh/zenoh#95). It would be beneficial to leverage this API to simplify zenoh-python and also improve performances.

[Bug] init_logger may panic if called from enviroment where the logger was already initialized (e.g., PyO3)

Describe the bug

When the zenoh.init_logger() function is called from an environment where env_logger was already initialized it crashes with the following error:

 PyErr { type: <class 'pyo3_runtime.PanicException'>, value: PanicException('env_logger::init should not be called after logger initialized: SetLoggerError(())'),

This is well documented in the env_logger crate.

A solution is to use try_init which returns an error instead of panicking, so change this line to something like

env_logger::try_init().unwrap_or_else(|_| log::warn!("`env_logger` already initialized"));;

It will avoid crashed and print in the log that the logger was already initialized.

To reproduce

Run zenoh.init_logger() in an environment with the logger already initialized (e.g. calling it from PyO3)

System info

Not applicable

Allow put operation to use directly some primitive types

For convenience the put operation should allow use directly some python primitive types commonly used, such as string, int, float and bytes and automatically create the right Value type.

This would allow for a put operation to look like:

     w.put('/sensor/temp', 25.3)

As opposed to having to do:

     w.put('/some/path', Value("my value", Encoding.STRING);
      ...

zenoh python subscriber work with asyncio

I would like to integrate the zenoh python with the asyncio library.
The statement like following:
sub = session.declare_subscriber('/rt/hello_world', sub_info, hello_callback) will call the hello_callback function.
The argument for the hello_callback can only be the sample: Sample.
Inside the hello_callback I can only deserialize the received message.

Is it possible, that I inside the hello_callback call a coroutine? Because I want to send the message to another broker(NATS broker) for further usage. But I need to call a coroutine to send the message to that broker.
I have tried once to decorate the hello_callback function as a async function. But it failed.

Or another alternative, that the recevied message can be stored in the Subscriber instance. The message can then be accessed.

Get testing failure with the pull-subscriber example

Hi all,
When I tried to use use the python API zn_pull.py, I got the error below:

Traceback (most recent call last):
File "zn_pull.py", line 61, in listener
sample.data_info.timestamp.time)
AttributeError: 'NoneType' object has no attribute 'time'

I guessed that it couldn't get the timestamp of the sample(I couldn't get timestamps with other zenoh-net examples either), after I edited the code of timestamp handling to
time = '(not specified)' if sample.data_info is None or sample.data_info.timestamp is None else datetime.fromtimestamp( sample.data_info.timestamp.time)
it worked.

I am not sure whether my guess is correct or not, thank you

Binary wheels for armv6

Describe the feature

zenoh-python relies on pypa/cibuildwheel to build the binary wheels that are released on pypi.org.
However it doesn't support armv6 and armv7 architectures. The reason being there is no manylinux image available for armv6 nor armv7.

EDIT 2022-06-08:
Thanks to #66 an armv7 wheel is now built. The build now relies on messense/maturin-action which doesn't provide a solution for armv6.

[Bug] macosx_11_0_arm64.whl only contains an x86 lib

Describe the bug

eclipse_zenoh-0.5.0b9-cp36-abi3-macosx_11_0_arm64.whl

file zenoh.abi3.so
zenoh.abi3.so: Mach-O 64-bit dynamically linked shared library x86_64

To reproduce

curl https://files.pythonhosted.org/packages/52/23/ccc52eeb84d6e8eef254682c19173467bf4b836021f2fbe3e6a42e29d603/eclipse_zenoh-0.5.0b9-cp36-abi3-macosx_11_0_arm64.whl

System info

Darwin 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64

Improve Release workflow

Describe the release item

  1. The current release workflow takes care of wheel builds for target platforms, followed by deployment to pypi.org
  2. Creating a release branch, bumping the version and tagging it are done in an ad-hoc way (in out-of-tree scripts)
  3. Read the Docs builds are triggered manually and new versions are also activated manually
  4. GitHub releases are created manually
  5. There is a zenoh-python directory on https://download.eclipse.org/zenoh but wheels are not uploaded there
  6. Unlike Zenoh & plugins/backends, no Debian/Homebrew/Docker releases are done

The goal is to integrate (1), (2) and (3) in the release workflow. (4) and (5) will remain unaddressed unless there is a need for them arises.

Custom messages

Hello there! I tried out the examples and managed to get them working. I was wondering if there is a recommended way to generate custom messages to be used with zenoh-python, for example by ingesting an .idl file?

So far, I have managed to use pickle to serialize python containers to be sent, and deserialize them when received.

Failed building wheel for eclipse-zenoh

Describe the bug

Standard python example running on Raspberry PI
Code:

from zenoh import Zenoh
import random
import time

random.seed()

def read_temp():
    return random.randint(15, 30)

def run_sensor_loop(w):
    # read and produce a temperature every second
    while True:
        t = read_temp()
        w.put('/myfactory/machine1/temp',t)
        print (t)
        time.sleep(15)

if __name__ == "__main__":
    z = Zenoh({'peer': 'tcp/127.0.0.1:7447'})
    w = z.workspace('/')
    run_sensor_loop(w)

Error Message:

Traceback (most recent call last):
  File "zenoh_producer.py", line 27, in <module>
    run_sensor_loop(w)
  File "zenoh_producer.py", line 20, in run_sensor_loop
    w.put('/myfactory/machine1/temp',t)
  File "/usr/local/lib/python3.7/dist-packages/zenoh/workspace.py", line 50, in put
    self.rt.write_data(
AttributeError: 'dict' object has no attribute 'write_data'

Any hints what led to this error message?

To reproduce

  1. Start Zenoh Broker
  2. Execute provided code
  3. Works on Ubuntu 22.04 but led to the shown error on ARM / Raspberry Pi OS.

System info

No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
Operating System: Raspbian GNU/Linux 10 (buster)
Kernel: Linux 5.10.103-v7l+
Architecture: arm

  • Rust: rustc 1.63.0 (4b91a6ea7 2022-08-08)
  • Python 3.7.3
  • The zenoh router v0.5.0-beta.8-326-g70d7b22

z_queryable example should not send queries to itself

Describe the feature

The z_queryable example in Python can send a query to its own queryable if the user inputs anything other than Q. This is different from z_queryable examples on all other bindings, which do not have this feature.

This can also cause issues if the Python z_queryable example is ran in the background without stdin, as it would keep sending queries to itself at 1Hz.

It would be best to remove this feature from this example to keep it consistent with other bindings' implementations of z_queryable.

Unit tests are missing

Describe the bug

Nowadays there is a general lacking of unit tests on the Python side of the API.

It would be nice to have them in order to avoid footgun like the one solved by #102.

To reproduce

N.A.

System info

N.A.

Introducing Python context managers

Describe the feature

I've tried out the zenoh-python api and I've noticed the manual opening and closing of sessions and subscriptions. I think it would be way more idiomatic Python to add context managers:

with zenoh.open() as session:
    for key, value in session.info().items():
        print(f"{key}: {value}")

This makes sure the session is automatically closed when exiting the "scope", even when an exception is raised. I have implemented the basic case for session here, but I have to admit that the async case was a bit beyond my current Rust abilities. Implementing these context managers exists of nothing more than implementing __enter__ and __exit__ as methods for the sync case and __aenter__ and __aexit__ for the async case. This would also allow you to make with zenoh.open() return a sync session and async with zenoh.open() return a async session, but that would require an intermediate object with the four methods implemented and would destroy the existing session = zenoh.open() style setup without some potentially ugly trickery.

API alignment

Semantic and naming should be aligned across all zenoh API bindings: Rust, C, Python, and more to come.

Update pyo3 to 0.15.0

I'm getting the following error:

thread 'blocking-1' panicked at 'assertion failed: `(left != right)`
  left: `0`,
 right: `0`: Python threading is not initalized and the `auto-initialize` feature is not enabled.

Consider calling `pyo3::prepare_freethreaded_python()` before attempting to use Python APIs.', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.14.5/src/gil.rs:232:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'async-std/runtime' panicked at 'task has failed', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.0.3/src/task.rs:368:45

It should be fixed in pyo3 0.15.0 PyO3/pyo3#1870

API refinements

I spotted various lacks and discrepancies in the Python API when compared to the Rust API.
I think they deserve to be fixed before a release:

  • the Config class is not documented
  • with the introduction of Config class, I think the config keys constants are no longer of any use
  • there are no Selector and ValueSelector classes that would allow parsing and easy access to properties/filters/fragments parts (for instance in Queryable callback)
  • in Encoding class the prefix and suffix are not exposed, while they are in Rust
  • both Session.get() and AsyncSession.get() methods have optional args, while other methods expects the optional arguments as kwargs (not sure what's the best, but we need to be consistent)
  • the documentation and text_signature of some Session and AsyncSession methods lack details for some optional args (e.g. priority, local_routing...)

[Bug] Deadlock subscribing to multiple remote publishers

Describe the bug

When receiving data from multiple remote publishers, the receiver sometimes just hangs.

To reproduce

deadlock.zip

  1. Run python code:
python3 python_code.py
  1. Run 2 or more rust loop_tasks:
./target/debug/loop_tasks
  1. Press enter in python code.

Python app (randomly) hangs.

System info

zenoh-python commit 4124b2f

Update README.md wrt. recent changes

The README.md needs to be updated for:

  • instructions for installation via pip
  • instructions for build (via top-level Makefile)
  • instructions for testing against the Docker image

Zenoh-python build failed with "error[E0164]: expected tuple struct or tuple variant..."

Hi all ,
I am new to Rust and Zenoh, When I was building the python client library, I got the errors below:

error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
  --> /home/eddie/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:87:13
   |
87 |         Err(nix::Error::Sys(Errno::EEXIST)) => return Err(ShmemError::MappingIdExists),
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
   |
   = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html


error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
  --> /home/eddie/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:88:13
   |
88 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapCreateFailed(e as u32)),
   |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
   |
   = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html


    Buildingerror[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
   --> /home/eddie/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:103:13
    |
103 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::UnknownOsError(e as u32)),
    |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
    |
    = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html


error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
   --> /home/eddie/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:119:13
    |
119 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapCreateFailed(e as u32)),
    |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
    |
    = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html


error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
   --> /home/eddie/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:135:13
    |
135 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapOpenFailed(e as u32)),
    |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
    |
    = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html


   error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
   --> /home/eddie/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:150:13
    |
150 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapOpenFailed(e as u32)),
    |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
    |
    = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html


error[E0164]: expected tuple struct or tuple variant, found associated function `nix::Error::Sys`
   --> /home/eddie/.cargo/registry/src/github.com-1ecc6299db9ec823/shared_memory-0.11.4/src/unix.rs:166:13
    |
166 |         Err(nix::Error::Sys(e)) => return Err(ShmemError::MapOpenFailed(e as u32)),
    |             ^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
    |
    = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html


 error: aborting due to 7 previous errors

 
error: could not compile `shared_memory`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `cargo rustc --message-format json --manifest-path Cargo.toml --release --lib --`

[Bug] No Message Received Pub/Sub on Windows 11 x64

Describe the bug

Trying the example on Windows 11 x64, one terminal is publishing the data:

Opening session...
Declaring Publisher on 'myhome/kitchen/temp'...
Putting Data ('myhome/kitchen/temp': '[   0] Hello World')...
Putting Data ('myhome/kitchen/temp': '[   1] Hello World')...
Putting Data ('myhome/kitchen/temp': '[   2] Hello World')...
Putting Data ('myhome/kitchen/temp': '[   3] Hello World')...
Putting Data ('myhome/kitchen/temp': '[   4] Hello World')...
Putting Data ('myhome/kitchen/temp': '[   5] Hello World')...
Putting Data ('myhome/kitchen/temp': '[   6] Hello World')...
Putting Data ('myhome/kitchen/temp': '[   7] Hello World')...

But the subscriber terminal receives nothing:

Opening session...
Declaring Subscriber on 'myhome/kitchen/temp'...
Enter 'q' to quit...

I tried the exact same thing on Ubuntu 20.04, and everything works fine.
So, I guess zenoh-python doesn't support Windows 11 x86 yet?

To reproduce

  1. Go to the /example folder
  2. Open one PowerShell: python z_pub.py -k myhome/kitchen/temp -v 'Hello World'
  3. In another PowerShell: python z_sub.py -k 'myhome/kitchen/temp'

System info

  • Platform: Windows 11 x64
  • CUP: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  • Python Version: tested with 3.8, 3.9, 3.10 (none of them worked)
  • Tried with 'pip install eclipse-zenoh' and building from source (neither worked)

Query on InfluxDB with starttime/stoptime returns only 1 value per key

To reproduce this:

  • Run InfluxDB (e.g. with docker run --rm -p 8086:8086 influxdb:1.8)
  • Run zenohd with such configuration file:
      {
        plugins: { storages: { backends: { influxdb: {
                url: "http://localhost:8086",
                storages: { demo: {
                    key_expr: "/demo/example/**",
                    db: "zenoh_example",
                    create_db: true
                } }
        } } } }
      }
  • Run 3 times: python3 examples/z_put.py
  • Run python3 examples/z_get.py -s '/demo/example/**?(starttime=0)'

The latest command displays only 1 reply: >> Received ('/demo/example/zenoh-rs-put': 'Put from Python!').
3 were expected since 3 values were published on the same key and stored in the time-serie database.

`unable to connect any locator of scouted peer` zenoh-plugin-dds

I am trying to use the Zenoh Python API with pycdr as in the demo to interface with cycloneDDS via zenoh-plugin-dds. The Python api was installed via pip: eclipse-zenoh-nightly I noticed that the python API examples don't seem to be compatible with the master or latest zenoh-plugin-dds docker image:
Unable to connect any locator of scouted peer D6B17F40D8234F80AE42D205FCB23673 : [Locator { address: Tcp(SocketAddr(192.168.0.62:33681)), metadata: None }, Locator { address: Tcp(SocketAddr(172.17.0.1:33681)), metadata: None }]
I have tried the master and apis-merge branches of the Python API but no luck. Should I build the Python API from source instead of using the PyPi binary?

Liveliness API

Describe the feature

The main implementation has added a feature called liveliness tokens (see docs).
It would be useful to have this available in the python bindings.

Issue in main repo: #652
Thanks!

zenoh.net.open connected with not existing host, throws no errors

I would like to wrap the zenoh net into another class. As initialization step, a session has been opened and need to be connected to a zenoh bridge on a remote machine. But as I gives the config a not existing host, the session has also been built without throwing an error. It is a feature, that is not created? Or was I using it wrong?

As I search for zenoh-python, there are actually two kinds of zenoh-python, one is eclipse-zenoh/zenoh-python from here, and another one is atolab/zenoh-python, which is read in c and wrapped in python. This makes a little bit confused. Is this repo not being used?

Include programming language in path used for examples

zenoh supports multiple programming languages and we try to keep examples interoperable and compatible across programming languages. It would be good however, to facilitate selectors across programming languages to include the programming language in the path used by some examples. For instance, if we consider the example that do the write, we could use:

/zenoh/examples/c/write/hello
/zenoh/examples/python/write/hello
/zenoh/examples/rust/write/hello
...

This would allow us to do subscriptions for anything produced by examples of a single language, such as /zenoh/examples/c/** or evaluate evals across multiple languages using /zenoh/examples/*/eval

[Bug] Query.decode_parameters() does not return dictionary

Describe the bug

The Query.decode_parameters() method is supposed to return a dictionary containing the parameters passed in via the query string. However, when trying to get a parameter from the returned object, an exception is thrown, indicating that the object has no attribute get.

IMHO this line in the Query class should read

return super().decode_parameters()

To reproduce

  1. register a Queryable with a handler.
  2. In the handler, try to decode the parameters using Query.decode_parameters().
  3. Try to invoke dict.get(key) on the returned object.

System info

  • Zenoh version: 0.6.0-b1
  • Platform: Ubuntu 22.10 on amd64

Build Read the Docs in pull requests

Describe the release item

The Read the Docs build often breaks in between releases. It should thus be integrated with the CI. The Read the Docs webhook has been enabled in eclipse-zenoh/.eclipsefdn#8. Rather unsurprisingly, the build is failing. This issue will be closed once the build is fixed.

Auto serialization + encoding for Python values

Describe the feature

The feature already exists in the Python API

def __new__(cls, payload: IntoValue, encoding: Encoding=None):
if encoding is None:
if isinstance(payload, Value):
return payload
return Value.autoencode(payload)
else:
if not isinstance(payload, bytes):
raise TypeError("`encoding` was passed, but `payload` is not of type `bytes`")
return Value.new(payload, encoding)
@staticmethod
def autoencode(value: IntoValue) -> 'Value':
"Automatically encodes the value based on its type"
if isinstance(value, IValue):
return Value.new(value.payload, value.encoding)
if isinstance(value, bytes):
return Value.new(value, Encoding.APP_OCTET_STREAM())
if isinstance(value, str):
return Value.new(value.encode(), Encoding.TEXT_PLAIN())
if isinstance(value, int):
return Value.new(f"{value}".encode(), Encoding.APP_INTEGER())
if isinstance(value, float):
return Value.new(f"{value}".encode(), Encoding.APP_FLOAT())
return Value.new(json.dumps(value).encode(), Encoding.APP_JSON())
.
However, in protocol_changes, the encoding has been formally detached from payload. Quoting @milyin:

As far as I understand, the difference between python and rust in this aspect is that in Rust we know the type on compilation stage. So in Rust it's normal to think in this paradigm: pass the value of known type to payload set the encoding corresponding to the type if necessary

But in Python the type of variable is stored inside the variable. So we need a way to serialize arbitrary variable and inform the caller which serializer was used

Also despite that encoding type is detached from serialization operation, there are still set of predefined encoding values whcih actually corresponds to our provided serializers (these ZENOH_INT. ZENOH_STRING, ZENOH_BYTES, etc). So it seems natual to use these values for identifyting serializer.

Maybe it makes sense to update our rust serialization API by adding some function/trait method which associates encoding value to specific serializer. I think unless we have an association between serializer and encoding on Rust we can't correctly provide automatic serialization in Python.

For my part, I agree with @milyin. @Mallets, do you think we should simply drop the autoencode feature in the new Zenoh Python API? This breaking change would be mitigated by Python typing annotations, allowing users to spot and fix the impact before running into a runtime check error.

Problems with "hello world"

Hey so I am trying to run

python3 z_sub.py

and I get the following error:

Traceback (most recent call last):
  File "z_sub.py", line 20, in <module>
    from zenoh import Reliability, SubMode
ImportError: cannot import name 'Reliability' from 'zenoh' (/home/andrzej/.local/lib/python3.8/site-packages/zenoh/__init__.py)

What should I do? Do you think that maybe I have missed versions 0.6 and 0.5? Because even I can't change the zenoh.version for some reasons....

In zenoh-python, example usage seems to be wrong

Hello,

In examples/zenoh/README.md , I am not able to use the examples as shown:

  python3 z_put

As I get a "file not found" error. I am on Mac OS X 10.15.6 and python 3.8.2 , pip3 21.01 (but have seen this issue on Ubuntu 20.04 as well).
Instead I have to go into that directory and do this:

python3 z_put.py

Is there something wrong with my python installation of this package, or is the example wrong?

[Help Wanted] Client unable to put or publish data to Peer ?

Describe the feature

This issue follow on from this discussion.

Context
For a project, I used v0.5 to connect a client node directly to a peer node by using configuration files such as:

# client.json
{
   "id": null,
   "mode": "client",
   "connect": {
      "endpoints": [
         "tcp/localhost:7447"
      ]
   },
   "listen": {
      "endpoints": [
         "tcp/localhost:7448"
      ]
   }
}
# peer.json
{
   "id": null,
   "mode": "peer",
   "connect": {
      "endpoints": [
      ]
   },
   "listen": {
      "endpoints": [
          "tcp/localhost:7447"
      ]
   }
}

Then I would start a sub script with peer.json configuration file and a put script with client.json file:
python z_sub.py -c peer.json
python z_put.py -c client.json

And the peer would see the data put by the client.

My Issue
Since v0.6.0.dev0, the peer cannot see the data.
A router seems to be needed as an intermediary between the peer and the client (which is something I wish to avoid) which contradict what the documentation indicate. The Client definition : A user application using a zenoh API and that connects to a single zenoh router (or a single peer) to communicate with the rest of the system.

My question
Is it a bug from the v0.6 or a intended behavior ?

Documentation Should be Improved

Describe the feature

The API documentation has lost some important information and examples that used to be there. This should be re-instated before ASAP.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.