-
Notifications
You must be signed in to change notification settings - Fork 651
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
FIX-#4564: Workaround import issues in Ray: auto-import pandas on python start if env var is set #4603
FIX-#4564: Workaround import issues in Ray: auto-import pandas on python start if env var is set #4603
Conversation
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
Codecov Report
@@ Coverage Diff @@
## master #4603 +/- ##
==========================================
+ Coverage 86.56% 89.69% +3.13%
==========================================
Files 230 231 +1
Lines 18470 18734 +264
==========================================
+ Hits 15988 16803 +815
+ Misses 2482 1931 -551
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
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.
This looks pretty good, although it introduces minor friction for users who want to get started and initialize Ray themselves. Probably need extra documentation or something because we recommend users to start the engine themselves.
Can you add runtime env to an already running Ray cluster?
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.
How does it work in the case I didn't install modin? Suppose, I'm working in modin
-root folder.
You can set runtime env even on per-task basis, but in this case it won't have any particular effect as the interpreter in each worker has already been initialized. As for docs... I'm open for suggestions on where to put things.
Obviously, it won't have the workaround effect, but TBH this isn't the main use case, plus I personally never saw this issue locally. If someone is really bothered by this issue, one could |
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
For hinting the users on how to initialize Ray, this is how current (in this PR) warning look like:
|
Whoa, poor user, so many extra info... |
It was like this for quite a while, but before this PR it simply stated
|
What do you think if we leave the warning as is (just |
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
I don't think adding a little bit of info in our warning would make any harm, but I think it would harm user's experience when they would receive some spurious failures until they would realize that there is a troubleshooting guide on that... |
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
@@ -138,17 +87,16 @@ def initialize_ray( | |||
include_dashboard=False, | |||
ignore_reinit_error=True, | |||
_redis_password=redis_password, | |||
**extra_init_kw, |
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.
Did you check this case? I can't find that extra parameters could be provided in case of existing cluster https://github.com/ray-project/ray/blob/master/python/ray/_private/worker.py#L1400-L1412
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.
I hadn't, but apparently extra ones would just get ignored, and, if in the future we'll add more arguments than runtime_env
it would be useful.
As for the runtime environment being different, there is a code later on checking the variables. It should give a warning to the user.
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.
I hadn't, but apparently extra ones would just get ignored, and, if in the future we'll add more arguments than runtime_env it would be useful.
Can you elaborate why it would be useful?
As for the runtime environment being different, there is a code later on checking the variables. It should give a warning to the user.
What the code do you mean?
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 you elaborate why it would be useful?
This creates one central place to add more arguments to ray.init()
instead of copy-pasting them in several different places.
What the code do you mean?
modin/modin/core/execution/ray/common/utils.py
Lines 170 to 177 in e426ce0
else: # ray is already initialized, check runtime env config | |
env_vars = ray.get_runtime_context().runtime_env.get("env_vars", {}) | |
for varname, varvalue in extra_init_kw["runtime_env"]["env_vars"].items(): | |
if str(env_vars.get(varname, "")) != str(varvalue): | |
ErrorMessage.single_warning( | |
"If initialising Ray yourself, please ensure its runtime env " | |
+ f"sets environment variable {varname} to {varvalue}" | |
) |
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.
We don't hit this branch in case of cluster init.
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.
Huh?.. we either call ray.init()
or hit this else:
branch.
We hit ray.init()
at line 84 (under if cluster:
) or at line 158 (in else
branch of that if cluster
).
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.
I was just wondering if we should check the runtime environment after ray.init() in case Modin itself initializes Ray? Because of this.
Did you check this case? I can't find that extra parameters could be provided in case of existing cluster https://github.com/ray-project/ray/blob/master/python/ray/_private/worker.py#L1400-L1412
I hadn't, but apparently extra ones would just get ignored
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.
good point!
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
What about modin.config - https://modin.readthedocs.io/en/stable/flow/modin/config.html? |
@vnlitvinov, that is fine to me. Please also take into account my previous comments, which are unresolved. |
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.
@vnlitvinov looks great! There are a couple of comments here about cluster-related handling.
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.
Left a quick change as well as a question
) | ||
ray.worker.global_worker.run_function_on_all_workers(_import_pandas) | ||
else: # ray is already initialized, check runtime env config | ||
env_vars = ray.get_runtime_context().runtime_env.get("env_vars", {}) |
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.
This only checks that the head nodes env vars are set correctly, right? Don't we need to set the environment variable on all of the workers/nodes, and if so, shouldn't we be checking that the env vars are set correctly on all of the workers? We could probably do that using the ray function that runs on all workers.
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.
No, .runtime_env
is the thing which tells Ray which environment variables to set for its workers. It should set these variables for the workers automatically.
Co-authored-by: Rehan Sohail Durrani <rdurrani@berkeley.edu>
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
74ebc29
to
49029e2
Compare
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
@vnlitvinov, build docs job failed because of |
Huh, when I look at the CI of the last commit (887a5f4) docs are built fine. Am I missing things? |
Thanks. I've missed an empty line after |
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
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.
@vnlitvinov, LGTM, thanks!
So green light for python 3.10 support? :) |
Technically yes, though note that Ray still does not have published 1.13 in conda-forge... |
What do these changes do?
Based on what I found in #4564 (comment), I think the real root cause of #4564 (and other similar issues with inability to import pandas) is the Python bug https://bugs.python.org/issue38884, which rises from the fact that they seem to have dropped the idea of the import lock in Python 3.3+.
This PR aims to workaround that by doing the following:
.pth
file to be shipped which, when package is installed, is placed undersite-packages
automatically and, when processed by Python interpreter, importspandas
if special environment variable is setsetup.py
so this special file is part of both source and binary distributionsflake8 modin/ asv_bench/benchmarks scripts/doc_checker.py
black --check modin/ asv_bench/benchmarks scripts/doc_checker.py
git commit -s
docs/development/architecture.rst
is up-to-date