create an in-memory state repository for our feature
977163
@Setup(Level.Trial)
    public void setupFeatureManager() {
        FeatureManager featureManager = new FeatureManagerBuilder()
                .featureEnums(ScriptEngineActivationStrategyFeatures.class)
                .stateRepository(new InMemoryStateRepository())
                .userProvider(new NoOpUserProvider())
                .build();
        // set up the toggle activation state
        StaticFeatureManagerProvider.setFeatureManager(featureManager);
        manager = featureManager;

        FeatureState alwaysTrueScriptEngineFeatureState = new FeatureState(ScriptEngineActivationStrategyFeatures.ALWAYS_TRUE_SCRIPT_ENGINE_ACTIVATION_STRATEGY);
        alwaysTrueScriptEngineFeatureState.setEnabled(true);
        alwaysTrueScriptEngineFeatureState.setStrategyId(ScriptEngineActivationStrategy.ID);
        alwaysTrueScriptEngineFeatureState.setParameter(ScriptEngineActivationStrategy.PARAM_LANG, "nashorn");
        alwaysTrueScriptEngineFeatureState.setParameter(ScriptEngineActivationStrategy.PARAM_SCRIPT, "true");

        FeatureState dynamicScriptEngineState = new FeatureState(ScriptEngineActivationStrategyFeatures.DYNAMIC_SCRIPT_ENGINE_STRATEGY);
        dynamicScriptEngineState.setEnabled(true);
        dynamicScriptEngineState.setStrategyId(ScriptEngineActivationStrategy.ID);
        dynamicScriptEngineState.setParameter(ScriptEngineActivationStrategy.PARAM_LANG, "nashorn");
        dynamicScriptEngineState.setParameter(ScriptEngineActivationStrategy.PARAM_SCRIPT, "Math.random() < Math.pow(1 - (27 - date.getDate()) * 0.2, 3)");


        manager.setFeatureState(alwaysTrueScriptEngineFeatureState);
        manager.setFeatureState(dynamicScriptEngineState);
    }
1312765
private void createImpl()
  {
    _systemSegment = allocateSegment(new byte[32], 1);
    
    _segmentList.add(_systemSegment);
    
    TempBuffer tBuf = TempBuffer.createLarge();
    byte []buffer = tBuf.buffer();
    
    Arrays.fill(buffer, (byte) 0);
    
    int offset = 0;
    
    BitsUtil.writeLong(buffer, offset, JOURNAL_MAGIC);
    offset += 8;
    
    BitsUtil.writeLong(buffer, offset, _segmentSize);
    offset += 8;
    
    BitsUtil.writeLong(buffer, offset, _tailAddress);
    offset += 8;
    
    BitsUtil.writeInt(buffer, offset, KEY_LENGTH);
    offset += 4;
    
    try (OutStore os = _store.openWrite(0, buffer.length)) {
      os.write(0, buffer, 0, buffer.length);
    }
    
    tBuf.free();
  }
902629
def commit(self, unit_of_work):
        
        MemoryRepository.commit(self, unit_of_work)
        if self.is_initialized:
            entity_classes_to_dump = set()
            for state in unit_of_work.iterator():
                entity_classes_to_dump.add(type(state.entity))
            for entity_cls in entity_classes_to_dump:
                self.__dump_entities(entity_cls)
1348009
def snapshot(self, mode):
        '''
        
        '''
        self._init_env()

        self._save_cfg_packages(self._get_changed_cfg_pkgs(self._get_cfg_pkgs()))
        self._save_payload(*self._scan_payload())
