<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 YARN on Stampede
This is an advanced example intended to show the capabilities. To execute this example a Stampede account is required.
1. Setting up the enviroment
Before running the following example you will need to set a passwordless ssh connection between your tutorial account and your account on TACC Stampede.
First, login through ssh to the edge node with the tutorial account and set up a public key
Step1:  3. Create a Radical Pilot Session
Step2:  4. Create Pilot and Unit Managers
Step3:  5. Submit the pilot to the Pilot and Unit Managers
Step4:  6. Submit Compute Units
First create the description of the compute units which define the task to be executed
Step5:  Submit the created Compute Units to the Unit Manager.
Step6:  Printing the output of a Compute Unit
Step7:  7. Always clean up the session
<ASSISTANT_TASK:>
Python Code:
import os,sys
import radical.pilot as rp
import ast
os.environ["RADICAL_PILOT_DBURL"]="mongodb://ec2-54-221-194-147.compute-1.amazonaws.com:24242/sc15tut"
os.environ["RADICAL_PILOT_VERBOSE"]="DEBUG"
def print_details(detail_object):
    if type(detail_object)==str:
        detail_object = ast.literal_eval(detail_object)
    for i in detail_object:
        detail_object[i]=str(detail_object[i])
    return pd.DataFrame(detail_object.values(), 
             index=detail_object.keys(), 
             columns=["Value"])
Explanation: YARN on Stampede
This is an advanced example intended to show the capabilities. To execute this example a Stampede account is required.
1. Setting up the enviroment
Before running the following example you will need to set a passwordless ssh connection between your tutorial account and your account on TACC Stampede.
First, login through ssh to the edge node with the tutorial account and set up a public key:
ssh &lt;user&gt;@sc15-aws.radical-cybertools.org
ssh-keygen -t rsa
Hit Return until you are in the terminal command prompt again.
Then execute the following command
cat .ssh/id_rsa.pub | ssh &lt;tacc_username&gt;@stampede.tacc.utexas.edu 'cat &gt;&gt; .ssh/authorized_keys'
Verify that everything is set by doing and you can connect without a password request:
ssh &lt;tacc_username&gt;@stampede.tacc.utexas.edu
2. Radical Pilot Setup
End of explanation
session = rp.Session()
print "Session id %s"%session.uid
c = rp.Context('ssh')
c.user_id = ""
session.add_context(c)
Explanation: 3. Create a Radical Pilot Session
End of explanation
print "Initializing Pilot Manager ..."
pmgr = rp.PilotManager(session=session)
print "Initializing Unit Manager ..."
umgr = rp.UnitManager (session=session,
                           scheduler=rp.SCHED_DIRECT_SUBMISSION)
Explanation: 4. Create Pilot and Unit Managers
End of explanation
pdesc = rp.ComputePilotDescription ()
pdesc.resource = "yarn.stampede"  # NOTE: This is a "label", not a hostname
pdesc.runtime  = 60 # minutes
pdesc.cores    = 16
pdesc.cleanup  = False
pdesc.project  = '' #Include the Allocation here
pdesc.queue    = 'development' #You can select a different queue if you want.
# submit the pilot.
print "Submitting Compute Pilot to Pilot Manager ..."
pilot = pmgr.submit_pilots(pdesc)
print "Registering Compute Pilot with Unit Manager ..."
umgr.add_pilots(pilot)
Explanation: 5. Submit the pilot to the Pilot and Unit Managers
End of explanation
NUMBER_JOBS  = 16
cudesc_list = []
for i in range(NUMBER_JOBS):
    cudesc = rp.ComputeUnitDescription()
    cudesc.environment = {'CU_NO': i}
    cudesc.executable  = "/bin/echo"
    cudesc.arguments   = ['I am CU number $CU_NO']
    cudesc.cores       = 1
    cudesc_list.append(cudesc)
Explanation: 6. Submit Compute Units
First create the description of the compute units which define the task to be executed
End of explanation
print "Submit Compute Units to Unit Manager ..."
cu_set = umgr.submit_units (cudesc_list)
print "Waiting for CUs to complete ..."
umgr.wait_units()
print "All CUs completed successfully!"
Explanation: Submit the created Compute Units to the Unit Manager.
End of explanation
for unit in cu_set:
    print "* CU %s, state %s, exit code: %s, stdout: %s" \
     % (unit.uid, unit.state, unit.exit_code, unit.stdout)
Explanation: Printing the output of a Compute Unit
End of explanation
session.close ()
del session
Explanation: 7. Always clean up the session
End of explanation
<END_TASK>