Skip to content
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

Merged
merged 4 commits into from
Jun 28, 2016

Conversation

daveFNbuck
Copy link
Contributor

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.

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@Tarrasch
Copy link
Contributor

Seem to be issues with Python 3. Other than that this looks fantastic. :)

@codecov-io
Copy link

codecov-io commented Jun 27, 2016

Current coverage is 76.20%

Merging #1734 into master will decrease coverage by 2.62%

@@             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          

Powered by Codecov. Last updated by 831e390...2682b63

@Tarrasch
Copy link
Contributor

LGTM. Unless anyone objects I'll merge this. :)

@erikbern
Copy link
Contributor

LGTM

@Tarrasch Tarrasch merged commit 2b9293c into spotify:master Jun 28, 2016
p7k pushed a commit to Celmatix/luigi that referenced this pull request Jul 11, 2016
* 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)
  ...
Tarrasch added a commit that referenced this pull request Sep 15, 2016
As of #1631 this is fixed, later #1734 enhanced it
Tarrasch added a commit that referenced this pull request Sep 16, 2016
As of #1631 this is fixed, later #1734 enhanced it
@daveFNbuck daveFNbuck deleted the simplify_rpc branch June 2, 2017 00:03
This was referenced Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants