You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

run.rs 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. use eyre::{ContextCompat, WrapErr};
  2. use std::path::Path;
  3. use tracing_subscriber::{
  4. filter::{FilterExt, LevelFilter},
  5. prelude::*,
  6. EnvFilter, Registry,
  7. };
  8. #[tokio::main]
  9. async fn main() -> eyre::Result<()> {
  10. set_up_tracing()?;
  11. let root = Path::new(env!("CARGO_MANIFEST_DIR"));
  12. std::env::set_current_dir(root.join(file!()).parent().unwrap())
  13. .wrap_err("failed to set working dir")?;
  14. run(&["python3", "-m", "venv", "../.env"], None).await?;
  15. let venv = &root.join("examples").join(".env");
  16. std::env::set_var(
  17. "VIRTUAL_ENV",
  18. venv.to_str()
  19. .context("venv path not valid unicode")?
  20. .to_owned(),
  21. );
  22. let orig_path = std::env::var("PATH")?;
  23. let venv_bin = venv.join("bin");
  24. std::env::set_var(
  25. "PATH",
  26. format!(
  27. "{}:{orig_path}",
  28. venv_bin.to_str().context("venv path not valid unicode")?
  29. ),
  30. );
  31. run(&["pip", "install", "--upgrade", "pip"], None).await?;
  32. run(&["pip", "install", "-r", "requirements.txt"], None).await?;
  33. run(&["maturin", "develop"], Some(&root.join("python"))).await?;
  34. let dataflow = Path::new("dataflow.yml");
  35. dora_daemon::Daemon::run_dataflow(dataflow).await?;
  36. Ok(())
  37. }
  38. async fn run(cmd: &[&str], pwd: Option<&Path>) -> eyre::Result<()> {
  39. let mut run = tokio::process::Command::new(cmd[0]);
  40. run.args(&cmd[1..]);
  41. if let Some(pwd) = pwd {
  42. run.current_dir(pwd);
  43. }
  44. if !run.status().await?.success() {
  45. eyre::bail!("failed to run {cmd:?}");
  46. };
  47. Ok(())
  48. }
  49. pub fn set_up_tracing() -> eyre::Result<()> {
  50. // Filter log using `RUST_LOG`. More useful for CLI.
  51. let filter = EnvFilter::from_default_env().or(LevelFilter::DEBUG);
  52. let stdout_log = tracing_subscriber::fmt::layer()
  53. .pretty()
  54. .with_filter(filter);
  55. let registry = Registry::default().with(stdout_log);
  56. tracing::subscriber::set_global_default(registry)
  57. .context("failed to set tracing global subscriber")
  58. }

DORA (Dataflow-Oriented Robotic Architecture) is middleware designed to streamline and simplify the creation of AI-based robotic applications. It offers low latency, composable, and distributed datafl