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.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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)
  15. .await
  16. .context("failed to create venv")?;
  17. let venv = &root.join("examples").join(".env");
  18. std::env::set_var(
  19. "VIRTUAL_ENV",
  20. venv.to_str()
  21. .context("venv path not valid unicode")?
  22. .to_owned(),
  23. );
  24. let orig_path = std::env::var("PATH")?;
  25. let venv_bin = venv.join("bin");
  26. std::env::set_var(
  27. "PATH",
  28. format!(
  29. "{}:{orig_path}",
  30. venv_bin.to_str().context("venv path not valid unicode")?
  31. ),
  32. );
  33. run(&["pip", "install", "--upgrade", "pip"], None)
  34. .await
  35. .context("failed to install pip")?;
  36. run(&["pip", "install", "-r", "requirements.txt"], None)
  37. .await
  38. .context("pip install failed")?;
  39. run(
  40. &["maturin", "develop"],
  41. Some(&root.join("apis").join("python").join("node")),
  42. )
  43. .await
  44. .context("maturin develop failed")?;
  45. let dataflow = Path::new("dataflow.yml");
  46. dora_daemon::Daemon::run_dataflow(dataflow).await?;
  47. Ok(())
  48. }
  49. async fn run(cmd: &[&str], pwd: Option<&Path>) -> eyre::Result<()> {
  50. let mut run = tokio::process::Command::new(cmd[0]);
  51. run.args(&cmd[1..]);
  52. if let Some(pwd) = pwd {
  53. run.current_dir(pwd);
  54. }
  55. if !run.status().await?.success() {
  56. eyre::bail!("failed to run {cmd:?}");
  57. };
  58. Ok(())
  59. }
  60. pub fn set_up_tracing() -> eyre::Result<()> {
  61. // Filter log using `RUST_LOG`. More useful for CLI.
  62. let filter = EnvFilter::from_default_env().or(LevelFilter::DEBUG);
  63. let stdout_log = tracing_subscriber::fmt::layer()
  64. .pretty()
  65. .with_filter(filter);
  66. let registry = Registry::default().with(stdout_log);
  67. tracing::subscriber::set_global_default(registry)
  68. .context("failed to set tracing global subscriber")
  69. }

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