Skip to content
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
4 changes: 2 additions & 2 deletions guide/samples/src/gemini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! Examples showing how to use the Vertex AI Gemini API.

// ANCHOR: text-prompt
pub async fn text_prompt(project_id: &str) -> crate::Result<()> {
pub async fn text_prompt(project_id: &str) -> anyhow::Result<()> {
// ANCHOR: text-prompt-client
use google_cloud_aiplatform_v1 as vertexai;
let client = vertexai::client::PredictionService::builder()
Expand Down Expand Up @@ -46,7 +46,7 @@ pub async fn text_prompt(project_id: &str) -> crate::Result<()> {
// ANCHOR_END: text-prompt

// ANCHOR: prompt-and-image
pub async fn prompt_and_image(project_id: &str) -> crate::Result<()> {
pub async fn prompt_and_image(project_id: &str) -> anyhow::Result<()> {
// ANCHOR: prompt-and-image-client
use google_cloud_aiplatform_v1 as vertexai;
let client = vertexai::client::PredictionService::builder()
Expand Down
4 changes: 2 additions & 2 deletions guide/samples/tests/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ mod driver {
const SECRET_ID_LENGTH: usize = 32;

#[tokio::test(flavor = "multi_thread")]
async fn gemini_text_prompt() -> user_guide_samples::Result<()> {
async fn gemini_text_prompt() -> anyhow::Result<()> {
let project_id = std::env::var("GOOGLE_CLOUD_PROJECT").unwrap();
user_guide_samples::gemini::text_prompt(&project_id).await
}

#[tokio::test(flavor = "multi_thread")]
async fn gemini_prompt_and_image() -> user_guide_samples::Result<()> {
async fn gemini_prompt_and_image() -> anyhow::Result<()> {
let project_id = std::env::var("GOOGLE_CLOUD_PROJECT").unwrap();
user_guide_samples::gemini::prompt_and_image(&project_id).await
}
Expand Down
13 changes: 9 additions & 4 deletions guide/samples/tests/initialize_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
// limitations under the License.

// [START test_only_snippet] ANCHOR: all
pub type Result = std::result::Result<(), Box<dyn std::error::Error>>;

pub async fn initialize_client(project_id: &str) -> Result {
pub async fn initialize_client(project_id: &str) -> anyhow::Result<()> {
// [START test_only] ANCHOR: use
use google_cloud_secretmanager_v1::client::SecretManagerService;
// [END test_only] ANCHOR_END: use
Expand Down Expand Up @@ -44,14 +42,21 @@ pub async fn initialize_client(project_id: &str) -> Result {

Ok(())
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let project_id = std::env::args().nth(1).unwrap();

initialize_client(&project_id).await
}
// [END test_only_snippet] ANCHOR_END: all

#[cfg(all(test, feature = "run-integration-tests"))]
mod tests {
use super::*;

#[tokio::test(flavor = "multi_thread")]
async fn driver() -> Result {
async fn driver() -> anyhow::Result<()> {
let project_id = std::env::var("GOOGLE_CLOUD_PROJECT").unwrap();
initialize_client(&project_id).await
}
Expand Down
14 changes: 14 additions & 0 deletions guide/src/setting_up_rust_on_cloud_shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ Cloud Shell.
[create a secret] and rerun the program, and you should see the secret
printed in the output.

You might see a "no space left on device" error. Run the following to remove
build artifacts:

```shell
cargo clean
```

Alternatively, you can build in release mode, which should also use less disk
space:

```shell
cargo build --release
```

<!-- markdownlint-enable MD029 -->

[authorize cloud shell]: https://cloud.google.com/shell/docs/auth
Expand Down
Loading