-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expose literal and quote #3275
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
Expose literal and quote #3275
Conversation
We'd like to get your thoughts on this @jcrist. Does this seem like a reasonable way to approach the problem? |
4b5fc1b
to
a7eef14
Compare
I don't feel comfortable exposing this as top-level api for a few reasons:
I'd be fine if you used them in your own code, as I doubt they'll change, but I wouldn't add them to the top-level namespace. For your specific case, I'd first ask why you want access to a future in the delayed function (as Matt pointed out, this is a bit unusual). If there's not a better way of handling this, then I'd add a @delayed
def foo(future, *args):
...
foo(delayed(future, literal=True), *args) This seems more consistent, keeps our api surface low, and doesn't expose internal bits at the task level in the top-level namespace. |
Was thinking about this functionality in the context of this comment. The strategy there is not limited to HDF5 files and could be just as applicable to addressing issue ( #3255 ). IOW really any situation where writing to a file cannot be done safely in parallel and we would like to open the file only once in a task to handle this writing. Perhaps there are other strategies that would still allow a single task to write to a file. Would be interested in your input in those contexts as well. :) |
Interesting. I recommend opening an issue about this specific issue (especially if you can think of a few more usecases besides hdf5 for support) and we can work for a resolution there. As for this specific fix, I'm going to say no for now (although we can re-open later if needed). |
People have asked for similar things in the past. This would also be relevant to passing dask arrays or dask dataframes into delayed functions. This does come up sometimes in advanced workloads by advanced users. It does come up more often by less advanced users who don't quite know what they're doing though. I think that having a Doing this as the keyword level seems less good to me for two reasons:
Honestly the status quo of using |
Ok, I can see how this might be nice to have.
I'm not sure I agree with that. Given the usecase that I want to pass some object to a delayed function in a way that dask that does nothing to it, both ways look equivalent: # Using literal
foo(literal(a), b)
# using delayed
foo(delayed(a, literal=True), b) However, the second option has a few things going for it:
I also think this is a bit of an odd thing to do, so making it not apparent in the top-level api might help force people to rethink their problem a bit before diving in. |
That makes sense to me. I think I was thinking of the following: foo(a, b, literal=True) I was not considering using delayed to wrap the object directly. This seems fine to me. |
Just thinking about keyword names, perhaps we might want to deprecate the boolean
to three:
Seems like these are all exclusive options, so one keyword makes more sense than 2. |
So your |
Normally I would agree with you that a function should do only one thing, and other things should have other names. However, this is outweighed in my mind by the following benefits:
|
Honestly this was just a style point. No strong feelings personally. So are we ok with using |
Thinking about this some more, I think a boolean flag is fine but the existing semantics of
My thought is that the times where you want # this is equivalent to `traverse=False`, using the proposed changes above
x2 = delayed(x, wrap=is_dask_collection(x)) The I'm not set on the name Edit: could also see |
So I vaguely remember you mentioning something about thoughts you had on this last week, @jcrist, but don't recall whether we discussed them. Does this ring a bell? Do you remember what they were? |
I am closing this since it is pretty stale at this point. Please reopen if you are planning on continuing the work. |
Includes
literal
andquote
in the public API following discussion in this SO question.cc @mrocklin