Skip to content

Commit

Permalink
Working runner registration
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Richard <jwric@users.noreply.github.com>
  • Loading branch information
ThierryCantin-Demers and jwric committed Aug 20, 2024
1 parent 04ea341 commit 0ae3ae6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
9 changes: 9 additions & 0 deletions crates/heat-sdk-cli/src/cli_commands/run/remote/training.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ pub struct RemoteTrainingRunArgs {
default_value = "http://127.0.0.1:9001"
)]
pub heat_endpoint: String,
/// The runner group name
#[clap(
short = 'r',
long = "runner",
help = "The runner group name.",
required = true,
)]
pub runner: String,
}

fn create_heat_client(api_key: &str, url: &str, project_path: &str) -> HeatClient {
Expand Down Expand Up @@ -73,6 +81,7 @@ pub(crate) fn handle_command(
let project_version = heat_client.upload_new_project_version(context.package_name(), crates)?;

heat_client.start_remote_job(
args.runner,
project_version,
format!(
"run local training --functions {} --backends {} --configs {} --project {} --key {}",
Expand Down
2 changes: 2 additions & 0 deletions crates/heat-sdk/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,12 @@ impl HeatClient {

pub fn start_remote_job(
&self,
runner_group_name: String,
project_version: u32,
command: String,
) -> Result<(), HeatSdkError> {
self.http_client.start_remote_job(
&runner_group_name,
self.config.project_path.owner_name(),
self.config.project_path.project_name(),
project_version,
Expand Down
8 changes: 4 additions & 4 deletions crates/heat-sdk/src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{

use super::schemas::{
CodeUploadParamsSchema, CodeUploadUrlsSchema, CreateExperimentResponseSchema,
EndExperimentSchema, RunnerJobCommand, RunnerQueueJobParamsSchema, URLSchema,
EndExperimentSchema, RunnerQueueJobParamsSchema, URLSchema,
};

pub enum EndExperimentStatus {
Expand Down Expand Up @@ -403,6 +403,7 @@ impl HttpClient {

pub fn start_remote_job(
&self,
runner_group_name: &str,
owner_name: &str,
project_name: &str,
project_version: u32,
Expand All @@ -416,10 +417,9 @@ impl HttpClient {
);

let body = RunnerQueueJobParamsSchema {
owner_name: owner_name.to_string(),
project_name: project_name.to_string(),
runner_group_name: runner_group_name.to_string(),
project_version,
command: RunnerJobCommand { command },
command
};

self.http_client
Expand Down
10 changes: 2 additions & 8 deletions crates/heat-sdk/src/http/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,9 @@ pub struct CodeUploadUrlsSchema {
pub urls: HashMap<String, String>,
}

#[derive(Debug, Clone, Serialize)]
pub struct RunnerJobCommand {
pub command: String,
}

#[derive(Debug, Serialize)]
pub struct RunnerQueueJobParamsSchema {
pub owner_name: String,
pub project_name: String,
pub runner_group_name: String,
pub project_version: u32,
pub command: RunnerJobCommand,
pub command: String,
}
4 changes: 2 additions & 2 deletions xtask/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{

use super::Target;

const PROJECT_UUID: &str = "331a3907-bfd8-45e5-af54-1fee73a3c1b1";
const PROJECT_PATH: &str = "test/Default-Project";
const API_KEY: &str = "dcaf7eb9-5acc-47d7-8b93-ca0fbb234096";

#[derive(Args)]
Expand Down Expand Up @@ -68,7 +68,7 @@ pub(crate) fn run_guide() -> Result<()> {
"--key",
API_KEY,
"--project",
PROJECT_UUID,
PROJECT_PATH,
])
.status()
.map_err(|e| anyhow!("Failed to execute guide example: {}", e))?;
Expand Down

0 comments on commit 0ae3ae6

Please sign in to comment.