Skip to content

Commit 6737a04

Browse files
authored
executors rfk, tidy ups and log rfks (#59)
1 parent 1400ffa commit 6737a04

File tree

24 files changed

+517
-1934
lines changed

24 files changed

+517
-1934
lines changed

Cargo.lock

Lines changed: 306 additions & 1806 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dkn-compute-launcher"
33
edition = "2021"
4-
version = "0.1.14"
4+
version = "0.1.15"
55
license = "Apache-2.0"
66
readme = "README.md"
77
description = "Dria Compute Node Launcher"
@@ -48,8 +48,7 @@ indicatif = "0.17.11"
4848
colored = "2.2.0"
4949

5050
# requests and LLMs
51-
ollama-rs = { version = "0.2.5", features = ["rustls", "stream"] }
52-
dkn-workflows = { git = "https://github.com/firstbatchxyz/dkn-compute-node" }
51+
dkn-executor = { git = "https://github.com/firstbatchxyz/dkn-compute-node" }
5352
reqwest = { version = "0.12.12", features = ["rustls-tls", "json"] }
5453

5554
# crypto stuff

README.md

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ Open a terminal and run the following command:
5050
curl -fsSL https://dria.co/launcher | bash
5151
```
5252

53+
You can verify the installation later with:
54+
55+
```sh
56+
which dkn-compute-launcher
57+
```
58+
5359
**Windows**
5460

5561
Open a Windows terminal ([cmd.exe](https://en.wikipedia.org/wiki/Cmd.exe)) and run the following command:
@@ -58,6 +64,12 @@ Open a Windows terminal ([cmd.exe](https://en.wikipedia.org/wiki/Cmd.exe)) and r
5864
powershell -c "irm https://dria.co/launcher.ps1 | iex"
5965
```
6066

67+
You can verify the installation later with:
68+
69+
```sh
70+
where.exe dkn-compute-launcher
71+
```
72+
6173
You may need to allow network access to the launcher if Windows prompts you to do so.
6274

6375
### Build from Source
@@ -191,7 +203,6 @@ Click on `Edit model selection` to select models for your node.
191203
openai
192204
gemini
193205
openrouter
194-
VLLM
195206
← Go Back
196207
```
197208

@@ -257,6 +268,8 @@ Use the `points` command to display how much you have earned!
257268
dkn-compute-launcher points
258269
```
259270
271+
You can also check out your [node dashboard](https://dria.co/edge-ai) for this information.
272+
260273
### Updating Manually
261274
262275
Using the `update` command you can check for updates & automatically update your compute node and launcher.
@@ -300,6 +313,62 @@ When you run a specific release your node & launcher will **not** be automatical
300313
> The Dria Knowledge Network always considers the latest `minor` version as the active version; therefore,
301314
> if the latest is `0.3.x` and you decide to run a smaller version like `0.2.x` you will most likely kept out of network due to protocol mismatch.
302315
316+
### Running in Background
317+
318+
#### Linux/MacOS
319+
320+
In Linux/MacOS systems you can use [`screen`](https://gist.github.com/jctosta/af918e1618682638aa82) command to run the launcher in the background.
321+
322+
First, create a screen with a given name (here we name it `dkn-compute-node`):
323+
324+
```sh
325+
screen -S dkn-compute-node
326+
```
327+
328+
Within the newly opened screen, start the node:
329+
330+
```sh
331+
dkn-compute-launcher start
332+
```
333+
334+
Now we will _detach_ from this screen and let it run in the background. For this, press <kbd>CTRL + A</kbd> and then press the <kbd>D</kbd> letter. You should now exit the screen, and see a `[detached]` log in the terminal that you have returned to.
335+
336+
At a later time, you can list your screens with:
337+
338+
```sh
339+
screen -list
340+
```
341+
342+
You can connect to a screen via its name directly:
343+
344+
```sh
345+
screen -r dkn-compute-node
346+
```
347+
348+
Within the screen, you can continue to use your launcher as you would normally, or stop the node with <kbd>CTRL+C</kbd>. You can `exit` within the screen to terminate it.
349+
350+
<!--
351+
TODO: test these commands and then publish them here
352+
#### Windows
353+
354+
In Windows systems, you can start the launcher in background using the `start` command:
355+
356+
```cmd
357+
start /B dkn-compute-launcher.exe start
358+
```
359+
360+
To list running processes:
361+
362+
```cmd
363+
tasklist | findstr "dkn-compute"
364+
```
365+
366+
To terminate the process:
367+
368+
```cmd
369+
taskkill /IM dkn-compute-launcher.exe /F
370+
``` -->
371+
303372
## Contributions
304373

305374
Contributions are welcome! You can start by cloning the repo:
@@ -327,15 +396,16 @@ cargo doc --open --no-deps --document-private-items
327396

328397
## Uninstallation
329398

330-
You can uninstall the launcher binary along with the environment files and compute node binaries with the `uninstall` command:
399+
You can uninstall the launcher binary along with the environment files and compute node binaries with the `uninstall` command.
400+
401+
Make sure you backup your private key within `.env` before removing these files, so that you do not lose your hard-earned $DRIA points. We have a `--backup` option for this purpose!
331402

332403
```sh
333404
dkn-compute-launcher uninstall
334-
```
335405

336-
> [!CAUTION]
337-
>
338-
> Make sure you backup your private key within `.env` before removing these files, so that you do not lose your hard-earned $DRIA points!
406+
# will save the removed .env file to the given path
407+
dkn-compute-launcher uninstall --backup ./my-backup.txt
408+
```
339409

340410
## License
341411

src/commands/editor.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use eyre::{eyre, Result};
21
use inquire::Editor;
32
use std::fs;
43
use std::path::Path;
@@ -11,16 +10,13 @@ use std::path::Path;
1110
/// ### Errors
1211
/// - If the environment file does not exist
1312
/// - If the file could not be read
14-
pub fn edit_environment_file(env_path: &Path) -> Result<()> {
13+
pub fn edit_environment_file(env_path: &Path) -> eyre::Result<()> {
1514
if !env_path.exists() {
16-
return Err(eyre!(
17-
"Environment file does not exist: {}",
18-
env_path.display()
19-
));
15+
eyre::bail!("Environment file does not exist: {}", env_path.display());
2016
}
2117

2218
let Ok(existing_env_content) = fs::read_to_string(env_path) else {
23-
return Err(eyre!("Could not read {}", env_path.display()));
19+
eyre::bail!("Could not read {}", env_path.display());
2420
};
2521

2622
let Some(new_env_content) =

src/commands/info.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@ pub fn show_info() {
1818
);
1919

2020
// models
21-
let model_names = dria_env.get_model_config().get_model_names();
22-
if model_names.is_empty() {
21+
let models = dria_env.get_models();
22+
if models.is_empty() {
2323
eprintln!("Models: no models configured!");
2424
} else {
25-
eprintln!("Models:\n - {}", model_names.join("\n - "));
25+
eprintln!(
26+
"Models:\n - {}",
27+
models
28+
.iter()
29+
.map(|m| m.to_string())
30+
.collect::<Vec<String>>()
31+
.join("\n - ")
32+
);
2633
}
2734

2835
eprintln!("Version: {}", env!("CARGO_PKG_VERSION"));

src/commands/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
mod start;
2+
use std::path::PathBuf;
3+
24
pub use start::run_compute_node;
35

46
mod editor;
@@ -42,7 +44,11 @@ pub enum Commands {
4244
/// Show your $DRIA points.
4345
Points,
4446
/// Uninstall the launcher & its files.
45-
Uninstall,
47+
Uninstall {
48+
/// Backup the environment file to the given path.
49+
#[arg(short, long)]
50+
backup: Option<PathBuf>,
51+
},
4652
/// Show information about the current environment.
4753
Info,
4854
/// Manually update the compute node & launcher.

src/commands/referrals.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use colored::Colorize;
2-
use eyre::eyre;
32
use inquire::{Select, Text};
43

54
use crate::utils::{referrals::*, DriaEnv, Selectable};
@@ -11,7 +10,7 @@ pub async fn handle_referrals() -> eyre::Result<()> {
1110
// ensure system is healthy
1211
let client = ReferralsClient::default();
1312
if !client.healthcheck().await {
14-
return Err(eyre!("Referrals API is offline."));
13+
eyre::bail!("Referrals API is offline.");
1514
}
1615

1716
// get wallet secret from env

src/commands/settings.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use eyre::{eyre, Result};
21
use inquire::{Confirm, Select};
32
use std::path::Path;
43

@@ -11,12 +10,9 @@ use crate::{settings::*, DriaEnv};
1110
///
1211
/// ### Errors
1312
/// - If the environment file is not a file
14-
pub async fn change_settings(env_path: &Path) -> Result<()> {
13+
pub async fn change_settings(env_path: &Path) -> eyre::Result<()> {
1514
if !env_path.exists() {
16-
return Err(eyre!(
17-
"Environment file does not exist: {}",
18-
env_path.display()
19-
));
15+
eyre::bail!("Environment file does not exist: {}", env_path.display());
2016
}
2117

2218
// an environment object is created from the existing environment variables

src/commands/setup.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use eyre::Result;
22
use std::path::Path;
33

4-
use crate::{
5-
settings::{self, DriaApiKeyKind},
6-
utils::DriaEnv,
7-
};
4+
use crate::{settings, utils::DriaEnv};
85

96
/// Asks for the following information for the user environment:
107
///
@@ -28,21 +25,6 @@ pub fn setup_environment(env_path: &Path) -> Result<()> {
2825
log::info!("Choose models that you would like to run.");
2926
settings::edit_models(&mut dria_env)?;
3027

31-
// ask for Jina and Serper api keys (optional)
32-
for optional_api_key in DriaApiKeyKind::optional_apis() {
33-
log::info!(
34-
"Optionally provide {} for better performance",
35-
optional_api_key
36-
);
37-
38-
let new_value = optional_api_key.prompt_api(&dria_env)?;
39-
if new_value.is_empty() {
40-
continue;
41-
} else {
42-
dria_env.set(optional_api_key.name(), new_value);
43-
}
44-
}
45-
4628
// create directories if they dont exist
4729
DriaEnv::new_default_file(env_path)?;
4830

src/commands/specific.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use eyre::{eyre, Result};
21
use inquire::Select;
32
use std::path::{Path, PathBuf};
43

@@ -21,9 +20,12 @@ use crate::{
2120
/// - If the release could not be downloaded
2221
/// - If the release could not be found for the given tag
2322
/// - If the user cancels the prompt
24-
pub async fn download_specific_release(exe_dir: &Path, tag: Option<&String>) -> Result<PathBuf> {
23+
pub async fn download_specific_release(
24+
exe_dir: &Path,
25+
tag: Option<&String>,
26+
) -> eyre::Result<PathBuf> {
2527
if !exe_dir.is_dir() {
26-
return Err(eyre!("{} must be a directory", exe_dir.display()));
28+
eyre::bail!("{} must be a directory", exe_dir.display());
2729
}
2830

2931
let releases = get_releases(DriaRepository::ComputeNode).await?;

0 commit comments

Comments
 (0)