Gauthier Pierard
01/14/2025, 5:24 PMkedro viz
.
my node runs correctly, and kedro catalog list
shows the right entries, but kedro viz
cannot retrieve credentials defined in my hooks.py. did anyone face the same issue?
kedro viz
KeyError: "Unable to find credentials 'adls_creds': check your data catalog and credentials configuration. See <https://kedro.readthedocs.io/en/stable/kedro.io.DataCatalog.html> for an example."
Hall
01/14/2025, 5:24 PMRashida Kanchwala
01/14/2025, 5:39 PMGauthier Pierard
01/14/2025, 5:47 PMStarting Kedro Viz ...
[01/14/25 17:46:18] INFO Using 'conf/logging.yml' as logging configuration. You can change this by setting the __init__.py:270
KEDRO_LOGGING_CONFIG environment variable accordingly.
Process SpawnProcess-1:
Traceback (most recent call last):
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/io/catalog_config_resolver.py", line 98, in _fetch_credentials
return credentials[credentials_name]
KeyError: 'adls_creds'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/anaconda/envs/gpy/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/anaconda/envs/gpy/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro_viz/server.py", line 121, in run_server
load_and_populate_data(
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro_viz/server.py", line 59, in load_and_populate_data
catalog, pipelines, session_store, stats_dict = kedro_data_loader.load_data(
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro_viz/integrations/kedro/data_loader.py", line 177, in load_data
return _load_data_helper(
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro_viz/integrations/kedro/data_loader.py", line 106, in _load_data_helper
catalog = context.catalog
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/framework/context/context.py", line 190, in catalog
return self._get_catalog()
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/framework/context/context.py", line 234, in _get_catalog
catalog: DataCatalog = settings.DATA_CATALOG_CLASS.from_config(
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/io/data_catalog.py", line 285, in from_config
config_resolver = CatalogConfigResolver(catalog, credentials)
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/io/catalog_config_resolver.py", line 33, in __init__
self._resolved_configs = self._resolve_config_credentials(config, credentials)
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/io/catalog_config_resolver.py", line 258, in _resolve_config_credentials
resolved_configs[ds_name] = self._resolve_credentials(
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/io/catalog_config_resolver.py", line 130, in _resolve_credentials
return {k: _resolve_value(k, v) for k, v in config.items()}
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/io/catalog_config_resolver.py", line 130, in <dictcomp>
return {k: _resolve_value(k, v) for k, v in config.items()}
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/io/catalog_config_resolver.py", line 125, in _resolve_value
return cls._fetch_credentials(value, credentials)
File "/anaconda/envs/gpy/lib/python3.10/site-packages/kedro/io/catalog_config_resolver.py", line 100, in _fetch_credentials
raise KeyError(
KeyError: "Unable to find credentials 'adls_creds': check your data catalog and credentials configuration. See <https://kedro.readthedocs.io/en/stable/kedro.io.DataCatalog.html> for an example."
Gauthier Pierard
01/14/2025, 5:50 PMGauthier Pierard
01/14/2025, 5:51 PMRashida Kanchwala
01/14/2025, 5:56 PMGauthier Pierard
01/14/2025, 6:21 PMfrom kedro.framework.hooks import hook_impl
from pyspark import SparkConf
from pyspark.sql import SparkSession
from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential
class AzureSecretsHook:
def __init__(self):
self.credentials = None
@hook_impl
def after_context_created(self, context) -> None:
credentials = DefaultAzureCredential(exclude_managed_identity_credential=True)
vault_url = 'xxx'
client = SecretClient(vault_url=vault_url, credential=credentials)
secrets = {
"client_secret": "client-secret",
"client_id": "client-id",
"account_name": "storage-account-bld",
"tenant_id": "tenant-id",
}
adls_creds = {
"adls_creds":{
cred_name: client.get_secret(secret_name).value
for cred_name, secret_name in secrets.items()
}
}
context.config_loader["credentials"] = {
**context.config_loader["credentials"],
**adls_creds,
}
self.credentials = context.config_loader["credentials"]
Ravi Kumar Pilla
01/14/2025, 6:48 PMRashida Kanchwala
01/14/2025, 6:53 PMGauthier Pierard
01/14/2025, 6:54 PMRashida Kanchwala
01/14/2025, 7:05 PMGauthier Pierard
01/14/2025, 7:06 PMGauthier Pierard
01/14/2025, 7:07 PMAnkita Katiyar
01/14/2025, 7:15 PMkedro viz run --include-hooks
^ This should work, the credentials are not found because itโs coming from a hookRashida Kanchwala
01/14/2025, 7:15 PMGauthier Pierard
01/14/2025, 7:20 PM