Skip to content

Commit

Permalink
[BUGFIX] Revert refactor to Datasource instantiation logic in `Data…
Browse files Browse the repository at this point in the history
…Context` (#6535)
  • Loading branch information
cdkini authored Dec 9, 2022
1 parent d95e64a commit 98c641b
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3063,17 +3063,25 @@ def _instantiate_datasource_from_config_and_update_project_config(
Raises:
DatasourceInitializationError
"""
substituted_config = self._perform_substitutions_on_datasource_config(config)
# Note that the call to `DatasourcStore.set` may alter the config object's state
# As such, we invoke it at the top of our function so any changes are reflected downstream
if save_changes:
config = self._datasource_store.set(key=None, value=config) # type: ignore[attr-defined]

datasource: Optional[Datasource] = None
if initialize:
datasource = self._instantiate_datasource_from_config(
raw_config=config, substituted_config=substituted_config
)
self._cached_datasources[config.name] = datasource

if save_changes:
config = self._datasource_store.set(key=None, value=config) # type: ignore[attr-defined]
try:
substituted_config = self._perform_substitutions_on_datasource_config(
config
)
datasource = self._instantiate_datasource_from_config(
raw_config=config, substituted_config=substituted_config
)
self._cached_datasources[config.name] = datasource
except ge_exceptions.DatasourceInitializationError as e:
if save_changes:
self._datasource_store.delete(config) # type: ignore[attr-defined]
raise e

self.config.datasources[config.name] = config # type: ignore[index,assignment]

Expand Down

0 comments on commit 98c641b

Please sign in to comment.