Skip to content

Instantly share code, notes, and snippets.

@andre-merzky
Created April 30, 2017 07:49
Show Gist options
  • Save andre-merzky/8aeed7c5e1ea3ae0042a2e2a705ea6de to your computer and use it in GitHub Desktop.
Save andre-merzky/8aeed7c5e1ea3ae0042a2e2a705ea6de to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
import sys
from pprint import pprint
import radical.utils as ru
import radical.pilot as rp
WALLTIME = 60 # In minutes
CORES = 20
cus_per_pilot = 10
resources = ['local.localhost', 'local.localhost', 'local.localhost']
data = list()
try:
session = rp.Session()
pmgr = rp.PilotManager(session)
umgr = rp.UnitManager(session)
puds = list()
cuds = list()
for res in resources:
print "Initializing %s" % res
pd_init = { 'resource' : res,
'cores' : 2,
'runtime' : WALLTIME}
puds.append(rp.ComputePilotDescription(pd_init))
pilots = pmgr.submit_pilots(puds)
umgr.add_pilots(pilots)
pmgr.wait_pilots(state=rp.PMGR_ACTIVE)
print "Creating and submitting CUs"
for pilot in pilots:
for i in range(cus_per_pilot):
cud = rp.ComputeUnitDescription()
cud.executable = '/bin/date'
cud.pilot = pilot.uid
cuds.append(cud)
units = umgr.submit_units(cuds)
print "Waiting for units to finish\n"
umgr.wait_units()
for unit in units:
print '%s: %-10s : %s' % (unit.uid, unit.state, unit.pilot)
except Exception as e:
print 'exception: %s' % e
finally:
session.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment