Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative to accessing attributes of KedroContext after 0.18.0 #807

Closed
willashford opened this issue Jun 24, 2021 · 4 comments
Closed

Comments

@willashford
Copy link
Contributor

Introduction

I'm looking to understand the preferred methods of accessing KedroContext attributes for testing purposes after 0.18.0, as I receive a deprecation warning.

Background

As part of managing a kedro project, I like to have tests that check attributes like the pipeline or catalog for coherence to naming conventions, etc. This is typically done via creating a kedro context object as a test fixture and running tests against the objects attributes.

Problem

When I do this currently, I'm presented with a warning about deprecation of accessing these attributes (app name, pipeline, etc) after 0.18.0. What is the preferred approach to accessing these attributes in a future proof way?

@datajoely
Copy link
Contributor

Hi @willashford - we talked about how the Context has become too bloated in this webinar last week, will get back to you on where those specific attributes will live in 0.18.0

@lorenabalan
Copy link
Contributor

Hi @willashford , the majority of the currently deprecated properties can be found in kedro.framework.project or in project metadata in <project_name>/pyproject.toml:

from kedro.framework.project import pipelines, settings
# you might need to also import `from kedro.framework.startup import bootstrap_project` and call it  for your tests
  • context.pipeline & context.pipelines - import pipelines and use that instead (or pipelines["__default__"])
  • context.io - duplicate of context.catalog, which we recommend - 0.18.0 might also see this changed though
  • context.package_name - is in metadata, which is the one returned by bootstrap_project or by _get_project_metadata - i.e. metadata.package_name
  • context.CONF_ROOT - import settings and use settings.CONF_ROOT

settings corresponds to your project's settings.py, and pipelines to your pipeline_registry.py and/or pipeline registration hooks.

@lorenabalan
Copy link
Contributor

A bit more context about settings and pipelines and why they are like that is here and here.

@datajoely
Copy link
Contributor

FYI - I'm going to convert this to a discussion

@kedro-org kedro-org locked and limited conversation to collaborators Jun 24, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants