Skip to content

Commit 726e131

Browse files
authored
docs(guide): update setup guide with user feedback improvements (#3620)
This PR is a clone of #3233. The [Rust Friction Log](https://docs.google.com/document/d/1sQBFLKq1fmc-qJL1tHqsQvRjzsk_bp7xOEpXmNYy72U/edit?resourcekey=0-MMQyQ4t4DVkDzqNA1sp6IQ&tab=t.0#heading=h.kf1buofzahta) gave users a chance to test the onboarding process and give us feedback. This PR addresses the common issues users had. Fixes b/429254171, b/429252054, b/429250702
1 parent b0e76ce commit 726e131

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

guide/samples/src/gemini.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! Examples showing how to use the Vertex AI Gemini API.
1616
1717
// ANCHOR: text-prompt
18-
pub async fn text_prompt(project_id: &str) -> crate::Result<()> {
18+
pub async fn text_prompt(project_id: &str) -> anyhow::Result<()> {
1919
// ANCHOR: text-prompt-client
2020
use google_cloud_aiplatform_v1 as vertexai;
2121
let client = vertexai::client::PredictionService::builder()
@@ -46,7 +46,7 @@ pub async fn text_prompt(project_id: &str) -> crate::Result<()> {
4646
// ANCHOR_END: text-prompt
4747

4848
// ANCHOR: prompt-and-image
49-
pub async fn prompt_and_image(project_id: &str) -> crate::Result<()> {
49+
pub async fn prompt_and_image(project_id: &str) -> anyhow::Result<()> {
5050
// ANCHOR: prompt-and-image-client
5151
use google_cloud_aiplatform_v1 as vertexai;
5252
let client = vertexai::client::PredictionService::builder()

guide/samples/tests/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ mod driver {
1919
const SECRET_ID_LENGTH: usize = 32;
2020

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

2727
#[tokio::test(flavor = "multi_thread")]
28-
async fn gemini_prompt_and_image() -> user_guide_samples::Result<()> {
28+
async fn gemini_prompt_and_image() -> anyhow::Result<()> {
2929
let project_id = std::env::var("GOOGLE_CLOUD_PROJECT").unwrap();
3030
user_guide_samples::gemini::prompt_and_image(&project_id).await
3131
}

guide/samples/tests/initialize_client.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
// limitations under the License.
1414

1515
// [START test_only_snippet] ANCHOR: all
16-
pub type Result = std::result::Result<(), Box<dyn std::error::Error>>;
17-
18-
pub async fn initialize_client(project_id: &str) -> Result {
16+
pub async fn initialize_client(project_id: &str) -> anyhow::Result<()> {
1917
// [START test_only] ANCHOR: use
2018
use google_cloud_secretmanager_v1::client::SecretManagerService;
2119
// [END test_only] ANCHOR_END: use
@@ -44,14 +42,21 @@ pub async fn initialize_client(project_id: &str) -> Result {
4442

4543
Ok(())
4644
}
45+
46+
#[tokio::main]
47+
async fn main() -> anyhow::Result<()> {
48+
let project_id = std::env::args().nth(1).unwrap();
49+
50+
initialize_client(&project_id).await
51+
}
4752
// [END test_only_snippet] ANCHOR_END: all
4853

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

5358
#[tokio::test(flavor = "multi_thread")]
54-
async fn driver() -> Result {
59+
async fn driver() -> anyhow::Result<()> {
5560
let project_id = std::env::var("GOOGLE_CLOUD_PROJECT").unwrap();
5661
initialize_client(&project_id).await
5762
}

guide/src/setting_up_rust_on_cloud_shell.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ Cloud Shell.
9595
[create a secret] and rerun the program, and you should see the secret
9696
printed in the output.
9797

98+
You might see a "no space left on device" error. Run the following to remove
99+
build artifacts:
100+
101+
```shell
102+
cargo clean
103+
```
104+
105+
Alternatively, you can build in release mode, which should also use less disk
106+
space:
107+
108+
```shell
109+
cargo build --release
110+
```
111+
98112
<!-- markdownlint-enable MD029 -->
99113

100114
[authorize cloud shell]: https://cloud.google.com/shell/docs/auth

0 commit comments

Comments
 (0)