Change priority of cell execution in jupyter notebook?How to export one cell of a jupyter notebook?Correct way to set Spark variables in jupyter notebookShare Jupyter Notebook with a non programmerHow to download a Jupyter Notebook from GitHub?Jupyter notebook running very slowInstalled module pysubgroup not found in Jupyter NotebookProblem importing CNTK in Azure jupyter notebookProblem upgrading pip command in Azure Jupyter notebookrequesting password while git push in jupyter notebookopen jupyter notebook file in linux from folder system
Would this string work as string?
How to test the sharpness of a knife?
Unfrosted light bulb
How do researchers send unsolicited emails asking for feedback on their works?
How do you justify more code being written by following clean code practices?
Pre-Employment Background Check With Consent For Future Checks
Hackerrank All Women's Codesprint 2019: Name the Product
How can I query the supported timezones in Apex?
What is the reasoning behind standardization (dividing by standard deviation)?
Would it be believable to defy demographics in a story?
Why didn't Héctor fade away after this character died in the movie Coco?
Print a physical multiplication table
label a part of commutative diagram
Why is "la Gestapo" feminine?
Print last inputted byte
Do I need an EFI partition for each 18.04 ubuntu I have on my HD?
Do I need to convey a moral for each of my blog post?
What is the difference between something being completely legal and being completely decriminalized?
pipe commands inside find -exec?
TDE Master Key Rotation
10 year ban after applying for a UK student visa
What will the french man say?
What (if any) is the reason to buy in small local stores?
UK Tourist Visa- Enquiry
Change priority of cell execution in jupyter notebook?
How to export one cell of a jupyter notebook?Correct way to set Spark variables in jupyter notebookShare Jupyter Notebook with a non programmerHow to download a Jupyter Notebook from GitHub?Jupyter notebook running very slowInstalled module pysubgroup not found in Jupyter NotebookProblem importing CNTK in Azure jupyter notebookProblem upgrading pip command in Azure Jupyter notebookrequesting password while git push in jupyter notebookopen jupyter notebook file in linux from folder system
$begingroup$
I am sometimes in the following situation:
I want to execute two cells: Cell 1 takes on the order of 10 minutes or hours. Cell 2 will take 1 second.
I'd rather execute cell 2 first and see the result, but I didn't know that beforehand and hence already started cell 1.
cell 1 is already significantly into the computation, so it would be wasteful to just abort it.
How do I first pause cell 1, then start cell 2, and then start cell 1 again? Or even better, how do I pause cell 1, start cell 2, and have cell 1 automatically start again when cell 2 is done?
python jupyter
$endgroup$
bumped to the homepage by Community♦ 2 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
$begingroup$
I am sometimes in the following situation:
I want to execute two cells: Cell 1 takes on the order of 10 minutes or hours. Cell 2 will take 1 second.
I'd rather execute cell 2 first and see the result, but I didn't know that beforehand and hence already started cell 1.
cell 1 is already significantly into the computation, so it would be wasteful to just abort it.
How do I first pause cell 1, then start cell 2, and then start cell 1 again? Or even better, how do I pause cell 1, start cell 2, and have cell 1 automatically start again when cell 2 is done?
python jupyter
$endgroup$
bumped to the homepage by Community♦ 2 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
$begingroup$
I am sometimes in the following situation:
I want to execute two cells: Cell 1 takes on the order of 10 minutes or hours. Cell 2 will take 1 second.
I'd rather execute cell 2 first and see the result, but I didn't know that beforehand and hence already started cell 1.
cell 1 is already significantly into the computation, so it would be wasteful to just abort it.
How do I first pause cell 1, then start cell 2, and then start cell 1 again? Or even better, how do I pause cell 1, start cell 2, and have cell 1 automatically start again when cell 2 is done?
python jupyter
$endgroup$
I am sometimes in the following situation:
I want to execute two cells: Cell 1 takes on the order of 10 minutes or hours. Cell 2 will take 1 second.
I'd rather execute cell 2 first and see the result, but I didn't know that beforehand and hence already started cell 1.
cell 1 is already significantly into the computation, so it would be wasteful to just abort it.
How do I first pause cell 1, then start cell 2, and then start cell 1 again? Or even better, how do I pause cell 1, start cell 2, and have cell 1 automatically start again when cell 2 is done?
python jupyter
python jupyter
asked Feb 16 at 9:48
user637140user637140
413
413
bumped to the homepage by Community♦ 2 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 2 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
I don't think Jupyter notebooks (even via extensions) currently offer pausing/restarting cell blocks. I would suggest putting the code of both cells into a single cell and using Python logic to determine the order of execution.
In general, however, you cannot strictly pause the execution of something and come back to it later. If you abort the execution of the function, the intermediate results are lost (because they are stored within the namespace of the function you effectively just killed). This is because Python only runs one single process at a time (key term: Global Interpreter Lock).
The only thing you might be able to do is create a cell 0, which performs some kind of check, testing how long cell 1 might take to run, then just put cell 1 and cell 2 in and if/else construction that gives the correct order to use.
Other approaches
You might want to look into something like the multiprocessing library. There you can create a group of worker processors, to which you can send the contents of cell 1 and at the same time the contents of cell 2. They will be computed at the same time, using two different processes i.e. two different instances of the Python interpreter. This can be easy to achieve if there is no direct dependency between (in your case) cell 1 and cell 2. Multiprocessing is particularly useful in the case that your long-running cell is compute bound, meaning is has to perform a large computation.
Yet another option would be to investigate the threading module and concurrent programming in general, but this get a little more complicated and is probably beyond what you want in your situation (it also requires more effort to get working that multiprocessing). This allows Python to kind of do two things at once, but with shared state - so each running thread can change variables that the other thread might also be changing, which can require a lot of work to make safe. This approach is however beneficial when you tasks are IO bound, i.e. there is no big computation, but rather you send data e.g. to a website and wait for a return - most your time is spent waiting.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "557"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f45679%2fchange-priority-of-cell-execution-in-jupyter-notebook%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
I don't think Jupyter notebooks (even via extensions) currently offer pausing/restarting cell blocks. I would suggest putting the code of both cells into a single cell and using Python logic to determine the order of execution.
In general, however, you cannot strictly pause the execution of something and come back to it later. If you abort the execution of the function, the intermediate results are lost (because they are stored within the namespace of the function you effectively just killed). This is because Python only runs one single process at a time (key term: Global Interpreter Lock).
The only thing you might be able to do is create a cell 0, which performs some kind of check, testing how long cell 1 might take to run, then just put cell 1 and cell 2 in and if/else construction that gives the correct order to use.
Other approaches
You might want to look into something like the multiprocessing library. There you can create a group of worker processors, to which you can send the contents of cell 1 and at the same time the contents of cell 2. They will be computed at the same time, using two different processes i.e. two different instances of the Python interpreter. This can be easy to achieve if there is no direct dependency between (in your case) cell 1 and cell 2. Multiprocessing is particularly useful in the case that your long-running cell is compute bound, meaning is has to perform a large computation.
Yet another option would be to investigate the threading module and concurrent programming in general, but this get a little more complicated and is probably beyond what you want in your situation (it also requires more effort to get working that multiprocessing). This allows Python to kind of do two things at once, but with shared state - so each running thread can change variables that the other thread might also be changing, which can require a lot of work to make safe. This approach is however beneficial when you tasks are IO bound, i.e. there is no big computation, but rather you send data e.g. to a website and wait for a return - most your time is spent waiting.
$endgroup$
add a comment |
$begingroup$
I don't think Jupyter notebooks (even via extensions) currently offer pausing/restarting cell blocks. I would suggest putting the code of both cells into a single cell and using Python logic to determine the order of execution.
In general, however, you cannot strictly pause the execution of something and come back to it later. If you abort the execution of the function, the intermediate results are lost (because they are stored within the namespace of the function you effectively just killed). This is because Python only runs one single process at a time (key term: Global Interpreter Lock).
The only thing you might be able to do is create a cell 0, which performs some kind of check, testing how long cell 1 might take to run, then just put cell 1 and cell 2 in and if/else construction that gives the correct order to use.
Other approaches
You might want to look into something like the multiprocessing library. There you can create a group of worker processors, to which you can send the contents of cell 1 and at the same time the contents of cell 2. They will be computed at the same time, using two different processes i.e. two different instances of the Python interpreter. This can be easy to achieve if there is no direct dependency between (in your case) cell 1 and cell 2. Multiprocessing is particularly useful in the case that your long-running cell is compute bound, meaning is has to perform a large computation.
Yet another option would be to investigate the threading module and concurrent programming in general, but this get a little more complicated and is probably beyond what you want in your situation (it also requires more effort to get working that multiprocessing). This allows Python to kind of do two things at once, but with shared state - so each running thread can change variables that the other thread might also be changing, which can require a lot of work to make safe. This approach is however beneficial when you tasks are IO bound, i.e. there is no big computation, but rather you send data e.g. to a website and wait for a return - most your time is spent waiting.
$endgroup$
add a comment |
$begingroup$
I don't think Jupyter notebooks (even via extensions) currently offer pausing/restarting cell blocks. I would suggest putting the code of both cells into a single cell and using Python logic to determine the order of execution.
In general, however, you cannot strictly pause the execution of something and come back to it later. If you abort the execution of the function, the intermediate results are lost (because they are stored within the namespace of the function you effectively just killed). This is because Python only runs one single process at a time (key term: Global Interpreter Lock).
The only thing you might be able to do is create a cell 0, which performs some kind of check, testing how long cell 1 might take to run, then just put cell 1 and cell 2 in and if/else construction that gives the correct order to use.
Other approaches
You might want to look into something like the multiprocessing library. There you can create a group of worker processors, to which you can send the contents of cell 1 and at the same time the contents of cell 2. They will be computed at the same time, using two different processes i.e. two different instances of the Python interpreter. This can be easy to achieve if there is no direct dependency between (in your case) cell 1 and cell 2. Multiprocessing is particularly useful in the case that your long-running cell is compute bound, meaning is has to perform a large computation.
Yet another option would be to investigate the threading module and concurrent programming in general, but this get a little more complicated and is probably beyond what you want in your situation (it also requires more effort to get working that multiprocessing). This allows Python to kind of do two things at once, but with shared state - so each running thread can change variables that the other thread might also be changing, which can require a lot of work to make safe. This approach is however beneficial when you tasks are IO bound, i.e. there is no big computation, but rather you send data e.g. to a website and wait for a return - most your time is spent waiting.
$endgroup$
I don't think Jupyter notebooks (even via extensions) currently offer pausing/restarting cell blocks. I would suggest putting the code of both cells into a single cell and using Python logic to determine the order of execution.
In general, however, you cannot strictly pause the execution of something and come back to it later. If you abort the execution of the function, the intermediate results are lost (because they are stored within the namespace of the function you effectively just killed). This is because Python only runs one single process at a time (key term: Global Interpreter Lock).
The only thing you might be able to do is create a cell 0, which performs some kind of check, testing how long cell 1 might take to run, then just put cell 1 and cell 2 in and if/else construction that gives the correct order to use.
Other approaches
You might want to look into something like the multiprocessing library. There you can create a group of worker processors, to which you can send the contents of cell 1 and at the same time the contents of cell 2. They will be computed at the same time, using two different processes i.e. two different instances of the Python interpreter. This can be easy to achieve if there is no direct dependency between (in your case) cell 1 and cell 2. Multiprocessing is particularly useful in the case that your long-running cell is compute bound, meaning is has to perform a large computation.
Yet another option would be to investigate the threading module and concurrent programming in general, but this get a little more complicated and is probably beyond what you want in your situation (it also requires more effort to get working that multiprocessing). This allows Python to kind of do two things at once, but with shared state - so each running thread can change variables that the other thread might also be changing, which can require a lot of work to make safe. This approach is however beneficial when you tasks are IO bound, i.e. there is no big computation, but rather you send data e.g. to a website and wait for a return - most your time is spent waiting.
answered Feb 16 at 19:05
n1k31t4n1k31t4
6,3912319
6,3912319
add a comment |
add a comment |
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f45679%2fchange-priority-of-cell-execution-in-jupyter-notebook%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown