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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. use dora_core::{get_pip_path, get_python_path, run};
  2. use dora_tracing::set_up_tracing;
  3. use eyre::{ContextCompat, WrapErr};
  4. use std::path::Path;
  5. #[tokio::main]
  6. async fn main() -> eyre::Result<()> {
  7. set_up_tracing("python-operator-dataflow-runner")?;
  8. let root = Path::new(env!("CARGO_MANIFEST_DIR"));
  9. std::env::set_current_dir(root.join(file!()).parent().unwrap())
  10. .wrap_err("failed to set working dir")?;
  11. run(
  12. get_python_path().context("Could not get python binary")?,
  13. &["-m", "venv", "../.env"],
  14. None,
  15. )
  16. .await
  17. .context("failed to create venv")?;
  18. let venv = &root.join("examples").join(".env");
  19. std::env::set_var(
  20. "VIRTUAL_ENV",
  21. venv.to_str().context("venv path not valid unicode")?,
  22. );
  23. let orig_path = std::env::var("PATH")?;
  24. // bin folder is named Scripts on windows.
  25. // 🤦‍♂️ See: https://github.com/pypa/virtualenv/commit/993ba1316a83b760370f5a3872b3f5ef4dd904c1
  26. let venv_bin = if cfg!(windows) {
  27. venv.join("Scripts")
  28. } else {
  29. venv.join("bin")
  30. };
  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(
  39. get_pip_path().context("Could not get pip binary")?,
  40. &["install", "--upgrade", "pip"],
  41. None,
  42. )
  43. .await
  44. .context("failed to install pip")?;
  45. run(
  46. get_pip_path().context("Could not get pip binary")?,
  47. &["install", "-r", "requirements.txt"],
  48. None,
  49. )
  50. .await
  51. .context("pip install failed")?;
  52. run(
  53. "maturin",
  54. &["develop"],
  55. Some(&root.join("apis").join("python").join("node")),
  56. )
  57. .await
  58. .context("maturin develop failed")?;
  59. let dataflow = Path::new("dataflow.yml");
  60. dora_daemon::Daemon::run_dataflow(dataflow).await?;
  61. Ok(())
  62. }