From 9d921fd04ce22b580703bd750826a61a732d1033 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 7 Apr 2020 09:34:07 +0200 Subject: [PATCH 1/4] use __name__ == "__main__" for the MPIPoolExecutor --- docs/source/tutorial/tutorial.parallelism.rst | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/source/tutorial/tutorial.parallelism.rst b/docs/source/tutorial/tutorial.parallelism.rst index 3a27b1734..235278db9 100644 --- a/docs/source/tutorial/tutorial.parallelism.rst +++ b/docs/source/tutorial/tutorial.parallelism.rst @@ -65,27 +65,29 @@ For example, you create the following file called ``run_learner.py``: from mpi4py.futures import MPIPoolExecutor - learner = adaptive.Learner1D(f, bounds=(-1, 1)) + if __name__ == "__main__": # ← use this, see warning @ https://bit.ly/2HAk0GG + + learner = adaptive.Learner1D(f, bounds=(-1, 1)) - # load the data - learner.load(fname) + # load the data + learner.load(fname) - # run until `goal` is reached with an `MPIPoolExecutor` - runner = adaptive.Runner( - learner, - executor=MPIPoolExecutor(), - shutdown_executor=True, - goal=lambda l: l.loss() < 0.01, - ) + # run until `goal` is reached with an `MPIPoolExecutor` + runner = adaptive.Runner( + learner, + executor=MPIPoolExecutor(), + shutdown_executor=True, + goal=lambda l: l.loss() < 0.01, + ) - # periodically save the data (in case the job dies) - runner.start_periodic_saving(dict(fname=fname), interval=600) + # periodically save the data (in case the job dies) + runner.start_periodic_saving(dict(fname=fname), interval=600) - # block until runner goal reached - runner.ioloop.run_until_complete(runner.task) + # block until runner goal reached + runner.ioloop.run_until_complete(runner.task) - # save one final time before exiting - learner.save(fname) + # save one final time before exiting + learner.save(fname) On your laptop/desktop you can run this script like: From 893154e99732d9640e2bf29a75ba9c3de877ab62 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 7 Apr 2020 09:38:05 +0200 Subject: [PATCH 2/4] bump vmImages --- azure-pipelines.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5ab1c4c37..5992b8e11 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,28 +12,28 @@ jobs: matrix: UbuntuPy36: python.version: '3.6' - vmImage: 'ubuntu-16.04' + vmImage: 'ubuntu-latest' tox_env: 'py36' UbuntuPy37: python.version: '3.7' - vmImage: 'ubuntu-16.04' + vmImage: 'ubuntu-latest' tox_env: 'py37' UbuntuPy38: python.version: '3.8' - vmImage: 'ubuntu-16.04' + vmImage: 'ubuntu-latest' tox_env: 'py38' macOSPy36: python.version: '3.6' - vmImage: 'macOS-10.13' + vmImage: 'macOS-latest' tox_env: 'py36' macOSPy37: python.version: '3.7' - vmImage: 'macOS-10.13' + vmImage: 'macOS-latest' tox_env: 'py37' macOSPy38: python.version: '3.8' - vmImage: 'macOS-10.13' + vmImage: 'macOS-latest' tox_env: 'py38' WindowsServerPy36: From 0912e069e84eee81076ec79fcf405183b0e5a248 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 7 Apr 2020 09:39:32 +0200 Subject: [PATCH 3/4] use full url to mpi4py docs --- docs/source/tutorial/tutorial.parallelism.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/tutorial/tutorial.parallelism.rst b/docs/source/tutorial/tutorial.parallelism.rst index 235278db9..9caa2d291 100644 --- a/docs/source/tutorial/tutorial.parallelism.rst +++ b/docs/source/tutorial/tutorial.parallelism.rst @@ -65,7 +65,7 @@ For example, you create the following file called ``run_learner.py``: from mpi4py.futures import MPIPoolExecutor - if __name__ == "__main__": # ← use this, see warning @ https://bit.ly/2HAk0GG + if __name__ == "__main__": # ← use this, see warning @ https://mpi4py.readthedocs.io/en/stable/mpi4py.futures.html#mpipoolexecutor learner = adaptive.Learner1D(f, bounds=(-1, 1)) From d2985fe76ac528b0c6accc4693467a78a6b8f51f Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 7 Apr 2020 09:54:08 +0200 Subject: [PATCH 4/4] split comment over two lines --- docs/source/tutorial/tutorial.parallelism.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/tutorial/tutorial.parallelism.rst b/docs/source/tutorial/tutorial.parallelism.rst index 9caa2d291..29dd09665 100644 --- a/docs/source/tutorial/tutorial.parallelism.rst +++ b/docs/source/tutorial/tutorial.parallelism.rst @@ -65,7 +65,9 @@ For example, you create the following file called ``run_learner.py``: from mpi4py.futures import MPIPoolExecutor - if __name__ == "__main__": # ← use this, see warning @ https://mpi4py.readthedocs.io/en/stable/mpi4py.futures.html#mpipoolexecutor + # use the idiom below, see the warning at + # https://mpi4py.readthedocs.io/en/stable/mpi4py.futures.html#mpipoolexecutor + if __name__ == "__main__": learner = adaptive.Learner1D(f, bounds=(-1, 1))