Skip to content

Commit

Permalink
Fix spanner creds issues: fixes: #634, #644 (#646)
Browse files Browse the repository at this point in the history
* fix: credential_file logic when not defined

* fix: spanner_cofig get logic and error when not defined

* chore: update to v0.35.10 in CHANGELOG.md w/ comments
  • Loading branch information
DataBoyTX authored Jan 25, 2025
1 parent 3d4c986 commit 105487b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Development]

## [0.35.10 - 2025-01-24]

### Fixes:

* Spanner: better handling of spanner_config issues: #634, #644

## [0.35.9 - 2025-01-22]

### Docs
Expand Down
7 changes: 4 additions & 3 deletions graphistry/PlotterBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2530,13 +2530,14 @@ def spanner_gql_to_g(self: Plottable, query: str) -> Plottable:
res = copy.copy(self)

if not hasattr(res, '_spannergraph'):
spanner_config = PyGraphistry._config["spanner"]
spanner_config = PyGraphistry._config.get("spanner", None)

if spanner_config is not None:
logger.debug(f"Spanner Config: {spanner_config}")
else:
raise ValueError('spanner_config is None, use spanner_init() or register() passing spanner_config')
raise ValueError('spanner_config not defined. Pass spanner_config via register() and retry query.')

res = res.spanner_init(PyGraphistry._config["spanner"]) # type: ignore[attr-defined]
res = res.spanner_init(spanner_config) # type: ignore[attr-defined]

return res._spannergraph.gql_to_graph(res, query)

Expand Down
3 changes: 2 additions & 1 deletion graphistry/plugins/spannergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def __connect(self) -> Any:
from google.cloud.spanner_dbapi.connection import connect

try:
if self.credentials_file:
if hasattr(self, 'credentials_file') and self.credentials_file is not None:

connection = connect(self.instance_id, self.database_id, credentials=self.credentials_file)
else:
connection = connect(self.instance_id, self.database_id)
Expand Down

0 comments on commit 105487b

Please sign in to comment.