Browse Source

Add terminal input and dora echo

tags/v0.3.6
haixuanTao 1 year ago
parent
commit
7974245108
13 changed files with 214 additions and 5 deletions
  1. +1
    -0
      examples/echo/.gitignore
  2. +16
    -0
      examples/echo/dataflow.yml
  3. +3
    -0
      node-hub/dora-echo/README.md
  4. +11
    -0
      node-hub/dora-echo/dora_echo/__init__.py
  5. +32
    -0
      node-hub/dora-echo/dora_echo/main.py
  6. +28
    -0
      node-hub/dora-echo/pyproject.toml
  7. +2
    -3
      node-hub/pyarrow-assert/pyarrow_assert/main.py
  8. +3
    -2
      node-hub/pyarrow-sender/pyarrow_sender/main.py
  9. +3
    -0
      node-hub/terminal-input/README.md
  10. +28
    -0
      node-hub/terminal-input/pyproject.toml
  11. +11
    -0
      node-hub/terminal-input/terminal_input/__init__.py
  12. +74
    -0
      node-hub/terminal-input/terminal_input/main.py
  13. +2
    -0
      node-hub/terminal-input/tests/test.py

+ 1
- 0
examples/echo/.gitignore View File

@@ -0,0 +1 @@
*.pt

+ 16
- 0
examples/echo/dataflow.yml View File

@@ -0,0 +1,16 @@
nodes:
- id: terminal-input
build: pip install -e ../../node-hub/terminal-input
path: dynamic
outputs:
- data
inputs:
echo: dora-echo/echo

- id: dora-echo
build: pip install -e ../../node-hub/dora-echo
path: dora-echo
inputs:
input: terminal-input/data
outputs:
- echo

+ 3
- 0
node-hub/dora-echo/README.md View File

@@ -0,0 +1,3 @@
# Dora echo node

This node will just echo whatever it receives as is.

+ 11
- 0
node-hub/dora-echo/dora_echo/__init__.py View File

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

# Define the path to the README file relative to the package directory
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md")

# Read the content of the README file
try:
with open(readme_path, "r", encoding="utf-8") as f:
__doc__ = f.read()
except FileNotFoundError:
__doc__ = "README file not found."

+ 32
- 0
node-hub/dora-echo/dora_echo/main.py View File

@@ -0,0 +1,32 @@
import argparse
import os
from dora import Node

RUNNER_CI = True if os.getenv("CI") == "true" else False


def main():

# Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables.
parser = argparse.ArgumentParser(description="Simple arrow sender")

parser.add_argument(
"--name",
type=str,
required=False,
help="The name of the node in the dataflow.",
default="echo",
)
args = parser.parse_args()

node = Node(
args.name
) # provide the name to connect to the dataflow if dynamic node

for event in node:
if event["type"] == "INPUT":
node.send_output("echo", event["value"])


if __name__ == "__main__":
main()

+ 28
- 0
node-hub/dora-echo/pyproject.toml View File

@@ -0,0 +1,28 @@
[tool.poetry]
name = "dora-echo"
version = "0.3.5"
authors = [
"Haixuan Xavier Tao <tao.xavier@outlook.com>",
"Enzo Le Van <dev@enzo-le-van.fr>",
]
description = "Dora echo"
license = "MIT License"
homepage = "https://github.com/dora-rs/dora.git"
documentation = "https://github.com/dora-rs/dora/blob/main/node-hub/dora-echo/README.md"
readme = "README.md"
packages = [{ include = "dora_echo" }]

[tool.poetry.dependencies]
dora-rs = "0.3.5"
numpy = "< 2.0.0"
pyarrow = ">= 5.0.0"

[tool.poetry.scripts]
dora-echo = "dora_echo.main:main"

[build-system]
requires = ["poetry-core>=1.8.0"]
build-backend = "poetry.core.masonry.api"

[project]
readme = "README.md"

+ 2
- 3
node-hub/pyarrow-assert/pyarrow_assert/main.py View File

@@ -1,8 +1,7 @@
import argparse
import os
import ast

import numpy as np
import pyarrow as pa

from dora import Node

@@ -37,7 +36,7 @@ def main():
args.name
) # provide the name to connect to the dataflow if dynamic node

