Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to insert manual input during the execution of Dora? #565

Open
chengzi0103 opened this issue Jun 25, 2024 · 21 comments
Open

How to insert manual input during the execution of Dora? #565

chengzi0103 opened this issue Jun 25, 2024 · 21 comments
Labels
bug Something isn't working python Python API

Comments

@chengzi0103
Copy link

Describe the bug
I want to determine during the execution of a Dora workflow whether some content needs manual intervention based on certain conditions. Following the example from https://github.com/dora-rs/dora/blob/main/examples/python-operator-dataflow/keyboard_op.py, I built a workflow myself. However, during the execution of the workflow, manual input was not integrated, and I am not sure where the issue lies. Additionally, I noticed that in your example, after using keyboard_op.py, manual input is possible. I want to know how I can solve this problem.

Expected behavior

Screenshots or Video
dora_run_pic

Environments (please complete the following information):

  • System info: Wsl-Ubuntu 22.04
  • Dora version: 0.3.4
  • Python version: 3.11.9

Additional context
I have uploaded my workflow files in a compressed folder. Could you please help check if there are any issues?
keyboard.zip

@github-actions github-actions bot added bug Something isn't working python Python API labels Jun 25, 2024
@DuinoDu
Copy link

DuinoDu commented Jun 25, 2024

I tried your keyboard.zip on mac and keyboard input can be captured by dora.

2024-06-25.15.32.37.mov

Is that what you expect?

I also tried on wsl2-ubuntu, but found error when install pynput. pynput seems not working well on wsl2.

@haixuanTao
Copy link
Collaborator

We're going to merge #559 and later release a release candidate for 0.3.5 that you will be able to try with dynamic nodes.

@chengzi0103
Copy link
Author

I tried your keyboard.zip on mac and keyboard input can be captured by dora.

2024-06-25.15.32.37.mov
Is that what you expect?

I also tried on wsl2-ubuntu, but found error when install pynput. pynput seems not working well on wsl2.

Thank you for your reply, I apologize for the late response.
In our WSL/VM environment, we are unable to control hardware using Pynput.
I suspect this is due to security considerations in these environments, as they typically do not allow direct access to the underlying hardware. This is what leads to our inability to use them in the virtual environment.
Below is the error message we received:

