SCRIPTS FILES local_vs_remoteΒΆ

# -*-Python-*-
# Created by bgrierson at 21 Aug 2017  16:55

"""
This script demonstrates the use of OMFITx.executable and OMFITx.remote_downsync
There are two file systems that OMFIT uses.
First there is the computer that OMFIT is running on, which is the local system.
Second there is the computer that OMFIT has access to for running codes, which is remote.
They can be the same physical computer, but OMFIT handles these two locations conceptually
differently in the way it uses temporary and scratch directories.

"""

# Define some commands that creates some output, i.e. run EFIT or GYRO
myCode = '''
#!/bin/bash
echo 'Hello world!' > hello.txt
exit 0
'''

# Place that code in a shell script
myScript = OMFITascii('myScript.sh', fromString=myCode)

# Define the commands to execute that script
executable = '''
chmod +x ./myScript.sh; ./myScript.sh
'''

# Now OMFIT will use the information in root['SETTINGS']['SETUP'] and root['SETTINGS']['REMOTE_SETUP']
# OMFIT will place the data on the local disk in the local working directory here:
#    root['SETTINGS']['SETUP']['workDir']
# Then scp the data to the remote computer and place the data in a directory here:
#    root['SETTINGS']['REMOTE_SETUP']['workDir']
# Then run the code, and scp the outputs back to the local working directory.
# Depending on hwat youy have for MainSettings['SERVER']['default'] this may run on any variaty of places.
printi('Running OMFITx.executable')
printi('Local workDir {}'.format(evalExpr(root['SETTINGS']['SETUP']['workDir'])))
printi('Remote workDir {}'.format(evalExpr(root['SETTINGS']['REMOTE_SETUP']['workDir'])))

OMFITx.executable(root, inputs=[myScript], outputs=['hello.txt'], executable=executable, clean=True)

root['OUTPUTS'].setdefault('FILES', OMFITtree())
root['OUTPUTS']['FILES']['hello'] = OMFITascii('./hello.txt')