Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env config cli tool #162

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
318 changes: 314 additions & 4 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
resolver = "2"
members = ["compute", "p2p", "workflows", "utils", "monitor"]
members = ["compute", "p2p", "workflows", "utils", "monitor", "launcher"]

# FIXME: removing this breaks the workflows
# compute node is the default member, until Oracle comes in
# then, a Launcher will be the default member
default-members = ["compute"]
default-members = ["launcher"]

[workspace.package]
edition = "2021"
Expand Down
34 changes: 2 additions & 32 deletions compute/src/main.rs → compute/src/launch.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,11 @@
use dkn_compute::*;
use crate::*;
use dkn_workflows::DriaWorkflowsConfig;
use eyre::Result;
use std::env;
use tokio_util::{sync::CancellationToken, task::TaskTracker};
use workers::workflow::WorkflowsWorker;

#[tokio::main]
async fn main() -> Result<()> {
let dotenv_result = dotenvy::dotenv();

env_logger::builder()
.format_timestamp(Some(env_logger::TimestampPrecision::Millis))
.filter(None, log::LevelFilter::Off)
.filter_module("dkn_compute", log::LevelFilter::Info)
.filter_module("dkn_p2p", log::LevelFilter::Info)
.filter_module("dkn_workflows", log::LevelFilter::Info)
.parse_default_env() // reads RUST_LOG variable
.init();

log::info!(
r#"

██████╗ ██████╗ ██╗ █████╗
██╔══██╗██╔══██╗██║██╔══██╗ Dria Compute Node
██║ ██║██████╔╝██║███████║ v{DRIA_COMPUTE_NODE_VERSION}
██║ ██║██╔══██╗██║██╔══██║ https://dria.co
██████╔╝██║ ██║██║██║ ██║
╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═╝
"#
);

// log about env usage
match dotenv_result {
Ok(path) => log::info!("Loaded .env file at: {}", path.display()),
Err(e) => log::warn!("Could not load .env file: {}", e),
}

pub async fn launch() -> Result<()> {
// task tracker for multiple threads
let task_tracker = TaskTracker::new();
let cancellation = CancellationToken::new();
Expand Down
5 changes: 3 additions & 2 deletions compute/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod config;
pub mod handlers;
pub mod launch;
pub mod node;
pub mod payloads;
pub mod utils;
Expand All @@ -9,7 +10,7 @@ pub mod workers;
/// This value is attached within the published messages.
pub const DRIA_COMPUTE_NODE_VERSION: &str = env!("CARGO_PKG_VERSION");

pub use utils::refresh_dria_nodes;

pub use config::DriaComputeNodeConfig;
pub use launch::launch;
pub use node::DriaComputeNode;
pub use utils::refresh_dria_nodes;
38 changes: 38 additions & 0 deletions launcher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "dkn-launcher"
version.workspace = true
edition.workspace = true
license.workspace = true
readme = "README.md"
authors = ["Erhan Tezcan <erhan@firstbatch.xyz>"]

[dependencies]
clap = { version = "4.5.20", features = ["derive"] }
crossterm = "0.28.1"
which = "7.0.0"
inquire = "0.7.5"
tempfile = "3.14.0"

# async stuff
tokio-util.workspace = true
tokio.workspace = true
async-trait.workspace = true

# serialize & deserialize
serde.workspace = true
serde_json.workspace = true

# utilities
dotenvy.workspace = true
hex = "0.4.3"
hex-literal = "0.4.1"

env_logger.workspace = true
log.workspace = true
eyre.workspace = true

# dria subcrates
dkn-compute = { path = "../compute" }
dkn-workflows = { path = "../workflows" }
self-replace = "1.5.0"
self_update = "0.41.0"
5 changes: 5 additions & 0 deletions launcher/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub mod utils;

pub use utils::gemini;
pub use utils::openai;
pub use utils::openrouter;
Loading