1335551
def in_memory(self, op_in_mem):
        
        """
        old_state = self.in_memory
        if not old_state and op_in_mem:
            self._map_to_memory()
        elif not op_in_mem and old_state:
            self._clear_in_memory()
545262
def load(self, commit=None):
        """"""
        git_info = self.record_git_info(commit)
        LOGGER.info("Loading result from '%s'.", git_info.hexsha)
        result = MemoteResult(
            self.session.query(Result.memote_result).
            filter_by(hexsha=git_info.hexsha).
            one().memote_result)
        # Add git info so the object is equivalent to the one returned by the
        #  RepoResultManager.
        self.add_git(result.meta, git_info)
        return result
637300
function createStore(ClonedVue, rawModules, state) {
    let Vuex = require('vuex');

    if (typeof Vuex.default !== 'undefined') {
        Vuex = Vuex.default;
    }

    ClonedVue.use(Vuex);

    // create a normalized copy of our vuex modules
    const normalizedModules = normalizeModules(rawModules);

    // merge in any test specific state
    const modules = mergeTestState(normalizedModules, state);

    // return the instantiated vuex store
    return new Vuex.Store({ state, modules, strict: true });
}
733544
async def repository(self, *args, **kwargs):
        

        return await self._makeApiCall(self.funcinfo["repository"], *args, **kwargs)
77820
def PushState(self, **unused_kwargs):
    """"""
    logging.debug('Storing state {0:s}'.format(repr(self.state)))
    self.state_stack.append(self.state)
1004209
def __create_and_save_state(cls, job_config, mapreduce_spec):
    
    state = model.MapreduceState.create_new(job_config.job_id)
    state.mapreduce_spec = mapreduce_spec
    state.active = True
    state.active_shards = 0
    state.app_id = job_config._app
    config = datastore_rpc.Configuration(force_writes=job_config._force_writes)
    state.put(config=config)
    return state
1755
def _create(self):
        """"""
        if not os.path.exists(settings.SALMON_WHISPER_DB_PATH):
            os.makedirs(settings.SALMON_WHISPER_DB_PATH)
        archives = [whisper.parseRetentionDef(retentionDef)
                    for retentionDef in settings.ARCHIVES.split(",")]
        whisper.create(self.path, archives,
                       xFilesFactor=settings.XFILEFACTOR,
                       aggregationMethod=settings.AGGREGATION_METHOD)
998934
def initialize_from_checkpoint(state):
  """"""

  # The checkpoint's work_dir should contain the most recently trained model.
  model_paths = glob.glob(os.path.join(FLAGS.checkpoint_dir,
                                       'work_dir/model.ckpt-*.pb'))
  if len(model_paths) != 1:
    raise RuntimeError('Expected exactly one model in the checkpoint work_dir, '
                       'got [{}]'.format(', '.join(model_paths)))
  start_model_path = model_paths[0]

  # Copy the latest trained model into the models directory and use it on the
  # first round of selfplay.
  state.best_model_name = 'checkpoint'
  shutil.copy(start_model_path,
              os.path.join(fsdb.models_dir(), state.best_model_name + '.pb'))

  # Copy the training chunks.
  golden_chunks_dir = os.path.join(FLAGS.checkpoint_dir, 'golden_chunks')
  for basename in os.listdir(golden_chunks_dir):
    path = os.path.join(golden_chunks_dir, basename)
    shutil.copy(path, fsdb.golden_chunk_dir())

  # Copy the training files.
  work_dir = os.path.join(FLAGS.checkpoint_dir, 'work_dir')
  for basename in os.listdir(work_dir):
    path = os.path.join(work_dir, basename)
    shutil.copy(path, fsdb.working_dir())
58244
def store(self, installed_stuff, metadata, interpreter, options):
        """"""
        new_content = {
            'timestamp': int(time.mktime(time.localtime())),
            'installed': installed_stuff,
            'metadata': metadata,
            'interpreter': interpreter,
            'options': options
        }
        logger.debug("Storing installed=%s metadata=%s interpreter=%s options=%s",
                     installed_stuff, metadata, interpreter, options)
        with filelock(self.lockpath):
            self._write_cache([json.dumps(new_content)], append=True)
1226158
def cli(debug, cache, incremental):
    """"""
    settings.HTTP_CACHE = cache
    settings.INCREMENTAL = incremental
    settings.DEBUG = debug
    if settings.DEBUG:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)
    init_memorious()
333616
function init(){

        debug("Checking if there is a repository");
        return co(function*(){
            let repo;
            try {
                repo = yield nodegit.Repository.open(repositoryPath);
            } catch(err) {
                debug("Repository not found.");
                repo = yield _createRepository();
            }

            debug("Repository is ready");
            return repo;

        });
    }
802278
function execute(req, res) {
  Persistence.save(this.state.store, this.state.conf);
  res.send(null, Constants.OK);
}
534269
private void initRepositoryFeatures()
    {
        if (this.repositoryVersion == null) {
            // Default features

            this.repositoryVersion = new DefaultVersion(Resources.VERSION10);
            this.filterable = false;
            this.sortable = false;

            // Get remote features

            CloseableHttpResponse response;
            try {
                response = getRESTResource(this.rootUriBuider);
            } catch (IOException e) {
                // Assume it's a 1.0 repository
                return;
            }

            try {
                Repository repository = getRESTObject(response);

                this.repositoryVersion = new DefaultVersion(repository.getVersion());
                this.filterable = repository.isFilterable() == Boolean.TRUE;
                this.sortable = repository.isSortable() == Boolean.TRUE;
            } catch (Exception e) {
                LOGGER.error("Failed to get repository features", e);
            }
        }
    }