Skip to content

Commit

Permalink
Enable multiline build for better packaging of dora node. (#683)
Browse files Browse the repository at this point in the history
It is necessary to make build multiline in order to build certain node. 

This allow users to do the following:

```bash
nodes:
  - id: dora-microphone
    build: |
      pip install -e ../../node-hub/dora-microphones
      pip install -e ../../node-hub/dora-vad
    path: dora-microphone
```

or

```bash
nodes:
  - id: dora-microphone
    build: |
      sudo apt install abc
      pip install bar
    path: dora-microphone
```
  • Loading branch information
haixuanTao authored Oct 11, 2024
2 parents 903cb23 + bf06c5c commit a254d70
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
32 changes: 17 additions & 15 deletions binaries/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,24 @@ pub fn build(dataflow: String) -> eyre::Result<()> {

fn run_build_command(build: Option<&str>, working_dir: &Path) -> eyre::Result<()> {
if let Some(build) = build {
let mut split = build.split_whitespace();
let mut cmd = Command::new(
split
.next()
.ok_or_else(|| eyre!("build command is empty"))?,
);
cmd.args(split);
cmd.current_dir(working_dir);
let exit_status = cmd
.status()
.wrap_err_with(|| format!("failed to run `{}`", build))?;
if exit_status.success() {
Ok(())
} else {
Err(eyre!("build command returned an error code"))
let lines = build.lines().collect::<Vec<_>>();
for build_line in lines {
let mut split = build_line.split_whitespace();
let mut cmd = Command::new(
split
.next()
.ok_or_else(|| eyre!("build command is empty"))?,
);
cmd.args(split);
cmd.current_dir(working_dir);
let exit_status = cmd
.status()
.wrap_err_with(|| format!("failed to run `{}`", build))?;
if !exit_status.success() {
return Err(eyre!("build command `{build_line}` returned {exit_status}"));
}
}
Ok(())
} else {
Ok(())
}
Expand Down
6 changes: 6 additions & 0 deletions tests/multiline_build/dataflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
nodes:
- id: dora-microphone
build: |
pip install -e ../../node-hub/dora-microphones
pip install -e ../../node-hub/dora-vad
path: dora-microphone

0 comments on commit a254d70

Please sign in to comment.