Skip to content

Fix dora runtime spawn command for dora installed through pip#940

Closed
phil-opp wants to merge 1 commit intomainfrom
fix-pip-dora-runtime-call
Closed

Fix dora runtime spawn command for dora installed through pip#940
phil-opp wants to merge 1 commit intomainfrom
fix-pip-dora-runtime-call

Conversation

@phil-opp
Copy link
Copy Markdown
Collaborator

@phil-opp phil-opp commented Apr 3, 2025

Pip installations of dora use a small Python wrapper script, which then calls a functions of the dora_cli module. This means that the current_exe() will be a python binary instead of a standalone dora binary. This leads to errors when trying to start a dora runtime instance for shared library operators (see #900).

This commit fixes this issue by introducing a new DoraCommand struct that is initialized in the respective main function. For normal Rust binaries, this is just initialized with current_exe() as before. When invoked from Python, we also include the first argument, which should be the path to the Python wrapper script invoking dora. We also use the 0th argument instead of current_exe for invoking the python binary because current_exe resolves symlinks on some platforms, which affects import statements (different base directory).

Fixes #900

Pip installations of dora use a small Python wrapper script, which then calls a functions of the `dora_cli` module. This means that the `current_exe()` will be a python binary instead of a standalone `dora` binary. This leads to errors when trying to start a `dora runtime` instance for shared library operators (see #900).

This commit fixes this issue by introducing a new `DoraCommand` struct that is initialized in the respective main function. For normal Rust binaries, this is just initialized with `current_exe()` as before. When invoked from Python, we also include the first argument, which should be the path to the Python wrapper script invoking dora. We also use the 0th argument instead of `current_exe` for invoking the `python` binary because `current_exe` resolves symlinks on some platforms, which affects import statements (different base directory).

Fixes #900
@phil-opp phil-opp force-pushed the fix-pip-dora-runtime-call branch from f7c76c1 to ac23cb4 Compare April 3, 2025 13:13
.build()
.context("tokio runtime failed")?;
let result = rt.block_on(Daemon::run_dataflow(&dataflow_path, uv.unwrap_or_default()))?;
let dora_command = DoraCommand::from_python_env()?;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is suppose to be run within a python script unrelated to the cli.

I'm slightly confused, why do we need dora command in this case. Is this to find the runtime python path?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be able to invoke the Dora CLI when there are any operators present in the dataflow. Operators are run by a dora runtime process, which we need to spawn.

This spawn command differs based on how Dora was installed. If it was installed as a normal binary, we can use current_exe to get the path to the binary. For Python-based installations, this points to a python executable instead.

Either way, you're totally right that this is the wrong approach. Dora might still be installed as a normal binary even if the run command is invoked from Python. Or even worse, Dora might not be installed at all....

@haixuanTao
Copy link
Copy Markdown
Collaborator

FYI, I have fixed this issue for the daemon and the coordinator with:

fn start_daemon() -> eyre::Result<()> {
    let path = if cfg!(feature = "python") {
        std::env::args_os()
            .nth(1)
            .context("Could not get first argument correspond to dora with python installation")?
    } else {
        std::env::args_os()
            .next()
            .context("Could not get dora path")?
    };
    let mut cmd = Command::new(path);
    cmd.arg("daemon");
    cmd.arg("--quiet");
    cmd.spawn().wrap_err("failed to run `dora daemon`")?;

    println!("started dora daemon");

    Ok(())
}

I think this changes creates a lot of additional argument changes that can be annoying down the line.

@phil-opp
Copy link
Copy Markdown
Collaborator Author

FYI, I have fixed this issue for the daemon and the coordinator with:

Unfortunately, that's different because this is invoked from the CLI directly.

The run function, on the other hand, is part of the node API. So the dora CLI might not even be installed. But in order to run dataflows with operators, we need a way to spawn the dora runtime as a process. Do you have any idea how we can achieve this reliably?

One simple approach could be to just invoke dora and require that it's in the PATH. This seems a bit hacky and restricting, though.

@haixuanTao
Copy link
Copy Markdown
Collaborator

I have opened a simpler PR that I have tested on c++ dataflow example: #1011

haixuanTao added a commit that referenced this pull request Jun 3, 2025
)

This PR fixes #900 by checking the current exe of the daemon. 

If the daemon is running on python => spawn the runtime on python.
If the daemon is running on a dora binary => use current dora binary.

Alternative to #940
@phil-opp
Copy link
Copy Markdown
Collaborator Author

Closed in favor of #1011

@phil-opp phil-opp closed this Jun 23, 2025
@haixuanTao haixuanTao deleted the fix-pip-dora-runtime-call branch November 7, 2025 06:35
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

Successfully merging this pull request may close these issues.

errror about operator node in C++

2 participants