-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add initial support for operating with workflows #23
Draft
tuommaki
wants to merge
10
commits into
main
Choose a base branch
from
add-support-for-workflows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
871ab20
Add initial support for operating with workflows
tuommaki 6c94263
Construct clients only after arg validation
tuommaki 62e3988
Merge branch 'main' into add-support-for-workflows
tuommaki e37bbf4
Fix `mia` dependency issue
tuommaki 5229708
Use the right struct for reading workflow file
tuommaki c5feee3
Merge branch 'main' into add-support-for-workflows
tuommaki 43a8518
Merge branch 'main' into add-support-for-workflows
tuommaki 4c9543d
Update gevulot-rs
tuommaki b14a28c
Merge branch 'add-support-for-workflows' of github.com:gevulotnetwork…
tuommaki 3de185b
Refresh mia-installer
tuommaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
pub mod build; | ||
pub mod pins; | ||
pub mod tasks; | ||
pub mod workflows; | ||
pub mod workers; | ||
pub mod sudo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,8 @@ pub async fn list_pins(_sub_m: &clap::ArgMatches) -> Result<(), Box<dyn std::err | |
/// * `_sub_m` - A reference to the ArgMatches struct containing parsed command-line arguments. | ||
/// This is used to access the CID of the pin to retrieve and any additional options. | ||
pub async fn get_pin(_sub_m: &clap::ArgMatches) -> Result<(), Box<dyn std::error::Error>> { | ||
let mut client = connect_to_gevulot(_sub_m).await?; | ||
if let Some(pin_cid) = _sub_m.get_one::<String>("cid") { | ||
let mut client = connect_to_gevulot(_sub_m).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instantiate client only after the CLI argument has been validated 🙂 |
||
let pin = client.pins.get(pin_cid).await?; | ||
// Convert the pin to the gevulot_rs::models::Pin type | ||
let pin: gevulot_rs::models::Pin = pin.into(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
use gevulot_rs::proto::gevulot::gevulot::{workflow_spec::Stage, InputContext, MsgCreateWorkflow, MsgDeleteWorkflow, OutputContext, TaskEnv, TaskSpec, WorkflowSpec}; | ||
|
||
use crate::{connect_to_gevulot, print_object, read_file}; | ||
|
||
|
||
|
||
|
||
pub async fn list_workflows(_sub_m: &clap::ArgMatches) -> Result<(), Box<dyn std::error::Error>> { | ||
let mut client = crate::connect_to_gevulot(_sub_m).await?; | ||
let workflows = client.workflows.list().await?; | ||
let workflows: Vec<gevulot_rs::models::Workflow> = workflows.into_iter().map(Into::into).collect(); | ||
print_object(_sub_m, &workflows)?; | ||
Ok(()) | ||
} | ||
|
||
pub async fn get_workflow(_sub_m: &clap::ArgMatches) -> Result<(), Box<dyn std::error::Error>> { | ||
if let Some(workflow_id) = _sub_m.get_one::<String>("id") { | ||
let mut client = crate::connect_to_gevulot(_sub_m).await?; | ||
let workflow = client.workflows.get(workflow_id).await?; | ||
let workflow: gevulot_rs::models::Workflow = workflow.into(); | ||
print_object(_sub_m, &workflow)?; | ||
} else { | ||
println!("Workflow ID is required"); | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub async fn create_workflow(_sub_m: &clap::ArgMatches) -> Result<(), Box<dyn std::error::Error>> { | ||
let workflow: gevulot_rs::models::WorkflowSpec = read_file(_sub_m).await?; | ||
let mut client = connect_to_gevulot(_sub_m).await?; | ||
let me = client | ||
.base_client | ||
.write() | ||
.await | ||
.address | ||
.clone() | ||
.ok_or("No address found, did you set a mnemonic?")?; | ||
|
||
let resp = client | ||
.workflows | ||
.create(MsgCreateWorkflow{ | ||
creator: me, | ||
spec: Some(WorkflowSpec{ | ||
stages: workflow.stages.iter().map(|s| Stage{ | ||
tasks: s.tasks.iter().map(|t| TaskSpec{ | ||
image: t.image.clone(), | ||
command: t.command.clone(), | ||
args: t.args.clone(), | ||
env: t.env.iter().map(|e| TaskEnv{ | ||
name: e.name.clone(), | ||
value: e.value.clone() | ||
}).collect(), | ||
input_contexts: t.input_contexts.iter().map(|ic| InputContext{ | ||
source: ic.source.clone(), | ||
target: ic.target.clone() | ||
}).collect(), | ||
output_contexts: t.output_contexts.iter().map(|oc| OutputContext{ | ||
source: oc.source.clone(), | ||
retention_period: oc.retention_period as u64 | ||
}).collect(), | ||
cpus: t.resources.cpus as u64, | ||
gpus: t.resources.gpus as u64, | ||
memory: t.resources.memory as u64, | ||
time: t.resources.time as u64, | ||
store_stdout: t.store_stdout.unwrap_or(false), | ||
store_stderr: t.store_stderr.unwrap_or(false), | ||
workflow_ref: "".to_string(), | ||
}).collect::<Vec<TaskSpec>>(), | ||
}).collect::<Vec<Stage>>(), | ||
}), | ||
}).await?; | ||
|
||
println!("Created workflow with ID: {}", resp.id); | ||
Ok(()) | ||
} | ||
|
||
pub async fn delete_workflow(_sub_m: &clap::ArgMatches) -> Result<(), Box<dyn std::error::Error>> { | ||
if let Some(workflow_id) = _sub_m.get_one::<String>("id") { | ||
let mut client = crate::connect_to_gevulot(_sub_m).await?; | ||
let me = client | ||
.base_client | ||
.write() | ||
.await | ||
.address | ||
.clone() | ||
.ok_or("No address found, did you set a mnemonic?")?; | ||
|
||
client.workflows.delete(MsgDeleteWorkflow{ | ||
creator: me, | ||
id: workflow_id.clone(), | ||
}).await?; | ||
println!("ok"); | ||
} else { | ||
println!("Workflow ID is required"); | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the build now that
gevulot-rs
is changing.