Traceback (most recent call last):
  File "/tmp/cc/experiment_project/experiment_project/moxin/keyboard/keyboard_op.py", line 1, in <module>
    from pynput import keyboard
  File "/root/miniconda3/lib/python3.12/site-packages/pynput/__init__.py", line 40, in <module>
    from . import keyboard
  File "/root/miniconda3/lib/python3.12/site-packages/pynput/keyboard/__init__.py", line 31, in <module>
    backend = backend(__name__)
              ^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/site-packages/pynput/_util/__init__.py", line 77, in backend
    raise ImportError('this platform is not supported: {}'.format(
ImportError: this platform is not supported: ('failed to acquire X connection: Bad display name ""', DisplayNameError(''))

Try one of the following resolutions:

 * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly

@haixuanTao
Copy link
Collaborator

I understand could you try dynamic node: https://github.com/dora-rs/dora/releases/tag/v0.3.5 ?

@chengzi0103
Copy link
Author

I understand could you try dynamic node: https://github.com/dora-rs/dora/releases/tag/v0.3.5 ?

Okay, I have tried it. When I used dora-cli with version 0.3.5-rc0, and I updated my Python-dora through the command pip install dora-rs==0.3.5 --force, it resulted in an error. I don't know what caused it. Currently, I am still testing in a VM (Virtual Machine) environment



[ERROR]
Dataflow could not be validated.

dora-rc-error

@chengzi0103
Copy link
Author

I understand could you try dynamic node: https://github.com/dora-rs/dora/releases/tag/v0.3.5 ?

Okay, I have tried it. When I used dora-cli with version 0.3.5-rc0, and I updated my Python-dora through the command pip install dora-rs==0.3.5 --force, it resulted in an error. I don't know what caused it. Currently, I am still testing in a VM (Virtual Machine) environment



[ERROR]
Dataflow could not be validated.

dora-rc-error

When I reinstalled dora-cli using cargo install dora-cli --locked, the same issue occurred

@haixuanTao
Copy link
Collaborator

Could you run:

cargo install dora-cli==0.3.5 --locked
pip install dora-rs==0.3.5

?

@chengzi0103
Copy link
Author

chengzi0103 commented Jul 4, 2024

pip install dora-rs==0.3.5

After I used the command cargo install dora-cli --version 0.3.5 --locked

error: could not find dora-cli==0.3.5 in registry crates-io with version *

@haixuanTao
Copy link
Collaborator

You can also use:

export DORA_VERSION=v0.3.5 # Check for the latest release
export ARCHITECTURE=$(uname -m)
wget https://github.com/dora-rs/dora/releases/download/${DORA_VERSION}/dora-${DORA_VERSION}-${ARCHITECTURE}-Linux.zip
unzip dora-${DORA_VERSION}-${ARCHITECTURE}-Linux.zip
pip install dora-rs==${DORA_VERSION}
PATH=$PATH:$(pwd)
dora --help

@chengzi0103
Copy link
Author

You can also use:您还可以使用:用途:

export DORA_VERSION=v0.3.5 # Check for the latest release
export ARCHITECTURE=$(uname -m)
wget https://github.com/dora-rs/dora/releases/download/${DORA_VERSION}/dora-${DORA_VERSION}-${ARCHITECTURE}-Linux.zip
unzip dora-${DORA_VERSION}-${ARCHITECTURE}-Linux.zip
pip install dora-rs==${DORA_VERSION}
PATH=$PATH:$(pwd)
dora --help

This is the version information below.
dora-version

@haixuanTao
Copy link
Collaborator

Sorry you need to do:

dora destroy
dora up

After a version update

@chengzi0103
Copy link
Author

Sorry you need to do:对不起,您需要做:

dora destroy
dora up

After a version update版本更新后

Okay, thank you. The process has started normally

@chengzi0103
Copy link
Author

I understand could you try dynamic node: https://github.com/dora-rs/dora/releases/tag/v0.3.5 ?我知道你能试试动态节点:https://github.com/dora-rs/dora/releases/tag/v0.3.5吗?

When I use the example from [https://github.com/dora-rs/dora-rs.github.io/blob/v0.3.5/docs/guides/Development/dynamic-node.md], I encountered several issues:

I cannot terminate the dataflow using dora stop.
After using dora destroy && dora up to restart the dataflow, and then using:
from dora import Node
node = Node("node_0")
event = node.next()
print(event)
I still cannot retrieve the messages corresponding to the node_id

>>> from dora import Node
>>> node = Node("node_0") 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: Could not setup node from node id. Make sure to have a running dataflow with this dynamic node

Caused by:
    failed to get node config from daemon: no node with ID `{node_id}`

Location:
    apis/rust/node/src/node/mod.rs:101:17

This is the dataflow I am currently running

dora list 
UUID                                  Name     Status
01907ce7-4513-7003-af5a-ef13a79d37db  dynamic  Running

@haixuanTao
Copy link
Collaborator

The node_0 from the node id is probably wrong. Are you sure your using the right node id?

@chengzi0103
Copy link
Author

The node_0 from the node id is probably wrong. Are you sure your using the right node id?节点ID中的node_0可能是错误的。你确定你使用的是正确的节点ID吗?

dataflow.yml

nodes:
  - id: node_0
    path: dynamic # <-- We need to define the path: dynamic for dynamic node
    inputs:
      tick: dora/timer/millis/50

@haixuanTao
Copy link
Collaborator

haixuanTao commented Jul 4, 2024

So our CI is passing on this:

dora start ../examples/python-dataflow/dataflow_dynamic.yml --name ci-python-dynamic --detach
python ../examples/python-dataflow/plot_dynamic.py

Could you check if you can run this from this repo:

pip install "numpy<2.0.0" opencv-python
dora start examples/python-dataflow/dataflow_dynamic.yml --name ci-python-dynamic --detach
python examples/python-dataflow/plot_dynamic.py

@chengzi0103
Copy link
Author

So our CI is passing on this:所以我们的线人会告诉你

dora start ../examples/python-dataflow/dataflow_dynamic.yml --name ci-python-dynamic --detach
python ../examples/python-dataflow/plot_dynamic.py

Could you check if you can run this from this repo:您能否检查是否可以从该存储库运行此操作:

pip install "numpy<2.0.0" opencv-python
dora start examples/python-dataflow/dataflow_dynamic.yml --name ci-python-dynamic --detach
python examples/python-dataflow/plot_dynamic.py

Thank you for your reply. After I restarted the process, I successfully ran your example. Thanks. But now I have another issue: How do I stop this dataflow? When I use dora stop 'dataflow_id', it gets stuck

@haixuanTao
Copy link
Collaborator

I wonder if this is linked to #575 .

You are on WSL right?

@chengzi0103
Copy link
Author

I wonder if this is linked to #575 .

You are on WSL right?

Yes, I have tried both in WSL and VM, and this problem has occurred in both cases. System version: Ubuntu 22.04
I think it is consistent with the issue in #575

@haixuanTao
Copy link
Collaborator

haixuanTao commented Jul 5, 2024

Ok, interesting.

For examples/python-dataflow/dataflow_dynamic.yml after 10 second, the dataflow should stop on its own.

Because of:

# Run for 20 seconds
while time.time() - start < 10:

Could you try to set the same logic in your usecase. I am going to fix #575 on a follow up PR.

@chengzi0103
Copy link
Author

Ok, interesting. 好吧,有趣。

For examples/python-dataflow/dataflow_dynamic.yml after 10 second, the dataflow should stop on its own.对于 10 秒后的 examples/python-dataflow/dataflow_dynamic.yml ,数据流应自行停止。

Because of: 因为:

# Run for 20 seconds
while time.time() - start < 10:

Could you try to set the same logic in your usecase. I am going to fix #575 on a follow up PR.您可以尝试在您的用例中设置相同的逻辑吗?我将在后续 PR 中修复 #575

Okay, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Python API
Projects
None yet
Development

No branches or pull requests

3 participants