There are more AWS SDK examples available in the AWS Doc SDK Examples
SageMaker AI examples using SDK for Rust
The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for Rust with SageMaker AI.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use ListNotebookInstances
.
- SDK for Rust
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. async fn show_instances(client: &Client) -> Result<(), Error> { let notebooks = client.list_notebook_instances().send().await?; println!("Notebooks:"); for n in notebooks.notebook_instances() { let n_instance_type = n.instance_type().unwrap(); let n_status = n.notebook_instance_status().unwrap(); let n_name = n.notebook_instance_name(); println!(" Name : {}", n_name.unwrap_or("Unknown")); println!(" Status : {}", n_status.as_ref()); println!(" Instance Type : {}", n_instance_type.as_ref()); println!(); } Ok(()) }
-
For API details, see ListNotebookInstances
in AWS SDK for Rust API reference.
-
The following code example shows how to use ListTrainingJobs
.
- SDK for Rust
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. async fn show_jobs(client: &Client) -> Result<(), Error> { let job_details = client.list_training_jobs().send().await?; println!("Jobs:"); for j in job_details.training_job_summaries() { let name = j.training_job_name().unwrap_or("Unknown"); let creation_time = j.creation_time().expect("creation time").to_chrono_utc()?; let training_end_time = j .training_end_time() .expect("Training end time") .to_chrono_utc()?; let status = j.training_job_status().expect("training status"); let duration = training_end_time - creation_time; println!(" Name: {}", name); println!( " Creation date/time: {}", creation_time.format("%Y-%m-%d@%H:%M:%S") ); println!(" Duration (seconds): {}", duration.num_seconds()); println!(" Status: {:?}", status); println!(); } Ok(()) }
-
For API details, see ListTrainingJobs
in AWS SDK for Rust API reference.
-