Skip to content

Commit

Permalink
more update
Browse files Browse the repository at this point in the history
  • Loading branch information
avatar-lavventura committed Apr 29, 2018
1 parent 027d3fd commit 5f941c8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,5 @@ docs/convert/get-pip\.py
eBlocBroker/

dd\.txt

dd\.py
44 changes: 32 additions & 12 deletions Driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
os.environ['eblocPath'] = constants.EBLOCPATH;
os.environ['contractCallPath'] = contractCallPath;
os.environ['logPath'] = constants.LOG_PATH;
totalCore = os.popen('sinfo | awk \'{print $4}\' | tail -n +2').read().rstrip('\n');
# ======================================================================

#rows, columns = os.popen('stty size', 'r').read().split();
Expand All @@ -31,6 +32,27 @@ def log(strIn, color=''): #{
txFile.close();
#}

def slurmPendingJobCheck(): #{
global totalCore;
printFlag = 0;
usedCoreNum = os.popen('squeue | grep -P \' R \' | awk \'{print $7}\' | paste -sd+ - | bc').read().rstrip('\n');

if usedCoreNum == '':
usedCoreNum = 0;

# log('There is ' + usedCoreNum + ' used core out of ' + totalCore + '.', 'green');
while True: #{
if int(totalCore) - int(usedCoreNum) > 0:
log('There is ' + usedCoreNum + ' used core out of ' + totalCore + '.', 'green')
break;
if printFlag == 0:
log('Waiting running jobs to be completed.', 'blue')
printFlag = 1;
time.sleep(10);
usedCoreNum = os.popen('squeue | grep -P \' R \' | awk \'{print $7}\' | paste -sd+ - | bc').read().rstrip('\n');
#}
#}

# checks: does Geth runs on the background
def isGethOn(): #{
check = os.popen("ps aux | grep [g]eth | grep " + str(constants.RPC_PORT) + "| wc -l").read().rstrip('\n');
Expand All @@ -42,14 +64,15 @@ def isGethOn(): #{

# checks: does Driver.py runs on the background
def isDriverOn():
check = os.popen("ps aux | grep \'[D]river.py\' | wc -l").read().rstrip('\n');
check = os.popen("ps aux | grep \'[D]river.py\' | grep \'python\' | wc -l").read().rstrip('\n');

if int(check) > 1:
log("Driver is already running.", 'green');
sys.exit();

# checks: does Slurm runs on the background or not
def isSlurmOn(): #{

os.system("bash checkSinfo.sh")
check = os.popen("cat $logPath/checkSinfoOut.txt").read();

Expand All @@ -64,6 +87,9 @@ def isSlurmOn(): #{
log("sudo munged -f")
log("/etc/init.d/munge start")
sys.exit()

global totalCore;
totalCore = os.popen('sinfo | awk \'{print $4}\' | tail -n +2 | paste -sd+ - | bc').read().rstrip('\n');
#}

yes = set(['yes', 'y', 'ye']);
Expand All @@ -76,15 +102,14 @@ def isSlurmOn(): #{
isDriverOn();
isSlurmOn();
isGethOn();

print('isWeb3Connected: ' + os.popen('$contractCallPath/isWeb3Connected.py').read().rstrip('\n'))

isContractExist = os.popen('$contractCallPath/isContractExist.py').read().rstrip('\n');
if 'False' in isContractExist:
log('Please check that you are using eBloc blockchain.', 'red');
sys.exit();

log('=' * int(int(columns) / 2 - 12) + ' cluster session starts ' + '=' * int(int(columns) / 2 - 12), "green");
log('isWeb3Connected: ' + os.popen('$contractCallPath/isWeb3Connected.py').read().rstrip('\n'))
log('rootdir: ' + os.getcwd());

if constants.IPFS_USE == 1:
Expand Down Expand Up @@ -195,6 +220,7 @@ def isSlurmOn(): #{
passedPrintFlag = 0;
os.environ['blockReadFrom'] = str(blockReadFrom) # Starting reading event's location has been updated

slurmPendingJobCheck()

constants.contractCall('eBlocBroker.LogJob($blockReadFrom, \'$jobsReadFromPath\')'); # Waits here until new job submitted into the cluster
print('isWeb3Connected: ' + os.popen('$contractCallPath/isWeb3Connected.py').read().rstrip('\n'))
Expand All @@ -205,14 +231,7 @@ def isSlurmOn(): #{
submittedJobs.add(line)

submittedJobs= sorted(submittedJobs);

# fR = open(jobsReadFromPath, 'r')
# blockReadFrom = fR.read().rstrip('\n');
# fR.close();
# submittedJobs = blockReadFrom.split('?');




maxVal = 0;
isClusterReceivedJob = 0;
submittedJob = 0;
Expand Down Expand Up @@ -266,7 +285,8 @@ def isSlurmOn(): #{
if 'False' in strCheck:
log('Filename contains invalid character', 'red');
runFlag = 1;


slurmPendingJobCheck()
# Checks isAlreadyCaptured job or not. If it is completed job do not obtain it
if runFlag == 1:
pass;
Expand Down
4 changes: 2 additions & 2 deletions driverFunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def driverEudatCall(jobKey, index, fID): #{

os.popen("wget https://b2drop.eudat.eu/s/$shareToken/download --output-document=$resultsFolderPrev/output.zip").read() # Downloads shared file as .zip, much faster.

os.system("unzip -j $resultsFolderPrev/output.zip -d $resultsFolder");
os.system("unzip -jo $resultsFolderPrev/output.zip -d $resultsFolder");
os.system("rm -f $resultsFolderPrev/output.zip");

isTarExist = os.popen("ls -1 $resultsFolder/*.tar.gz 2>/dev/null | wc -l").read();
Expand All @@ -249,7 +249,7 @@ def driverEudatCall(jobKey, index, fID): #{
isZipExist = os.popen("ls -1 $resultsFolder/*.zip 2>/dev/null | wc -l").read();
if int(isTarExist) > 0:
log(os.popen("" ).read());
os.popen("unzip -j $resultsFolderPrev/$jobKey -d $resultsFolder").read();
os.popen("unzip -jo $resultsFolderPrev/$jobKey -d $resultsFolder").read();
os.popen("rm -f $resultsFolder/*.zip").read();

os.chdir(resultsFolder); # 'cd' into the working path and call sbatch from there
Expand Down
2 changes: 1 addition & 1 deletion tar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

for a in $1/*.tar.gz; do
if [[ "$a" != $1/result-* ]] ; then
tar -xf "$a" -C $1;
tar -xvf "$a" -C $1;
fi
done;

0 comments on commit 5f941c8

Please sign in to comment.