Skip to content

Commit

Permalink
Add hook example to access metadata (#2998)
Browse files Browse the repository at this point in the history
* Check plugins implement valid hooks

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* add Metadtahook

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* Fix docs according to comments

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

---------

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Co-authored-by: Jo Stichbury <jo_stichbury@mckinsey.com>
  • Loading branch information
noklam and stichbury authored Sep 5, 2023
1 parent edbbcc7 commit 17f404f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/source/hooks/common_use_cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,17 @@ HOOKS = (AzureSecretsHook(),)
```{note}
Note: `DefaultAzureCredential()` is Azure's recommended approach to authorise access to data in your storage accounts. For more information, consult the [documentation about how to authenticate to Azure and authorize access to blob data](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python).
```

## Use a Hook to read `metadata` from `DataCatalog`
Use the `after_catalog_created` Hook to access `metadata` to extend Kedro.

```python
class MetadataHook:
@hook_impl
def after_catalog_created(
self,
catalog: DataCatalog,
):
for dataset_name, dataset in catalog.datasets.__dict__.items():
print(f"{dataset_name} metadata: \n {str(dataset.metadata)}")
```

0 comments on commit 17f404f

Please sign in to comment.