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

Add parameter alias to inherits_config_params #193

Conversation

mski-iksm
Copy link
Contributor

@mski-iksm mski-iksm commented Apr 14, 2021

This update allows to replace parameter name of inherited config Task, when using @inherits_config_params decorator.

Currently, when using @inherits_config_params, parameter name of inheriting config Task and decorated Task must be same. After this PR, parameter name can be replaced by passing parameter names dictionary param_config2task to @inherits_config_params decorator.

Please review!
@hirosassa @vaaaaanquish @e-mon @Hi-king

Copy link
Contributor

@vaaaaanquish vaaaaanquish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like you to write a document :)

@@ -25,6 +25,12 @@ class Inherited(gokart.TaskOnKart):
param_b = luigi.Parameter(default='overrided')


@inherits_config_params(ConfigClass, param_config2task={'param_a': 'param_d'})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would you be happy with this feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vaaaaanquish
This would be useful when ConfigClass and Wrapped class has different parameter name but want to have common value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import luigi

import gokart


class inherits_config_params:
def __init__(self, config_class: luigi.Config):
self.config_class: luigi.Config = config_class
def __init__(self, config_class: luigi.Config, param_config2task: Optional[Dict[str, str]] = None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mski-iksm [nits] Plz write docstring about args here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hi-king
I've changed param_config2task to parameter_alias. Please review!

Copy link
Contributor

@vaaaaanquish vaaaaanquish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@Hi-king Hi-king left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Hi-king Hi-king merged commit 5eb59d8 into m3dev:master Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants