Functions¶
Function to be used to clean up erronious empty folders in the Shared directory
-
diracAPI
(cmd, timeout=60, cred_req=None)¶ - Args:
- cmd (str): This is the command you want to execute from within an active DIRAC session timeout (int): This is the maximum time(sec) the session has to complete the task cred_req (ICredentialRequirement): This is the (optional) credential passed to construct the correct DIRAC env
Execute DIRAC API commands from w/in GangaCore.
The stdout will be returned, e.g.:
# this will simply return 87 diracAPI(‘print 87’)
# this will return the status of job 66 # note a Dirac() object is already provided set up as ‘dirac’ diracAPI(‘print(Dirac().getJobStatus([66]))’) diracAPI(‘print(dirac.getJobStatus([66]))’)
# or can achieve the same using command defined and included from # getConfig(‘DIRAC’)[‘DiracCommandFiles’] diracAPI(‘status([66])’)
-
startDiracProcess
()¶ Start a subprocess that runs the DIRAC commands
-
stopDiracProcess
()¶ Stop the Dirac process if it is running
-
diracAPI_interactive
(connection_attempts=5)¶ Run an interactive server within the DIRAC environment.
-
diracAPI_async
(cmd, timeout=120)¶ Execute DIRAC API commands from w/in GangaCore.
-
getDiracFiles
()¶
-
dumpObject
(object, filename)¶ These are complimentary functions to export/load which are already exported to the GPI from GangaCore.GPIDev.Persistency. The difference being that these functions will export the objects using the pickle persistency format rather than a Ganga streaming (human readable) format.
-
loadObject
(filename)¶ These are complimentary functions to export/load which are already exported to the GPI from GangaCore.GPIDev.Persistency. The difference being that these functions will export the objects using the pickle persistency format rather than a Ganga streaming (human readable) format.
-
license
()¶ Print the full license (GPL)
-
runfile
(path_to_file)¶ A wrapper for the runpy.run_path() function. Usage: Ganga In[]: runfile(‘myfile.py’) Note: If you want to run a file which includes something like:
j = Job() j.submit()
then you have to run the function with init_globals=globals() in the Ganga interpreter like this
Ganga In[]: runfile(‘myfile.py’)
-
typename
(obj)¶ Return a name of Ganga object as a string, example: typename(j.application) -> ‘DaVinci’
-
categoryname
(obj)¶ Return a category of Ganga object as a string, example: categoryname(j.application) -> ‘applications’
-
plugins
(category=None)¶ List loaded plugins.
If no argument is given return a dictionary of all loaded plugins. Keys are category name. Values are lists of plugin names in each category.
If a category is specified (for example ‘splitters’) return a list of all plugin names in this category.
-
convert_merger_to_postprocessor
(j)¶
-
load
(filename='', returnList=True)¶ Function to load previously exported Ganga objects
- Arguments:
- filename - String [default ‘’] giving path to a file containing
definitions of Ganga objects, such as produced with the ‘export’ function => The path can be absolute, relative, or relative
to a directory in the search path LOAD_SCRIPTS, defined in [Configuration] section of Ganga configuration- returnList - Switch [default True] defining the return type:
=> True : List of loaded objects is returned => False : None returned - job and template objects
stored in job repository
- Return value: List of Ganga objects or None, as determined by value
- of argument returnList
-
export
(item=None, filename='', mode='w')¶
-
full_print
(obj, out=None, interactive=False)¶ Print the full contents of a GPI object without abbreviation.
-
report
(job=None, filetype=<class 'GangaCore.GPIDev.Lib.File.GoogleFile.GoogleFile'>)¶ Upload error reports (snapshot of configuration,job parameters, input/output files, command history etc.). Job argument is optional. Reports can be provided as the file type indicated by filetype argument which defaults to GoogleFile
- example of particular job details submission to GoogleDrive:
- j = Job() # a job defined, which results in an error report(job=j, filetype=GoogleFile) # filetype can take other arguments like LocalFile, DiracFile
example of standalone submission:
report()
-
reactivate
()¶ activates the internal services previously disabled due to expired credentials
-
disableMonitoring
()¶
-
enableMonitoring
()¶
-
disableServices
()¶ - Deactivates all the internal services :
- monitoring loop
- registry/repository and workspace (or GPI entierly)
- Currently this method is called whenever:
- one of the managed credentials (AFS token or Grid Proxy) is detected as beeing invalid by the monitoring component
- the user is running out of space
-
jobSlice
(joblist)¶ create a ‘JobSlice’ from a list of jobs example: jobSlice([j for j in jobs if j.name.startswith(“T1:”)])
-
runMonitoring
(self, jobs=None, steps=1, timeout=300)¶ Enable/Run the monitoring loop and wait for the monitoring steps completion. Parameters:
steps: number of monitoring steps to run timeout: how long to wait for monitor steps termination (seconds) jobs: a registry slice to be monitored (None -> all jobs), it may be passed by the user so ._impl is stripped if needed- Return:
- False, if the loop cannot be started or the timeout occured while waiting for monitoring termination True, if the monitoring steps were successfully executed
- Note:
- This method is meant to be used in Ganga scripts to request monitoring on demand.