Skip to content
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

Can we use dashes in yml syntax for the config.yml? #1790

Closed
merelcht opened this issue Aug 17, 2022 · 1 comment
Closed

Can we use dashes in yml syntax for the config.yml? #1790

merelcht opened this issue Aug 17, 2022 · 1 comment
Assignees
Labels
Component: CLI Issue/PR that addresses the CLI for Kedro

Comments

@merelcht
Copy link
Member

Introduction

#1485

Problem

Currently, there are 2 ways to provide argument to kedro run CLI.

  1. Using the CLI argument kedro run --from-nodes=some_node
  2. Using the --config argument and define the arguments in a YAML file. kedro run --config=config.yml
# config.yml
run:
  from_nodes: some_node # Notice this is underscore instead of a dash

Task

Ideally the YAML config should use the same arguments as the CLI, i.e. using the dash instead of the underscore. Investigate if it's possible to use dashes in config.yml. The click context handles some of this logic, and so we need to find out if it is possible to use dash in yaml or not. If it is possible, then we'll implement it, but that would be a breaking change.

@merelcht
Copy link
Member Author

This doesn't seem to be possible because of the way click parses parameters.

I haven't been able to fully trace how the config file gets read and parsed, because the click code is super hard to follow and debugging doesn't really work.
But what I've figured out is that when you pass config in yaml and specify from_nodes, this gets filled in as the value in: https://github.com/kedro-org/kedro/blob/main/kedro/framework/cli/project.py#L386. In python you can't name arguments with a dash like "from-nodes" and so if you provide it like that in config.yml, click can't map the value to the python argument.

This part in the click docs talks a bit about naming of paramters: https://click.palletsprojects.com/en/8.1.x/parameters/#parameter-names and they mention "If a name is not prefixed, it is used as the Python argument name and not parsed as an option name."

@github-project-automation github-project-automation bot moved this from In Progress to Done in Kedro Framework Jan 13, 2023
@merelcht merelcht self-assigned this Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CLI Issue/PR that addresses the CLI for Kedro
Projects
Archived in project
Development

No branches or pull requests

1 participant