https://kedro.org/ logo
#questions
Title
# questions
a

Andrew Stewart

12/20/2023, 7:44 PM
I may be misremembering but is there a versio nof https://docs.kedro.org/en/0.18.0/get_started/standalone_use_of_datacatalog.html that provides exmples of how to access the catalog datasets outside of notebook magic? Like say from just a script?
I'm getting some fairly convoluted looking example from ChatGPT:
Copy code
from kedro.framework.hooks import _create_hook_manager
from kedro.config import ConfigLoader
from kedro.context import KedroContext, KedroContextError
from kedro.framework.hooks import _create_hook_manager
from kedro.framework.hooks import _create_hook_manager
from kedro.config import ConfigLoader
from kedro.framework.hooks import _create_hook_manager
from <http://kedro.io|kedro.io> import DataCatalog
from pathlib import Path

class ProjectContext(KedroContext):
    project_name = "your_project"

context = ProjectContext(Path.cwd())

# Load Kedro configuration
conf_source = context.config_loader.get("source*")
conf_catalog = context.config_loader.get("catalog*")

# Load data catalog
catalog = DataCatalog.from_config(conf_catalog)

# Load your dataset
data = catalog.load("raw_data")
y

Yolan Honoré-Rougé

12/20/2023, 8:17 PM
It is even simpler in 0.19, because the OmegaConfigLoader defaults have changed and you don't need to specify all the arguments in the example, they are the default now.
It's basically the same that what ChatGPT suggests, but you can create the config loader directly without all the stuff about creating a fake project context just for accessing the configloader
👍 1
a

Andrew Stewart

12/20/2023, 8:49 PM
Thanks for catching me up there @Yolan Honoré-Rougé - I need to get up to speed with omega
n

Nok Lam Chan

12/21/2023, 12:38 PM
"outside of a notebook", do you still have a kedro project or you just having some configuration files?. If the former you can always use
bootstrap_project
(which is what the notebook magic do behind the scene). Otherwise what @Yolan Honoré-Rougé suggested is the way to go.
a

Andrew Stewart

12/28/2023, 7:55 PM
yes, there is kedro project
is there a good overview of
bootstrap_project
usage?
n

Nok Lam Chan

01/02/2024, 3:49 PM
@Andrew Stewart https://github.com/kedro-org/kedro/pull/3470 Would this help? should I add more details?
👀 1
a

Andrew Stewart

01/08/2024, 5:41 PM
Thanks @Nok Lam Chan I'll give that a read!
2 Views