Make cli async so running the graph works, add schema generation to readme
Some checks failed
test / test (push) Failing after 47m44s
Some checks failed
test / test (push) Failing after 47m44s
This commit is contained in:
@@ -7,6 +7,12 @@ A super fast, simple base for building analytics applications.
|
|||||||
A basic CLI is available to run a graph and a subset of analytics workloads.
|
A basic CLI is available to run a graph and a subset of analytics workloads.
|
||||||
In development environments, use `cargo run --bin cli -- -h` for more information.
|
In development environments, use `cargo run --bin cli -- -h` for more information.
|
||||||
|
|
||||||
|
### Generating the JSON schema:
|
||||||
|
|
||||||
|
`cargo run --bin cli -- generate-schema`
|
||||||
|
|
||||||
|
The schema will be written to a schema.json file.
|
||||||
|
|
||||||
## General Notes
|
## General Notes
|
||||||
|
|
||||||
Setting the number of threads in overhead allocation: set RAYON_NUM_THREADS environment
|
Setting the number of threads in overhead allocation: set RAYON_NUM_THREADS environment
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use coster_rs::cli::Cli;
|
use coster_rs::cli::Cli;
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
#[tokio::main]
|
||||||
|
async fn main() -> anyhow::Result<()> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
cli.run()
|
cli.run().await
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ use std::{
|
|||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use clap::{command, Parser};
|
use clap::Parser;
|
||||||
|
|
||||||
pub use commands::Commands;
|
pub use commands::Commands;
|
||||||
|
|
||||||
@@ -23,17 +23,17 @@ use crate::{
|
|||||||
mod commands;
|
mod commands;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(name = "coster-rs")]
|
#[command(name = "ingey")]
|
||||||
#[command(author = "Pivato M. <mpivato4@gmail.com>")]
|
#[command(author = "Pivato M. <contact@michaelpivato.dev>")]
|
||||||
#[command(version = "0.0.1")]
|
#[command(version = "0.0.1")]
|
||||||
#[command(about = "Simple, fast, efficient costing tool", long_about = None)]
|
#[command(about = "Simple, fast, efficient data manipulation tool", long_about = None)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
pub command: Commands,
|
pub command: Commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cli {
|
impl Cli {
|
||||||
pub fn run(self) -> anyhow::Result<()> {
|
pub async fn run(self) -> anyhow::Result<()> {
|
||||||
match self.command {
|
match self.command {
|
||||||
Commands::MoveMoney {
|
Commands::MoveMoney {
|
||||||
rules,
|
rules,
|
||||||
@@ -174,11 +174,13 @@ impl Cli {
|
|||||||
let reader = BufReader::new(file);
|
let reader = BufReader::new(file);
|
||||||
let graph = serde_json::from_reader(reader)?;
|
let graph = serde_json::from_reader(reader)?;
|
||||||
let graph = RunnableGraph::from_graph(graph);
|
let graph = RunnableGraph::from_graph(graph);
|
||||||
// TODO: Possible to await here? Actually needs awaiting to work
|
|
||||||
graph.run_default_tasks(threads, |id, status| {
|
let result = graph
|
||||||
|
.run_default_tasks(threads, |id, status| {
|
||||||
info!("Node with id {} finished with status {:?}", id, status)
|
info!("Node with id {} finished with status {:?}", id, status)
|
||||||
});
|
})
|
||||||
Ok(())
|
.await;
|
||||||
|
result
|
||||||
}
|
}
|
||||||
Commands::GenerateSchema { output } => {
|
Commands::GenerateSchema { output } => {
|
||||||
let schema = schema_for!(Graph);
|
let schema = schema_for!(Graph);
|
||||||
|
|||||||
Reference in New Issue
Block a user