-
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
Removes redundant function definitions from rpc and server #1734
Conversation
When defining a new API call in the scheduler, there are three steps that must be taken. First, you create the function in CentralPlannerScheduler. Next, you define the same function with the same signature in RemoteScheduler. This second function just aggregates its arguments in a dictionary and passes them to _request. Finally, the function must be registered in server.py. These last two steps are extremely automatable, so I moved them into a decorator that gets applied to all rpc-accessible functions in CentralPlannerScheduler.
# If request args are passed, return this function again for use as | ||
# the decorator function with the request args attached. | ||
if fn is None: | ||
return functools.partial(rpc_method, **request_args) |
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.
Can we avoid this magic if we just force everyone to do @rpc_method()
instead of the slightly more convenient rpc_method
?
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.
Sure, I'll make that update.
Seem to be issues with Python 3. Other than that this looks fantastic. :) |
Current coverage is 76.20%@@ master #1734 diff @@
==========================================
Files 95 95
Lines 10346 10341 -5
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 8155 7880 -275
- Misses 2191 2461 +270
Partials 0 0
|
LGTM. Unless anyone objects I'll merge this. :) |
LGTM |
* spotify/master: (25 commits) Version 2.2.0 Add tests for hashing parameters (spotify#1719) Update call to iteritems in luigi/tools/deps: deprecated in Python 3 (spotify#1749) Reset terminal colors in external_program (spotify#1742) Caches get_autoconfig_client on a per-thread basis Fix bug with GCSFlagTarget Add additional event handlers to tasks (spotify#1698) Reduce number of get_params calls in common_params. Removes redundant function definitions from rpc and server (spotify#1734) Fix salesforce default content type (spotify#1724) Rename MockTarget class variable _fn to path Remove MockTarget path property Deprecated LocalTarget fn propery Add note about underscore in parameter names (spotify#1729) Remove tracking url callback hack (spotify#1722) Consistent Luigi spelling in docs (spotify#1723) Update example_top_artists.rst (spotify#1662) Add combiner to docstrings in mrrunner Add luigi-deps-tree visualising tool (spotify#1680) Adding release step for Debian packages. (spotify#1718) ...
Description
When defining a new API call in the scheduler, there are three steps that
must be taken. First, you create the function in CentralPlannerScheduler.
Next, you define the same function with the same signature in
RemoteScheduler. This second function just aggregates its arguments in a
dictionary and passes them to _request. Finally, the function must be
registered in server.py.
These last two steps are extremely automatable, so I moved them into a
decorator that gets applied to all rpc-accessible functions in
CentralPlannerScheduler.
Motivation and Context
We've wanted to simplify the way the rpc works in the past. The addition of registration in server makes this even more important. I'm tired of bugs during development caused by inconsistencies between the three locations a function must be mentioned.
Have you tested this? If so, how?
The current rpc tests should be enough. I think they miss the graph-related functions and maybe a few others, but there's nothing different about those and an error would probably get caught by some other integration test I'm hoping.