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

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

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