Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion committed Oct 18, 2024
1 parent 50e5172 commit 38fba2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions crates/polars-io/src/cloud/credential_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ impl Debug for CredentialProviderFunction {
impl Eq for CredentialProviderFunction {}

impl PartialEq for CredentialProviderFunction {
fn eq(&self, _other: &Self) -> bool {
false
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.0, &other.0)
}
}

Expand Down Expand Up @@ -456,7 +456,7 @@ mod python_impl {

use super::IntoCredentialProvider;

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PythonCredentialProvider(pub(super) Arc<PythonFunction>);

Expand Down Expand Up @@ -648,8 +648,20 @@ mod python_impl {
}
}

impl Eq for PythonCredentialProvider {}

impl PartialEq for PythonCredentialProvider {
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.0, &other.0)
}
}

impl Hash for PythonCredentialProvider {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
// # Safety
// * Inner is an `Arc`
// * Visibility is limited to super
// * No code in `mod python_impl` or `super` mutates the Arc inner.
state.write_usize(Arc::as_ptr(&self.0) as *const () as usize)
}
}
Expand Down
4 changes: 2 additions & 2 deletions py-polars/polars/io/cloud/credential_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ def __init__(self) -> None:
import google.auth
import google.auth.credentials

creds, _ = google.auth.default() # type: ignore[no-untyped-call]
creds, _ = google.auth.default()
self.creds = creds

def __call__(self) -> CredentialProviderFunctionReturn:
"""Fetch the credentials for the configured profile name."""
import google.auth.transport.requests

self.creds.refresh(google.auth.transport.requests.Request()) # type: ignore[no-untyped-call]
self.creds.refresh(google.auth.transport.requests.Request())

return {"bearer_token": self.creds.token}, (
int(
Expand Down

0 comments on commit 38fba2c

Please sign in to comment.