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

Regarding the delivery of events in Dora. #747

Open
chengzi0103 opened this issue Jan 7, 2025 · 2 comments
Open

Regarding the delivery of events in Dora. #747

chengzi0103 opened this issue Jan 7, 2025 · 2 comments

Comments

@chengzi0103
Copy link

In the add-numbers node, I use a while True loop to continuously retrieve the value of num2. After successfully obtaining the value of num2, I attempt to use the same method to retrieve the value of num1, but I find that num1 is no longer available and has become None. Could you provide a detailed explanation of the event delivery mechanism and its underlying logic?

Environments

  • System info: mac os
  • Dora version: 0.3.8

Additional context

The dataflow configuration is as follows:

nodes:
  - id: terminal-input
    build: pip install -e ../../node-hub/terminal-input
    path: dynamic
    outputs:
      - data
    inputs:
      add_numbers_result: add-numbers/add_numbers_result
      multiply_numbers_result: multiply-numbers/multiply_numbers_result
  - id: multiply-numbers
    build: pip install -e ../../agent-hub/multiply-numbers
    path: multiply-numbers
    outputs:
      - multiply_numbers_result
    inputs:
      num1: terminal-input/data
    env:
      IS_DATAFLOW_END: false
  - id: add-numbers
    build: pip install -e ../../agent-hub/add-numbers
    path: add-numbers
    outputs:
      - add_numbers_result
    inputs:
      num1: terminal-input/data
      num2: multiply-numbers/multiply_numbers_result
    env:
      IS_DATAFLOW_END: true
  1. Add Logging:
    add-numbers-nodes-logs:

    num2 : 40
    num1 : None

@ayushshrivastv
Copy link

To fix this, store num1 when it is first received (using the on_input callback) and wait for num2 to arrive before performing the addition. Avoid while True loops; rely on event triggers to manage state. Ensure nodes handle inputs asynchronously, preserving data between events for correct computation.

@ayushshrivastv
Copy link

What’s happening here is that when the first number is received from the terminal input or data, it’s consumed by the add-numbers function. By the time the second number, num2, arrives, num1 is no longer available, so it returns None.

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

No branches or pull requests

2 participants