-
Notifications
You must be signed in to change notification settings - Fork 57
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
Feature/ Runtime validation of TaskInstanceParameter() and ListTaskInstanceParameter() by subclass bound #305
Conversation
@mski-iksm Thank you for creating the PR! I forgot to make a PR after making this issue. |
@mski-iksm @hirosassa @Hi-king please review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
gokart/parameter.py
Outdated
logger = getLogger(__name__) | ||
|
||
|
||
class TaskInstanceParameter(luigi.Parameter): | ||
|
||
def __init__(self, *args, **kwargs): | ||
bound = kwargs.pop('bound', gokart.TaskOnKart) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean subtype bound, how about just use 'type' keyword? There might be both upper and lower for 'bound' keyword.
Thank you for the reviews! I found How about this implementation? Sample class TaskInstanceParameter(luigi.Parameter):
...
def _warn_on_wrong_param_type(self, param_name, param_value):
if self.__class__ != TaskInstanceParameter:
return
if not isinstance(param_value, self.expected_type):
raise TypeError(f'{param_value} is not an instance of {self.expected_type}') |
I've updated implementation to use _warn_on_wrong_param_type. Could you review again? @mski-iksm @hirosassa @Hi-king |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ujiuji1259 LGTM!
@ganow Thx for suggesting nice feature for improving reliability :) @ujiuji1259 Thank you for the reasonable implementation! 👍 |
Issue: #268
I've implemented runtime validation of TaskInstanceParameter() and ListTaskInstanceParameter() by subclass bound.
@ganow I'd like to use this feature, so I've created a PR based on your idea. Thank you for your feature request and the concrete implementation idea!