Browse Source

chore: make run function public

tags/v0.3.12-fix
sjfhsjfh 6 months ago
parent
commit
20c9269f64
No known key found for this signature in database GPG Key ID: CA820EAE1C115AED
4 changed files with 41 additions and 34 deletions
  1. +1
    -1
      apis/python/node/src/lib.rs
  2. +2
    -0
      binaries/cli/src/command/mod.rs
  3. +36
    -33
      binaries/cli/src/command/run.rs
  4. +2
    -0
      binaries/cli/src/lib.rs

+ 1
- 1
apis/python/node/src/lib.rs View File

@@ -381,7 +381,7 @@ pub fn resolve_dataflow(dataflow: String) -> eyre::Result<PathBuf> {
#[pyfunction]
#[pyo3(signature = (dataflow_path, uv=None))]
pub fn run(dataflow_path: String, uv: Option<bool>) -> eyre::Result<()> {
dora_cli::command::run(dataflow_path, uv.unwrap_or_default())
dora_cli::run_func(dataflow_path, uv.unwrap_or_default())
}

#[pymodule]


+ 2
- 0
binaries/cli/src/command/mod.rs View File

@@ -14,6 +14,8 @@ mod start;
mod stop;
mod up;

pub use run::run_func;

use build::Build;
use check::Check;
use coordinator::Coordinator;


+ 36
- 33
binaries/cli/src/command/run.rs View File

@@ -23,41 +23,44 @@ pub struct Run {
uv: bool,
}

impl Executable for Run {
fn execute(self) -> eyre::Result<()> {
#[cfg(feature = "tracing")]
{
let log_level = std::env::var("RUST_LOG").ok().unwrap_or("info".to_string());
TracingBuilder::new("run")
.with_stdout(log_level)
.build()
.wrap_err("failed to set up tracing subscriber")?;
}

let dataflow_path =
resolve_dataflow(self.dataflow).context("could not resolve dataflow")?;
let dataflow_session = DataflowSession::read_session(&dataflow_path)
.context("failed to read DataflowSession")?;
let rt = Builder::new_multi_thread()
.enable_all()
pub fn run_func(dataflow: String, uv: bool) -> eyre::Result<()> {
#[cfg(feature = "tracing")]
{
let log_level = std::env::var("RUST_LOG").ok().unwrap_or("info".to_string());
TracingBuilder::new("run")
.with_stdout(log_level)
.build()
.context("tokio runtime failed")?;
.wrap_err("failed to set up tracing subscriber")?;
}

let (log_tx, log_rx) = flume::bounded(100);
std::thread::spawn(move || {
for message in log_rx {
print_log_message(message, false, false);
}
});
let dataflow_path = resolve_dataflow(dataflow).context("could not resolve dataflow")?;
let dataflow_session =
DataflowSession::read_session(&dataflow_path).context("failed to read DataflowSession")?;
let rt = Builder::new_multi_thread()
.enable_all()
.build()
.context("tokio runtime failed")?;

let result = rt.block_on(Daemon::run_dataflow(
&dataflow_path,
dataflow_session.build_id,
dataflow_session.local_build,
dataflow_session.session_id,
self.uv,
LogDestination::Channel { sender: log_tx },
))?;
handle_dataflow_result(result, None)
let (log_tx, log_rx) = flume::bounded(100);
std::thread::spawn(move || {
for message in log_rx {
print_log_message(message, false, false);
}
});

let result = rt.block_on(Daemon::run_dataflow(
&dataflow_path,
dataflow_session.build_id,
dataflow_session.local_build,
dataflow_session.session_id,
uv,
LogDestination::Channel { sender: log_tx },
))?;
handle_dataflow_result(result, None)
}

impl Executable for Run {
fn execute(self) -> eyre::Result<()> {
run_func(self.dataflow, self.uv)
}
}

+ 2
- 0
binaries/cli/src/lib.rs View File

@@ -12,6 +12,8 @@ pub mod output;
pub mod session;
mod template;

pub use command::run_func;

const LOCALHOST: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
const LISTEN_WILDCARD: IpAddr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));



Loading…
Cancel
Save