| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
26c39eaefb
|
Use `just` tool to run rust-dataflow example | 1 year ago |
| @@ -110,12 +110,15 @@ jobs: | |||||
| save-if: ${{ github.ref == 'refs/heads/main' }} | save-if: ${{ github.ref == 'refs/heads/main' }} | ||||
| # general examples | # general examples | ||||
| - run: cargo install just --locked | |||||
| - name: "Rust Dataflow example" | |||||
| timeout-minutes: 30 | |||||
| working-directory: examples/rust-dataflow | |||||
| run: just run | |||||
| - name: "Build examples" | - name: "Build examples" | ||||
| timeout-minutes: 30 | timeout-minutes: 30 | ||||
| run: cargo build --examples | run: cargo build --examples | ||||
| - name: "Rust Dataflow example" | |||||
| timeout-minutes: 30 | |||||
| run: cargo run --example rust-dataflow | |||||
| - name: "Multiple Daemons example" | - name: "Multiple Daemons example" | ||||
| timeout-minutes: 30 | timeout-minutes: 30 | ||||
| run: cargo run --example multiple-daemons | run: cargo run --example multiple-daemons | ||||
| @@ -101,10 +101,6 @@ tokio-stream = "0.1.11" | |||||
| name = "c-dataflow" | name = "c-dataflow" | ||||
| path = "examples/c-dataflow/run.rs" | path = "examples/c-dataflow/run.rs" | ||||
| [[example]] | |||||
| name = "rust-dataflow" | |||||
| path = "examples/rust-dataflow/run.rs" | |||||
| [[example]] | [[example]] | ||||
| name = "rust-ros2-dataflow" | name = "rust-ros2-dataflow" | ||||
| path = "examples/rust-ros2-dataflow/run.rs" | path = "examples/rust-ros2-dataflow/run.rs" | ||||
| @@ -0,0 +1 @@ | |||||
| out | |||||
| @@ -0,0 +1,6 @@ | |||||
| # Rust Dataflow Example | |||||
| This example uses the [`just`](https://github.com/casey/just) tool for building and running the dataflow: | |||||
| - Build: `just build` | |||||
| - Run: `just run` | |||||
| @@ -0,0 +1,12 @@ | |||||
| # you can use the installed `dora` command instead of this `cargo run` command | |||||
| dora := "cargo run -p dora-cli --" | |||||
| # build dora and the example nodes/operators | |||||
| build: | |||||
| {{ dora }} build dataflow.yml | |||||
| # build and run the dataflow example | |||||
| run: build | |||||
| # The `--run-dataflow` argument is mostly meant for testing. It's recommended | |||||
| # to instead run `dora daemon` in one terminal and `dora start dataflow.yml` in another | |||||
| RUST_LOG=debug {{ dora }} daemon --run-dataflow dataflow.yml | |||||
| @@ -1,46 +0,0 @@ | |||||
| use dora_tracing::set_up_tracing; | |||||
| use eyre::{bail, Context}; | |||||
| use std::path::Path; | |||||
| #[tokio::main] | |||||
| async fn main() -> eyre::Result<()> { | |||||
| set_up_tracing("rust-dataflow-runner").wrap_err("failed to set up tracing subscriber")?; | |||||
| let root = Path::new(env!("CARGO_MANIFEST_DIR")); | |||||
| std::env::set_current_dir(root.join(file!()).parent().unwrap()) | |||||
| .wrap_err("failed to set working dir")?; | |||||
| let dataflow = Path::new("dataflow.yml"); | |||||
| build_dataflow(dataflow).await?; | |||||
| run_dataflow(dataflow).await?; | |||||
| Ok(()) | |||||
| } | |||||
| async fn build_dataflow(dataflow: &Path) -> eyre::Result<()> { | |||||
| let cargo = std::env::var("CARGO").unwrap(); | |||||
| let mut cmd = tokio::process::Command::new(&cargo); | |||||
| cmd.arg("run"); | |||||
| cmd.arg("--package").arg("dora-cli"); | |||||
| cmd.arg("--").arg("build").arg(dataflow); | |||||
| if !cmd.status().await?.success() { | |||||
| bail!("failed to build dataflow"); | |||||
| }; | |||||
| Ok(()) | |||||
| } | |||||
| async fn run_dataflow(dataflow: &Path) -> eyre::Result<()> { | |||||
| let cargo = std::env::var("CARGO").unwrap(); | |||||
| let mut cmd = tokio::process::Command::new(&cargo); | |||||
| cmd.arg("run"); | |||||
| cmd.arg("--package").arg("dora-cli"); | |||||
| cmd.arg("--") | |||||
| .arg("daemon") | |||||
| .arg("--run-dataflow") | |||||
| .arg(dataflow); | |||||
| if !cmd.status().await?.success() { | |||||
| bail!("failed to run dataflow"); | |||||
| }; | |||||
| Ok(()) | |||||
| } | |||||