.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/example_run_remote_function.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_example_run_remote_function.py: Call by function ================ .. GENERATED FROM PYTHON SOURCE LINES 5-15 .. code-block:: Python from pathlib import Path from remote_run.run import ( ExecutionContext, GuixRunner, GitProject, run_remote, SshExecution, ) .. GENERATED FROM PYTHON SOURCE LINES 16-17 Define an execution context .. GENERATED FROM PYTHON SOURCE LINES 17-27 .. code-block:: Python execution_context = ExecutionContext( execution=SshExecution( machine="shpc0003.ost.ch", working_directory=Path("/cluster/raid/home/reza.housseini"), ), project=GitProject(), runner=GuixRunner(channels=Path("channels.scm").read_text()), ) .. GENERATED FROM PYTHON SOURCE LINES 28-29 undecorated function we want to run in the specified execution context .. GENERATED FROM PYTHON SOURCE LINES 29-33 .. code-block:: Python def add(a, b): return a + b .. GENERATED FROM PYTHON SOURCE LINES 34-35 run on the remote machine specified in execution_context using the function call .. GENERATED FROM PYTHON SOURCE LINES 35-36 .. code-block:: Python assert run_remote(lambda: add(1, 2), execution_context=execution_context) == 3 .. _sphx_glr_download_auto_examples_example_run_remote_function.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_run_remote_function.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_run_remote_function.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_run_remote_function.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_