def update_rollout_dict(spec, rollout_dict):
 if should_skip_env_spec_for_tests(spec):
  logger.info(u'Skipping tests for {}'.format(spec.id))
  return False
 if spec.nondeterministic:
  logger.info(u'Skipping tests for nondeterministic env {}'.format(spec.id))
  return False
 logger.info(u'Generating rollout for {}'.format(spec.id))
 try:
  (observations_hash, actions_hash, rewards_hash, dones_hash) = generate_rollout_hash(spec)
 except:
  logger.warn(u'Exception {} thrown while generating rollout for {}. Rollout not added.'.format(sys.exc_info()[0], spec.id))
  return False
 rollout = {}
 rollout[u'observations'] = observations_hash
 rollout[u'actions'] = actions_hash
 rollout[u'rewards'] = rewards_hash
 rollout[u'dones'] = dones_hash
 existing = rollout_dict.get(spec.id)
 if existing:
  differs = False
  for (key, new_hash) in rollout.items():
   differs = (differs or (existing[key] != new_hash))
  if (not differs):
   logger.debug(u'Hashes match with existing for {}'.format(spec.id))
   return False
  else:
   logger.warn(u'Got new hash for {}. Overwriting.'.format(spec.id))
 rollout_dict[spec.id] = rollout
 return True

def update_rollout_dict ( spec , rollout_dict ) : if should_skip_env_spec_for_tests ( spec ) : logger . info ( u'Skipping tests for {}' . format ( spec . id ) ) return False if spec . nondeterministic : logger . info ( u'Skipping tests for nondeterministic env {}' . format ( spec . id ) ) return False logger . info ( u'Generating rollout for {}' . format ( spec . id ) ) try : ( observations_hash , actions_hash , rewards_hash , dones_hash ) = generate_rollout_hash ( spec ) except : logger . warn ( u'Exception {} thrown while generating rollout for {}. Rollout not added.' . format ( sys . exc_info ( ) [ 0 ] , spec . id ) ) return False rollout = { } rollout [ u'observations' ] = observations_hash rollout [ u'actions' ] = actions_hash rollout [ u'rewards' ] = rewards_hash rollout [ u'dones' ] = dones_hash existing = rollout_dict . get ( spec . id ) if existing : differs = False for ( key , new_hash ) in rollout . items ( ) : differs = ( differs or ( existing [ key ] != new_hash ) ) if ( not differs ) : logger . debug ( u'Hashes match with existing for {}' . format ( spec . id ) ) return False else : logger . warn ( u'Got new hash for {}. Overwriting.' . format ( spec . id ) ) rollout_dict [ spec . id ] = rollout return True
takes as input the environment spec for which the rollout is to be generated .