assert_data = eval(data)
assert_data = ast.literal_eval(data)

for event in node:
if event["type"] == "INPUT":


+ 3
- 2
node-hub/pyarrow-sender/pyarrow_sender/main.py View File

@@ -1,5 +1,6 @@
import argparse
import os
import ast

import pyarrow as pa

@@ -41,7 +42,7 @@ def main():
data = input(
"Provide the data you want to send: ",
)
data = eval(data)
data = ast.literal_eval(data)
if isinstance(data, list):
data = pa.array(data) # initialize pyarrow array
elif isinstance(data, str):
@@ -54,7 +55,7 @@ def main():
data = pa.array(data) # initialize pyarrow array
node.send_output("data", data)
else:
data = eval(data)
data = ast.literal_eval(data)
if isinstance(data, list):
data = pa.array(data) # initialize pyarrow array
elif isinstance(data, str):


+ 3
- 0
node-hub/terminal-input/README.md View File

@@ -0,0 +1,3 @@
# Dora Node for sending terminal input data.

This node send the data that is given to him within a terminal window.

+ 28
- 0
node-hub/terminal-input/pyproject.toml View File

@@ -0,0 +1,28 @@
[tool.poetry]
name = "terminal-input"
version = "0.3.5"
authors = [
"Haixuan Xavier Tao <tao.xavier@outlook.com>",
"Enzo Le Van <dev@enzo-le-van.fr>",
]
description = "Dora terminal input"
license = "MIT License"
homepage = "https://github.com/dora-rs/dora.git"
documentation = "https://github.com/dora-rs/dora/blob/main/node-hub/terminal-input/README.md"
readme = "README.md"
packages = [{ include = "terminal_input" }]

[tool.poetry.dependencies]
dora-rs = "0.3.5"
numpy = "< 2.0.0"
pyarrow = ">= 5.0.0"

[tool.poetry.scripts]
terminal-input = "terminal_input.main:main"

[build-system]
requires = ["poetry-core>=1.8.0"]
build-backend = "poetry.core.masonry.api"

[project]
readme = "README.md"

+ 11
- 0
node-hub/terminal-input/terminal_input/__init__.py View File

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

# Define the path to the README file relative to the package directory
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md")

# Read the content of the README file
try:
with open(readme_path, "r", encoding="utf-8") as f:
__doc__ = f.read()
except FileNotFoundError:
__doc__ = "README file not found."

+ 74
- 0
node-hub/terminal-input/terminal_input/main.py View File

@@ -0,0 +1,74 @@
import argparse
import os
import ast

import pyarrow as pa

from dora import Node

RUNNER_CI = True if os.getenv("CI") == "true" else False


def main():

# Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables.
parser = argparse.ArgumentParser(description="Simple arrow sender")

parser.add_argument(
"--name",
type=str,
required=False,
help="The name of the node in the dataflow.",
default="terminal-input",
)
parser.add_argument(
"--data",
type=str,
required=False,
help="Arrow Data as string.",
default=None,
)

args = parser.parse_args()

data = os.getenv("DATA", args.data)

node = Node(
args.name
) # provide the name to connect to the dataflow if dynamic node

if data is None and os.getenv("DORA_NODE_CONFIG") is None:
while True:
data = input(
"Provide the data you want to send: ",
)
data = ast.literal_eval(data)
if isinstance(data, list):
data = pa.array(data) # initialize pyarrow array
elif isinstance(data, str):
data = pa.array([data])
elif isinstance(data, int):
data = pa.array([data])
elif isinstance(data, float):
data = pa.array([data])
elif isinstance(data, dict):
data = pa.array([data])
else:
data = pa.array(data) # initialize pyarrow array
node.send_output("data", data)
event = node.next(timeout=0.2)
if event is not None:
print(f"Received: {event['value'].to_pylist()}")
else:
data = ast.literal_eval(data)
if isinstance(data, list):
data = pa.array(data) # initialize pyarrow array
elif isinstance(data, str):
data = pa.array([data])
else:
data = pa.array(data) # initialize pyarrow array
node.send_output("data", data)


if __name__ == "__main__":
main()

+ 2
- 0
node-hub/terminal-input/tests/test.py View File

@@ -0,0 +1,2 @@
def test_placeholder():
pass

Loading…
Cancel
Save