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 1.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. use dora_tracing::set_up_tracing;
  2. use eyre::{ContextCompat, WrapErr};
  3. use std::path::Path;
  4. #[tokio::main]
  5. async fn main() -> eyre::Result<()> {
  6. set_up_tracing("python-operator-dataflow-runner")?;
  7. let root = Path::new(env!("CARGO_MANIFEST_DIR"));
  8. std::env::set_current_dir(root.join(file!()).parent().unwrap())
  9. .wrap_err("failed to set working dir")?;
  10. run(
  11. &[
  12. get_python_path()
  13. .context("Could not get python binary")?
  14. .to_str()
  15. .context("Could not convert python path to string")?,
  16. "-m",
  17. "venv",
  18. ".env",
  19. ],
  20. None,
  21. )
  22. .await
  23. .context("failed to create venv")?;
  24. let venv = &root.join("examples").join(".env");
  25. std::env::set_var(
  26. "VIRTUAL_ENV",
  27. venv.to_str().context("venv path not valid unicode")?,
  28. );
  29. let orig_path = std::env::var("PATH")?;
  30. let venv_bin = venv.join("bin");
  31. std::env::set_var(
  32. "PATH",
  33. format!(
  34. "{}:{orig_path}",
  35. venv_bin.to_str().context("venv path not valid unicode")?
  36. ),
  37. );
  38. run(&["pip", "install", "--upgrade", "pip"], None)
  39. .await
  40. .context("failed to install pip")?;
  41. run(&["pip", "install", "-r", "requirements.txt"], None)
  42. .await
  43. .context("pip install failed")?;
  44. run(
  45. &["maturin", "develop"],
  46. Some(&root.join("apis").join("python").join("node")),
  47. )
  48. .await
  49. .context("maturin develop failed")?;
  50. let dataflow = Path::new("dataflow.yml");
  51. dora_daemon::Daemon::run_dataflow(dataflow).await?;
  52. Ok(())
  53. }