Browse Source

Add python installer and run script

tags/v0.0.0-test.4
haixuanTao 3 years ago
parent
commit
7822e87b2d
2 changed files with 51 additions and 0 deletions
  1. +10
    -0
      examples/python-dataflow/install.sh
  2. +41
    -0
      examples/python-dataflow/run.rs

+ 10
- 0
examples/python-dataflow/install.sh View File

@@ -0,0 +1,10 @@
python3 -m venv .env
. $(pwd)/.env/bin/activate
# Dev dependencies
pip install maturin
cd ../../apis/python/node
maturin develop
cd ../../../examples/python-dataflow

# Dependencies
pip install -r requirements.txt

+ 41
- 0
examples/python-dataflow/run.rs View File

@@ -0,0 +1,41 @@
use eyre::{bail, Context};
use std::path::Path;

#[tokio::main]
async fn main() -> eyre::Result<()> {
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
std::env::set_current_dir(root.join(file!()).parent().unwrap())
.wrap_err("failed to set working dir")?;

build_package("dora-runtime").await?;

install_python_dependencies(root).await?;

dora_coordinator::run(dora_coordinator::Command::Run {
dataflow: Path::new("dataflow.yml").to_owned(),
runtime: Some(root.join("target").join("release").join("dora-runtime")),
})
.await?;

Ok(())
}

async fn build_package(package: &str) -> eyre::Result<()> {
let cargo = std::env::var("CARGO").unwrap();
let mut cmd = tokio::process::Command::new(&cargo);
cmd.arg("build").arg("--release");
cmd.arg("--package").arg(package);
if !cmd.status().await?.success() {
bail!("failed to build {package}");
};
Ok(())
}

async fn install_python_dependencies(root: &Path) -> eyre::Result<()> {
let mut install = tokio::process::Command::new("sh");
install.arg("./install.sh");
if !install.status().await?.success() {
bail!("failed to create venv");
};
Ok(())
}

Loading…
Cancel
Save