<s> import time <EOL> import json <EOL> from datetime import datetime , timedelta <EOL> from world import world <EOL> from bigml . api import HTTP_CREATED <EOL> from bigml . api import FINISHED <EOL> from bigml . api import FAULTY <EOL> from bigml . api import get_status <EOL> from read_evaluation_steps import i_get_the_evaluation <EOL> def i_create_an_evaluation ( step ) : <EOL> dataset = world . dataset . get ( '<STR_LIT>' ) <EOL> model = world . model . get ( '<STR_LIT>' ) <EOL> resource = world . api . create_evaluation ( model , dataset ) <EOL> world . status = resource [ '<STR_LIT:code>' ] <EOL> assert world . status == HTTP_CREATED <EOL> world . location = resource [ '<STR_LIT:location>' ] <EOL> world . evaluation = resource [ '<STR_LIT:object>' ] <EOL> world . evaluations . append ( resource [ '<STR_LIT>' ] ) <EOL> def i_create_an_evaluation_ensemble ( step ) : <EOL> dataset = world . dataset . get ( '<STR_LIT>' ) <EOL> ensemble = world . ensemble . get ( '<STR_LIT>' ) <EOL> resource = world . api . create_evaluation ( ensemble , dataset ) <EOL> world . status = resource [ '<STR_LIT:code>' ] <EOL> assert world . status == HTTP_CREATED <EOL> world . location = resource [ '<STR_LIT:location>' ] <EOL> world . evaluation = resource [ '<STR_LIT:object>' ] <EOL> world . evaluations . append ( resource [ '<STR_LIT>' ] ) <EOL> def wait_until_evaluation_status_code_is ( step , code1 , code2 , secs ) : <EOL> start = datetime . utcnow ( ) <EOL> i_get_the_evaluation ( step , world . evaluation [ '<STR_LIT>' ] ) <EOL> status = get_status ( world . evaluation ) <EOL> while ( status [ '<STR_LIT:code>' ] != int ( code1 ) and <EOL> status [ '<STR_LIT:code>' ] != int ( code2 ) ) : <EOL> time . sleep ( <NUM_LIT:3> ) <EOL> assert datetime . utcnow ( ) - start < timedelta ( seconds = int ( secs ) ) <EOL> i_get_the_evaluation ( step , world . evaluation [ '<STR_LIT>' ] ) <EOL> status = get_status ( world . evaluation ) <EOL> assert status [ '<STR_LIT:code>' ] == int ( code1 ) <EOL> def the_evaluation_is_finished_in_less_than ( step , secs ) : <EOL> wait_until_evaluation_status_code_is ( step , FINISHED , FAULTY , secs ) <EOL> def the_measured_measure_is_value ( step , measure , value ) : <EOL> ev = world . evaluation [ '<STR_LIT:result>' ] [ '<STR_LIT>' ] [ measure ] + <NUM_LIT:0.0> <EOL> assert ev == float ( value ) , "<STR_LIT>" % ( <EOL> measure , ev , float ( value ) ) <EOL> def the_measured_measure_is_greater_value ( step , measure , value ) : <EOL> assert world . evaluation [ '<STR_LIT:result>' ] [ '<STR_LIT>' ] [ measure ] + <NUM_LIT:0.0> > float ( value ) </s>
