Using GangaExtension you can directly submit and monitor Ganga Jobs from Jupyter Notebook/SWAN.
The notebook and Job Script used for this tutorial can be found here.
To submit a Job open/create a Python2 Notebook. In this notebook, create a new cell and in the first line of this cell write
%%ganga to indicate this cell is an IPython Ganga Magic. From the next line simply define the Job in the same way it is defined in Ganga shell.
Note: Only a single Job can be defined per cell magic. If none or more than one Job is defined in single magic cell, an exception will be raised.
For Example: A Job definition with multiple subjobs can look like
After execution of this cell magic a new Job will be created.
Note: This Job is not being monitored in Notebook’s kernel, it is being monitored in a seperate Ganga session attached to Jupyter Session, so killing this notebook will not affect monitoring of submitted Ganga Job.
A widget will appear below the cell showing Job information and it will periodically update the status of Job.
Note: Since Job is being monitored in seperate session, there may be some lag between the actual status of Job and the status visible in following widget.
Also, a new entry corresponding to submitted Job will appear in Ganga Jobs tab. Since the Job is being monitored in Jupyter’s server session, this entry will display live status of submitted Job.
Note: The submitted Job can be killed and removed from this Ganga Jobs Tab.
The Job directory location can be identified by
outputdir property of job object:
The output files of Job can be identified by
outputfiles property of job object:
In this example, the content of outputfile
islands.txt of Job is:
On restarting Notebook or in another notebook, The Job object can be obtained by Ganga Repository object
Since, the Ganga Namespace is directly imported in Notebook’s Python namespace, user is advised to not define variables/methods with following names to prevent overwriting of Ganga Namespace variables/methods.