Browse Source

Remove legacy python example

tags/v0.0.0-test.4
haixuanTao 3 years ago
parent
commit
b91b6db3f4
5 changed files with 0 additions and 123 deletions
  1. +0
    -29
      binaries/coordinator/examples/graphs/python_test.yml
  2. +0
    -8
      binaries/coordinator/examples/nodes/python/printer.py
  3. +0
    -11
      binaries/coordinator/examples/nodes/python/static_string.py
  4. +0
    -36
      examples/python-operator/op.py
  5. +0
    -39
      examples/python-operator/op2.py

+ 0
- 29
binaries/coordinator/examples/graphs/python_test.yml View File

@@ -1,29 +0,0 @@
communication:
zenoh:
prefix: /foo

nodes:
- id: static-string
custom:
run: python examples/nodes/python/static_string.py
outputs:
- string

- id: python-printer
custom:
run: python examples/nodes/python/printer.py
inputs:
string: static-string/string
time2: rust-timer/time
- id: rust-timer
custom:
run: cargo run --example source_timer
outputs:
- time

- id: rust-logger
custom:
run: cargo run --example sink_logger
inputs:
time: static-string/string

+ 0
- 8
binaries/coordinator/examples/nodes/python/printer.py View File

@@ -1,8 +0,0 @@
from dora import Node

node = Node()

for id, value in node:
print(f"From Python, id: {id}, value: {value}") if value is not [] else None

print("printer finished")

+ 0
- 11
binaries/coordinator/examples/nodes/python/static_string.py View File

@@ -1,11 +0,0 @@
import time

from dora import Node

node = Node()

for i in range(100):
node.send_output("string", b"Hello World")
time.sleep(0.1)

print("static string finished")

+ 0
- 36
examples/python-operator/op.py View File

@@ -1,36 +0,0 @@
from typing import Callable
from enum import Enum

class DoraStatus(Enum):
CONTINUE = 0
STOP = 1

class Operator:
"""
Example operator incrementing a counter every times its been called.

The current value of the counter is sent back to dora on `counter`.
"""

def __init__(self, counter=0):
self.counter = counter

def on_input(
self,
input_id: str,
value: bytes,
send_output: Callable[[str, bytes], None],
):
"""Handle input by incrementing count by one.

Args:
input_id (str): Id of the input declared in the yaml configuration
value (bytes): Bytes message of the input
send_output (Callable[[str, bytes]]): Function enabling sending output back to dora.
"""
val_len = len(value)
print(f"PYTHON received input {input_id}; value length: {val_len}")
send_output("counter", (self.counter % 256).to_bytes(1, "little"))
self.counter = self.counter + 1

return DoraStatus.OK

+ 0
- 39
examples/python-operator/op2.py View File

@@ -1,39 +0,0 @@
from typing import Callable
from enum import Enum

class DoraStatus(Enum):
OK = 0
STOP = 1

class Operator:
"""
Example operator incrementing a counter every times its been called.

The current value of the counter is sent back to dora on `counter`.
"""

def __init__(self, counter=0):
self.counter = counter

def on_input(
self,
input_id: str,
value: bytes,
send_output: Callable[[str, bytes], None],
):
"""Handle input by incrementing count by one.

Args:
input_id (str): Id of the input declared in the yaml configuration
value (bytes): Bytes message of the input
send_output (Callable[[str, bytes]]): Function enabling sending output back to dora.
"""
val_len = len(value)
print(f"PYTHON received input {input_id}; value length: {val_len}")
send_output("counter", (self.counter % 256).to_bytes(1, "little"))
self.counter = self.counter + 1

if self.counter > 500:
return DoraStatus.STOP
else:
return DoraStatus.OK

Loading…
Cancel
Save