-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Dynamic Requires incorrectly treats all luigi.Parameter as strings #1607
Comments
nice catch. is it simple to fix? |
I've identified the result of the error, but not the cause of it. I'm not sure exactly where to find the execution of dynamic requirements in Luigi Core. Can you point me in the right direction, @erikbern ? |
should be somewhere in worker.py (which is a terrible mess unfortunately) |
@erikbern Thanks. I'll take a look and see what i can find. |
excellent! |
I'm pretty lost when trying to decode what all is happening within worker.py... I'll spend some more time trying to decipher when I return from PTO next week. |
Check out https://github.com/spotify/luigi/blob/master/luigi/worker.py#L104 That is where you'll see the yielded dependencies are put on a multiprocessing Queue and then picked up by Worker class and loaded to be added to scheduler. |
I can read through Worker.py and vaguely understand the logic, but am still lost when it comes to how this bug arises. I see that DictParameter has been added to parameter.py. Would it be worth adding ListParameter and TupleParameter to ensure the type of Parameter being pass (and possibly bypass this dynamic requires bug), @erikbern ? |
Do you have any custom parameters? The Parameter class implements the methods I haven't looked at the code |
Looks like here it uses |
I do not have any customer parameters. Presently, Parameter.parse(...) just returns the value and serialize(...) casts the value to a string. So yes, So although It then seems necessary to implement a If you believe otherwise, I'll go your route. |
So |
With this said I would not expect passing lists to a standard Parameter object to work so I am surprised the |
Ah, dynamic dependencies have |
So then, dynamic requires functioned as expected. The issue is that |
It might be good to do a |
Since Should |
@erikbern , thoughts on class Parameter(object):
....
def parse(self, x):
return str(x) verus class Parameter(object):
....
def parse(self, x):
if not isinstance(x, basestring) or not isinstance(x, str):
warnings.warn("Parameter %r is not of type string." % x)
return x ? |
yes the latter looks good |
As issues are solved via PRs, they need to be closed. I just came across the keywords used to reference and auto close issues. Maybe we can try to enforce this more? Keep things clean and organized. |
I actually knew that keyword. Please start using it. I think it's hard to enforce as not everybody knows about it. :) |
As noted by the title, dynamic requirement Parameters are treated as strings (where the required class is expected luigi.Parameter()). DateParameter, IntParameter, etc are treated appropriately.
This issue was found when dynamically requiring an arbitrary number of redshift.S3CopyToTable statements to temporary tables. Columns and queries are passed as lists, but errors were being throw because these lists were being interpreted as strings.
I have written the following luigi code to note this error (I have noted the actual output in both cases - normal requires, as well as dynamic requires):
The text was updated successfully, but these errors were encountered: