Add pass-through arguments for scheduler/worker --preload modules.#1634
Add pass-through arguments for scheduler/worker --preload modules.#1634mrocklin merged 10 commits intodask:masterfrom
--preload modules.#1634Conversation
3b99652 to
3fc9641
Compare
--preload modules.--preload modules.
--preload modules.--preload modules.
|
Thanks for taking this on. First question is "is there a convention or
common practice for doing this with the click library?" It seems like the
sort of thing that has probably come up before.
…On Thu, Dec 14, 2017 at 11:50 AM, Alexander Ford ***@***.***> wrote:
*Work in progress and untested, this PR is intended to provide a forum for
feedback on this implementation.*
Adds support for pass-through command line arguments to worker and
scheduler preload modules via an argv pattern similar to that used for
compiler subcommand arguments. Intended to provide support "generic"
preload modules with run-time configuration.
- Extension of dask_setup interface will likely break existing preload
implementations.
- Preload argument handling is *ambiguous* in the case of multiple
modules. Should the full argv set be passed to each module? Should the argv
be specified on a per-module basis?
- Test coverage and test updates.
------------------------------
You can view, comment on, or merge this pull request online at:
#1634
Commit Summary
- Add pass-through arguments for scheduler/worker `--preload` modules.
File Changes
- *M* distributed/cli/dask_scheduler.py
<https://github.com/dask/distributed/pull/1634/files#diff-0> (6)
- *M* distributed/cli/dask_worker.py
<https://github.com/dask/distributed/pull/1634/files#diff-1> (6)
- *M* distributed/nanny.py
<https://github.com/dask/distributed/pull/1634/files#diff-2> (5)
- *M* distributed/preloading.py
<https://github.com/dask/distributed/pull/1634/files#diff-3> (11)
- *M* distributed/worker.py
<https://github.com/dask/distributed/pull/1634/files#diff-4> (5)
Patch Links:
- https://github.com/dask/distributed/pull/1634.patch
- https://github.com/dask/distributed/pull/1634.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1634>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASszJyaQfDMR-t7AW9DPyw_X-MnpLviks5tAV_QgaJpZM4RCbxv>
.
|
|
I've looked through the click documentation and think this would be possible. The "clang-like" interface seems harder to support via click, but I'm not tied to that concept. Would a model that passes any "unrecognized" arguments into the preloaded module be preferable to the This interface seems better, but may complicate (a) unknown argument error handling and (b) the use of multiple preload modules. My main concern with building the "preload" logic around click is that it ties the preload implementation to a specific command-line parser, but I can see an argument for standardization. I'll explore this more and prototype a click-based system. |
|
The AppVeyor build appeared to have hung, but didn't terminate itself. So took the liberty of canceling it. Edit: Should add the previous build for this PR did the exact same thing. Probably worth investigating if there is something here causing it. |
|
@jakirkham Sorry, my intention was to skip CI for this pull until we've landed on an implementation. Would you mind checking if the [skip ci] flag I've added is now working? |
|
@mrocklin It turned out that a This obviously needs testing and documentation updates, but unfortunately I may not be able to push this to a mergeable state until early next week. Would you mind commenting on the interface as implemented? |
|
Will do, although probably not until later tonight or early tomorrow. I'm
out for the day.
Thanks again for pursuing this and looking into click conventions.
…On Thu, Dec 14, 2017 at 2:36 PM, Alexander Ford ***@***.***> wrote:
@mrocklin <https://github.com/mrocklin> It turned out that a click based
implementation was easier than I expected. I've updated this interface to
support delegation into a click.Command exposed in the preload module
attribute dask_command.
This obviously needs testing and documentation updates, but unfortunately
I may not be able to push this to a mergeable state until early next week.
Would you mind commenting on the interface as implemented?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1634 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASszKqnGcCcZqTHxYzS0FhZ2jaxYpCBks5tAYa5gaJpZM4RCbxv>
.
|
4b0d408 to
f209527
Compare
No worries. Just figured I'd mention it in case this was unexpected or you were trying to debug the CI.
Sorry. Don't seem to be seeing it. If you add |
|
In reviewing this it would be useful to see an example of how it works. Perhaps add a test following the pattern in |
|
I'm finding review this to be a bit of a challenge due to my own lack of familiarity with the CC'ing @danielfrg in case cd he has time and has experience with common conventions on how to pass through keyword arguments to downstream commands. @danielfrg , in brief the Where |
|
I kinda like what wait-for-it does you pass a It will look like: |
This would presumably go outside of standard I think what I'm looking for is a way to pass keywords down to subcommands. I want the click equivalent of passing def f(x=1, y=2, **kwargs):
tmp = g(**kwargs)
return x + y + tmp
def g(z=3, **kwargs):
... |
|
Yes, the "--" delimited approach is hard to do with click. I believe you'd
need to layer ad additional parsing layer on to the click system. This
implementation just passed any args that aren't recognised by the dask
parser into a *single* dynamically loaded click command.
On Thu, Dec 21, 2017, 12:43 Matthew Rocklin ***@***.***> wrote:
I kinda like what wait-for-it does you pass a -- and after that the extra
command and flags.
This would presumably go outside of standard click approaches though,
yes? I'm not a good judge of how fancy this is or what conventions are
these days, but I'm a little hesitant about this.
I think what I'm looking for is a way to pass keywords down to
subcommands. I want the click equivalent of passing **kwargs
def f(x=1, y=2, **kwargs):
tmp = g(**kwargs)
return x + y + tmp
def g(z=3, **kwargs):
...
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1634 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARQqJrn6VSjglsjP2YL2zL7WgAPxYEvks5tCsMDgaJpZM4RCbxv>
.
--
Alex Ford
a.sewall.ford@gmail.com
206.659.6559
|
|
Any thoughts on the implementation in this PR @danielfrg ? (again, assuming
you have the time for review)
On Thu, Dec 21, 2017 at 7:16 PM, Alexander Ford <notifications@github.com>
wrote:
… Yes, the "--" delimited approach is hard to do with click. I believe you'd
need to layer ad additional parsing layer on to the click system. This
implementation just passed any args that aren't recognised by the dask
parser into a *single* dynamically loaded click command.
On Thu, Dec 21, 2017, 12:43 Matthew Rocklin ***@***.***>
wrote:
> I kinda like what wait-for-it does you pass a -- and after that the extra
> command and flags.
>
> This would presumably go outside of standard click approaches though,
> yes? I'm not a good judge of how fancy this is or what conventions are
> these days, but I'm a little hesitant about this.
>
> I think what I'm looking for is a way to pass keywords down to
> subcommands. I want the click equivalent of passing **kwargs
>
> def f(x=1, y=2, **kwargs):
> tmp = g(**kwargs)
> return x + y + tmp
> def g(z=3, **kwargs):
> ...
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#1634 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/
AARQqJrn6VSjglsjP2YL2zL7WgAPxYEvks5tCsMDgaJpZM4RCbxv>
> .
>
--
Alex Ford
***@***.***
206.659.6559 <(206)%20659-6559>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1634 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASszAV-R34js5bwAHNAhfqw9ULtVbJ8ks5tCvTGgaJpZM4RCbxv>
.
|
|
OK, I gave this a shot with the following example: # click_test.py
@click.command(context_settings={'ignore_unknown_options': True})
@click.option('--foo', type=str)
def dask_setup(foo):
print(foo)
if __name__ == '__main__':
dask_setup()It's not clear to me how to use this work properly yet. I appreciate the informative error messages. |
6dbabe5 to
8b345f5
Compare
|
Rebased, added initial test coverage and documented. This should now be ready for review. |
--preload modules.--preload modules.
|
It looks like the CI error was py2.7 distributed/tests/test_worker.py::test_statistical_profiling_cycle. I haven't been able to repro locally in a conda-based python 2.7 development environment. Is it possible that this test is flaky? |
|
Yes, that test is known to be flaky. I have a fix in a local branch. Feel
free to disregard for now (there are a few more of these lingering around
as well).
…On Fri, Dec 29, 2017 at 2:11 AM, Alexander Ford ***@***.***> wrote:
It looks like the CI error was py2.7 distributed/tests/test_worker.
py::test_statistical_profiling_cycle
<https://travis-ci.org/dask/distributed/jobs/322776454#L2209>. I haven't
been able to repro locally in a conda-based python 2.7 development
environment. Is it possible that this test is flaky?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1634 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASszCOLFUY4DRX0ojL9-SFrOiBe3SvAks5tFLq1gaJpZM4RCbxv>
.
|
|
@mrocklin @danielfrg Friendly ping on this pull. Happy to revise the implementation, but would like to have a +1/-1 and plan for a merge. |
mrocklin
left a comment
There was a problem hiding this comment.
In principle the approach looks good to me. I've raised a couple of points below.
| @click.command() | ||
| @click.option("--passthrough", type=str, default="default") | ||
| def dask_command(passthrough): | ||
| _config["passthrough"] = passthrough |
There was a problem hiding this comment.
I'm inclined to just put the command bits on dask_setup rather than add a new special function. Presumably these run at the same time anyway?
There was a problem hiding this comment.
Understood, fixed below.
| return value | ||
|
|
||
| if value and not ctx.params.get("preload", None): | ||
| raise click.UsageError("Additional preload arguments specified without --preload target.") |
There was a problem hiding this comment.
This might be valuable to include in a test. We want to make ensure that operations like dask-scheduler --bad-keyword do genuinely raise informative arguments. In these cases we probably don't want to talk about --preload but rather just mention that there are unknown keywords (and perhaps list what they are).
There was a problem hiding this comment.
Updated in commit below to match click error messages for unknown options and extra arguments.
Adds support for optional command-line parsing to worker and scheduler --preload modules. Modules *may* support an additional `dask_command` module attribute, which must provide a click.Command to be used in parsing command-line options from the root command-line interface. `dask_command` will be invoked with any "additional" arguments specified on the command line interface, and is expected to configure the preload module. Following calls to `dask_setup` and `dask_teardown` provide the target worker or scheduler objects.
Adds initial test coverage for click-based preload arguments. Fixup errors in preload argument specification and preload main handling.
From review, convert to parsing options on dask_setup if provided as a click command. Fixup error messages from unknown/extra options to match click conventions if preload argment module isn't provided.
cc35032 to
7fcdd79
Compare
|
An experiment and results: # foo.py
import click
@click.command()
@click.option("--cmd", type=str, default='default')
def dask_setup(scheduler, cmd):
print("Hello")
print(cmd)
print("running")Why the reloads? Why did |
|
Otherwise everything feels smooth on my end |
|
This occurs when a source preload The This forced reload prevents the import system from using the cached initial If this behavior seems too spooky it would be possible to fully parse the |
|
Example tracebacks below, lightly trimmed for clarity: Preload SourcePreload via module name, single importImport via filename, repeated import |
|
I again apologize for the long delay here. I've merged in master and pushed. Merging on passed tests. |
|
This is in. Thank you for your work and patience @asford |
Adds support for pass-through command line arguments to worker and scheduler preload modules via an
argvpattern similar to that used for compiler subcommand arguments. Intended to provide support "generic" preload modules with run-time configuration.Extension ofExtends preload interface with an optionaldask_setupinterface will likely break existing preload implementations.dask_commandmodule attribute.dask_commandinterface. Applications requiring multiple preload modules may declare a single "top-level" module chaining the required subcommands.