Describe the problem
Currently, ray/worker.py seems too heavy. It contains ~3000 lines of code (maybe 1/3 of core python code of ray).
And its a bit messy (contains nearly all kinds of structure-breaking reference🙃) :
global_worker = Worker()
class Worker:
def func_a(self):
foo(worker=self)
def func_b(self):
foo()
def func_c(self):
put()
def func_d(self):
bar(worker=self)
def func_d(self):
bar(worker=global_worker)
def foo(worker=global_worker):
pass
def bar(worker):
pass
def put():
do_something(global_worker)
What's more, worker.py contains all these things:
- logging utils
- serialization utils
- core worker logics
- ray APIs
- ray exceptions
- constants
Since a possible correct dependency may look like:

, it could be better to divide worker.py into several independent modules. We could keep ray's APIs in worker.py so it may not affect other parts of ray.
I want to know if a PR for refactoring worker.py is welcomed? (I understand that such a PR is heavy and may be unnecessary now.)
Describe the problem
Currently,
ray/worker.pyseems too heavy. It contains ~3000 lines of code (maybe 1/3 of core python code of ray).And its a bit messy (contains nearly all kinds of structure-breaking reference🙃) :
What's more,
worker.pycontains all these things:Since a possible correct dependency may look like:
, it could be better to divide
worker.pyinto several independent modules. We could keep ray's APIs inworker.pyso it may not affect other parts of ray.I want to know if a PR for refactoring
worker.pyis welcomed? (I understand that such a PR is heavy and may be unnecessary now.)