Integration with Jupyter notebook
PyCOMPSs can also be used within Jupyter notebooks. This feature allows users to develop and run their PyCOMPSs applications in a Jupyter notebook, where it is possible to modify the code during the execution and experience an interactive behaviour.
Environment Variables
The following libraries must be present in the appropiate environment variables in order to enable PyCOMPSs within Jupyter notebook:
- PYTHONPATH
The path where PyCOMPSs is installed (e.g.
/opt/COMPSs/Bindings/python/
). Please, note that the path contains the folder2
and/or3
. This is due to the fact that PyCOMPSs is able to choose the appropiate one depending on the kernel used with jupyter.- LD_LIBRARY_PATH
The path where the
libbindings-commons.so
library is located (e.g.<COMPSS_INSTALLATION_PATH>/Bindings/bindings-common/lib/
) and the path where thelibjvm.so
library is located (e.g./usr/lib/jvm/java-8-openjdk/jre/lib/amd64/server/
).
API calls
In this case, the user is responsible of starting and stopping the
COMPSs runtime during the jupyter notebook execution.
To this end, PyCOMPSs provides a module with two main API calls:
one for starting the COMPSs runtime, and another for stopping it.
This module can be imported from the pycompss library:
import pycompss.interactive as ipycompss
And contains two main functions: start and stop. These functions can then be invoked as follows for the COMPSs runtime deployment with default parameters:
# Previous user code/cells
import pycompss.interactive as ipycompss
ipycompss.start()
# User code/cells that can benefit from PyCOMPSs
ipycompss.stop()
# Subsequent code/cells
Between the start and stop function calls, the user can write its own python code including PyCOMPSs imports, decorators and synchronization calls described in the Programming Model Section. The code can be splitted into multiple cells.
The start and stop functions accept parameters in order to customize
the COMPSs runtime (such as the flags that can be selected with the
runcompss
command). Table 12 summarizes
the accepted parameters of the start function. Table 13
summarizes the accepted parameters of
the stop function.
Parameter Name |
Parameter Type |
Description |
---|---|---|
log_level |
String |
Log level |
debug |
Boolean |
COMPSs runtime debug |
o_c |
Boolean |
Object conversion to string when possible |
graph |
Boolean |
Task dependency graph generation |
trace |
Boolean |
Paraver trace generation |
monitor |
Integer |
Monitor refresh rate |
project_xml |
String |
Path to the project XML file |
resources_xml |
String |
Path to the resources XML file |
summary |
Boolean |
Show summary at the end of the execution |
storage_impl |
String |
Path to an storage implementation |
storage_conf |
String |
Storage configuration file path |
task_count |
Integer |
Number of task definitions |
app_name |
String |
Application name |
uuid |
String |
Application uuid |
base_log_dir |
String |
Base directory to store COMPSs log files (a .COMPSs/ folder will be created inside this location)|pyjbr| (Default: User homeBase log path) |
specific_log_dir |
String |
Use a specific directory to store COMPSs log files (the folder MUST exist and no sandbox is created) |
extrae_cfg |
String |
Sets a custom extrae config file. Must be in a shared disk between all COMPSs workers |
comm |
String |
Class that implements the adaptor for communications. Supported adaptors: |
conn |
String |
Class that implements the runtime connector for the cloud. Supported connectors: |
master_name |
String |
Hostname of the node to run the COMPSs master |
master_port |
String |
Port to run the COMPSs master communications (Only for NIO adaptor) |
scheduler |
String |
Class that implements the Scheduler for COMPSs. Supported schedulers: |
jvm_workers |
String |
Extra options for the COMPSs Workers JVMs. Each option separed by “,” and without blank spaces |
cpu_affinity |
String |
Sets the CPU affinity for the workers. |
gpu_affinity |
String |
Sets the GPU affinity for the workers. |
profile_input |
String |
Path to the file which stores the input application profile |
profile_output |
String |
Path to the file to store the application profile at the end of the execution |
scheduler_config |
String |
Path to the file which contains the scheduler configuration |
external_adaptation |
Boolean |
Enable external adaptation (this option will disable the Resource Optimizer) |
propatage_virtual_environment |
Boolean |
Propagate the master virtual environment to the workers |
verbose |
Boolean |
Verbose mode |
Parameter Name |
Parameter Type |
Description |
---|---|---|
sync |
Boolean |
Synchronize the objects left on the user scope. |
The following code snippet shows how to start a COMPSs runtime with tracing and graph generation enabled (with trace and graph parameters), as well as enabling the monitor with a refresh rate of 2 seconds (with the monitor parameter). It also synchronizes all remaining objects in the scope with the sync parameter when invoking the stop function.
# Previous user code
import pycompss.interactive as ipycompss
ipycompss.start(graph=True, trace=True, monitor=2000)
# User code that can benefit from PyCOMPSs
ipycompss.stop(sync=True)
# Subsequent code
Attention
Once the COMPSs runtime has been stopped it, the value of the variables that have not been synchronized will be lost.
Notebook execution
The application can be executed as a common Jupyter notebook by steps or the whole application.
Important
A message showing the failed task/s will pop up if an exception within them happens.
This pop up message will also allow you to continue the execution without PyCOMPSs, or to restart the COMPSs runtime. Please, note that in the case of COMPSs restart, the tracking of some objects may be lost (will need to be recomputed).
More information on the Notebook execution can be found in the Execution Environments Jupyter Notebook Section.
Notebook example
Sample notebooks can be found in the PyCOMPSs Notebooks Section.