-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Packages and definitions loaded in the regular kernel are not known by engines and vice versa #897
Comments
%%px --local
def foo():
....
|
@minrk ahh ok thanks! I haven't seen that in the docs and still can't. Would you mind pointing me to the docs as well? |
I now checked again and try to use %pxconfig --local --verbose
%autopx as global config. I however than have the problem that I cannot execute local cells only. Here are my two tests: The idea is to use something like %autopx # disable global
# do local stuff for testing
%autopx # enable again in a single cell. Problems:
Another way would be to %pxconfig --targets 0 Problems:
|
To answer specific questions:
That's right.
you can use:
to use all targets again. You can run
This is not well documented, sorry! I'll try to write up a new tutorial notebook with this kind of thing in mind. But the short-term answer is: interactive documentation always works: run |
Thanks a lot for this detailed reply. I do agree that a explicit I however experience problems with linter / formatter no longer working when the magic is included at the top of the cell. %pxconfig --local --verbose
%autopx globally and turning No problem for the documentation! |
what linter are you using? I know ruff doesn't understand most cell magics, but nbqa can and so can black. |
I actually use ruff now. In the past I used black. I already read about The ruff issue you linked is thus highly relevant to me! Thanks for creating it! |
I know that the now recommended approach is to not use I just noticed, that in import ipyparallel as ipp
cluster = ipp.Cluster(engines="MPI", n=4, cluster_id="ppb", profile="MPI")
clients = cluster.start_and_connect_sync()
%pxconfig --local --verbose
# enable
%autopx the def foo():
print("bar")
foo() works just fine. # disable
%autopx foo() I get
Any idea what I miss here? |
My guess is there's something missing in autopx, perhaps not handling |
Looking at the code, |
Thanks!. I see your point though. |
You can see the updated parallel magics doc here. |
Importing modules or defining functions in regular cells (without the
%%px
magic) are not known in cells where the%%px
macro is used.The same is true for the other way around.
To reproduce this try
Cell 5 and Cell 6 will fail on both statements in each.
A global
%autopx
would ensure that everything runs on the engines, which makes development kind of inconvenient (e.g. prints are done on all engines and so on).Defining different views and activating them according to how many engines are needed, e.g. one for development with a single engine, seems overkill.
What is the recommended approach to solve the outlined problem?
The text was updated successfully, but these errors were encountered: