mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 02:07:52 +00:00 
			
		
		
		
	sim script UX improvements
This commit is contained in:
		
							parent
							
								
									6f1cdeb336
								
							
						
					
					
						commit
						5befb6a954
					
				@ -7,24 +7,27 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Parse Input Args
 | 
			
		||||
# get simulation type
 | 
			
		||||
simType=$1
 | 
			
		||||
# get seed
 | 
			
		||||
startingSeed=$1
 | 
			
		||||
startingSeed=$2
 | 
			
		||||
# compute the seed from the starting and the job index
 | 
			
		||||
# add two nums together, hence the $(()), and use 0 as the default value for array index, hence the ${:-} syntax
 | 
			
		||||
seed=$(($startingSeed+${AWS_BATCH_JOB_ARRAY_INDEX:-0}))
 | 
			
		||||
echo "seed: " $seed
 | 
			
		||||
# get sim parameters
 | 
			
		||||
numBlocks=$2
 | 
			
		||||
blockSize=$3
 | 
			
		||||
numBlocks=$3
 | 
			
		||||
blockSize=$4
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Run The Sim
 | 
			
		||||
# redirect stdout and stderr to a file
 | 
			
		||||
go test ./app -run TestFullAppSimulation -Enabled=true -NumBlocks=$numBlocks -BlockSize=$blockSize -Commit=true -Period=5 -Seed=$seed -v -timeout 24h > out.log 2>&1
 | 
			
		||||
# record cli arguments in the log file (in json in case we need to parse this) and stdout (https://stackoverflow.com/questions/418896/how-to-redirect-output-to-a-file-and-stdout)
 | 
			
		||||
printf "{\"simType\": \"%s\", \"startingSeed\": %s, \"seed\": %s, \"numBlocks\": %s, \"blockSize\": %s}\n" $simType $startingSeed $seed $numBlocks $blockSize | tee out.log
 | 
			
		||||
# run sim and redirect stdout and stderr to a file)
 | 
			
		||||
go test ./app -run $simType -Enabled=true -NumBlocks=$numBlocks -BlockSize=$blockSize -Commit=true -Period=5 -Seed=$seed -v -timeout 24h >> out.log 2>&1
 | 
			
		||||
# get the exit code to determine how to upload results
 | 
			
		||||
simExitStatus=$?
 | 
			
		||||
if [ $simExitStatus -eq 0 ];then
 | 
			
		||||
   echo "simulations passed"
 | 
			
		||||
   echo "simulation passed"
 | 
			
		||||
   simResult="pass"
 | 
			
		||||
else
 | 
			
		||||
   echo "simulation failed"
 | 
			
		||||
@ -39,5 +42,5 @@ jobID=${AWS_BATCH_JOB_ID:-"testJobID:"}
 | 
			
		||||
jobID=$(echo $jobID | sed 's/\(.*\):\d*/\1/')
 | 
			
		||||
 | 
			
		||||
# create the filename from the array job index (which won't be set if this is a normal job)
 | 
			
		||||
fileName=out$AWS_BATCH_JOB_ARRAY_INDEX.log
 | 
			
		||||
fileName=$(printf "out%05d.log" $AWS_BATCH_JOB_ARRAY_INDEX)
 | 
			
		||||
aws s3 cp out.log s3://simulations-1/$jobID/$simResult/$fileName
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user