<commit_before>
module.exports = async function (log, metainfo, models, disableTests) {
  if (!metainfo) return;
  let state;
  const load = async () => metainfo.get();
  const save = async () => metainfo.set(state);

  async function update(name, version) {
    state.updated = new Date().toISOString();
    state.versions[name] = version;
    await save();
    return version;
  }

  async function setup(name, model) {
    const { setup, version = 0, changes = [] } = model;
    if (setup) await setup();
    return update(name, version + changes.length);
  }

  async function test(name, model) {
    if (!model.testing) return false;
    const { version = 0, perform, reset } = model.testing;
    if (reset) return update(name, -1);
    if (isNaN(version)) return false;
    if (perform) await perform();
    return update(name, version);
  }

  async function upgrade(from, name, model) {
    const { version, changes } = model;
    for (let i = from - version; i < changes.length; i += 1) {
      const change = changes[i];
      if (change) await change();
      await update(name, version + i + 1);
      log.info('Model "%s" upgraded to v%d.', name, version + i + 1);
    }
  }

  async function migrate(name, model) {
    let old = state.versions[name];
    const { testing, version = 0, changes = [] } = model;
    const latest = version + changes.length;
    if (!disableTests) {
      const result = await test(name, model);
      if (result !== false) {<commit_msg>Reset version if no version specified in testing<commit_after>
module.exports = async function (log, metainfo, models, disableTests) {
  if (!metainfo) return;
  let state;
  const load = async () => metainfo.get();
  const save = async () => metainfo.set(state);

  async function update(name, version) {
    state.updated = new Date().toISOString();
    state.versions[name] = version;
    await save();
    return version;
  }

  async function setup(name, model) {
    const { setup, version = 0, changes = [] } = model;
    if (setup) await setup();
    return update(name, version + changes.length);
  }

  async function test(name, model) {
    if (!model.testing) return false;
    const { version = -1, perform, reset } = model.testing;
    if (reset) return update(name, -1);
    if (isNaN(version)) return false;
    if (perform) await perform();
    return update(name, version);
  }

  async function upgrade(from, name, model) {
    const { version, changes } = model;
    for (let i = from - version; i < changes.length; i += 1) {
      const change = changes[i];
      if (change) await change();
      await update(name, version + i + 1);
      log.info('Model "%s" upgraded to v%d.', name, version + i + 1);
    }
  }

  async function migrate(name, model) {
    let old = state.versions[name];
    const { testing, version = 0, changes = [] } = model;
    const latest = version + changes.length;
    if (!disableTests) {
      const result = await test(name, model);
      if (result !== false) {
{'fraction_non_alphanumeric': 0.14185580774365822, 'fraction_numerical': 0.004672897196261682, 'mean_word_length': 3.0336473755047106, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3046124', 'n_tokens_mistral': 926, 'n_tokens_neox': 904, 'n_words': 303}