Skip to content
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

Vertex-ai providers with application_default_credentials.json #1312

Closed
Hunterlige opened this issue Jan 11, 2025 · 2 comments · Fixed by #1328
Closed

Vertex-ai providers with application_default_credentials.json #1312

Hunterlige opened this issue Jan 11, 2025 · 2 comments · Fixed by #1328

Comments

@Hunterlige
Copy link

Hunterlige commented Jan 11, 2025

Service account keys could pose a security risk if compromised. GCP recommend you avoid downloading service account keys.

Instead of using a service account key to run these tools, let them use your credentials by running gcloud auth login (for gcloud and gsutil) or gcloud auth application-default login

Currently, when giving the content of application_default_credentials.json I am unable of creating an ai-plateform request using baml.

[2025-01-11T01:15:12Z ERROR baml_runtime::tracing] Failed to create clients from client_registry
Traceback (most recent call last):
          ^^^^^^^^^^^^^^^^^^^
  File "/home/test/baml_client/sync_client.py", line 62, in ImageDescription
    raw = self.__runtime.call_function_sync(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
baml_py.BamlError: Failed to create clients from client_registry

Caused by:
    0: Failed to parse client: VertexAI
    1: Failed to parse service account JSON
    2: missing field `token_uri` at line 8 column 1

Is there a way to make a request while being authenticated with the CLI instead of a Service account keys?

@sxlijin
Copy link
Collaborator

sxlijin commented Jan 14, 2025

Hey there! Unfortunately this isn't currently supported but this is something we're actively working on, see #1328. We're expecting it to land on Monday.

github-merge-queue bot pushed a commit that referenced this issue Jan 18, 2025
Implement support for GCP application default credentials and everything
else that the `gcp_auth` crate supports.

Also make `BAML_LOG=debug` useful for customers debugging the GCP auth
decision graph.

In theory I could probably fork `gcp_auth` and make it work in wasm (the
compile errors suggest to me that the underlying rand/ring
implementations just need to get swapped out for wasm-compatible ones to
make it work) but it was more time-bounded to just reuse the existing
implementation. (We should strongly look into using `gcp_auth`, though,
or at least upgrading to using the `oauth2` crate to handle the
exchange.)

Tested on cloud run: 

![image](https://github.com/user-attachments/assets/b02016d4-8dda-48d4-993c-b62642e22d82)

Tested with `gcloud auth application-default login`:
<img width="924" alt="image"
src="https://github.com/user-attachments/assets/a08abb81-fba5-43e9-b5b0-d939fbac8b9a"
/>

Tested with `gcloud auth print-access-token` fallback:
<img width="928" alt="image"
src="https://github.com/user-attachments/assets/e9c85ae7-ffc6-4d42-be48-b2d15095e112"
/>

Fixes #1312 

<!-- ELLIPSIS_HIDDEN -->


----

> [!IMPORTANT]
> Implement GCP authentication chain for Vertex AI clients using
`gcp_auth` crate, update documentation, and modify build/test scripts.
> 
>   - **Authentication**:
> - Implement GCP authentication chain for Vertex AI clients using
`gcp_auth` crate in `vertex.rs`.
> - Introduce `UnresolvedGcpAuthStrategy` and `ResolvedGcpAuthStrategy`
enums for handling different auth strategies.
> - Add `VertexAuth` struct in `std_auth.rs` and `wasm_auth.rs` for
standard and WASM environments.
>   - **Documentation**:
> - Update `vertex.mdx` to include new authentication strategies and
examples.
>   - **Build and Test**:
> - Update `tools/build` to include new test paths and commands for
Vertex AI.
> - Modify `.github/workflows/build-python-release.reusable.yaml` to
track new branches.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup>
for 7674f18. It will automatically
update as commits are pushed.</sup>


<!-- ELLIPSIS_HIDDEN -->
@sxlijin
Copy link
Collaborator

sxlijin commented Jan 18, 2025

Release is planned for Monday! Will close when it goes out.

@sxlijin sxlijin reopened this Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants