Skip to content
Snippets Groups Projects
samples.js 11.45 KiB
export const makeSampleResults = (results) => ({
  count: results.length,
  number: 1,
  previous: 'http://previous',
  next: 'http://next',
  results
})

export const makeCursorSampleResults = (results) => ({
  count: null,
  previous: 'http://previous?cursor=ABC',
  next: 'http://next?cursor=GHI',
  results
})

export const pageSample = {
  id: 'pageid',
  type: 'page',
  name: 'Page 4 recto',
  image: {
    id: 'imageid',
    width: 1000,
    height: 2000,
    path: 'path',
    url: 'http://url/path'
  }
}

export const zoneSample = {
  id: 'zoneid',
  url: 'http://zone',
  x: 10,
  y: 20,
  width: 30,
  height: 40
}

export const elementSample = {
  id: 'volumeid',
  name: 'Volume 1',
  type: 'volume'
}

export const elementsSample = makeSampleResults([elementSample])

export const entitiesSample = makeSampleResults([
  {
    id: 'entityid',
    name: 'Paris',
    type: 'location'
  }
])

export const documentsSample = makeSampleResults([
  {
    id: 'documentid',
    parent_id: 'parentid',
    element_id: 'elementid'
  }
])

export const corpusSample = {
  id: 'corpusid',
  name: 'Démo JFK',
  description: 'Assassinat de John F. Kennedy',
  public: true,
  rights: ['read', 'write', 'admin']
}

export const corporaSample = [
  {
    id: 'jfk',
    name: 'Démo JFK',
    description: 'Assassinat de John F. Kennedy',
    public: true
  },
  {
    id: 'himanis',
    name: 'Himanis',
    description: 'Trésor des Chartres registers',
    public: false
  }
]

export const taskSample = {
  id: 'taskid',
  slug: 'task-slug',
  state: 'running',
  logs: 'hello'
}

export const processSample = {
  id: 'processid',
  state: 'created',
  mode: 'workers',
  corpus: 'himanis',
  farm: {
    id: 'farm1',
    name: 'Wheat farm'
  },
  tasks: [taskSample]
}

export const templateSample = {
  id: 'templateid',
  name: 'test-template',
  state: 'unscheduled',
  mode: 'template',
  corpus: 'himanis',
  template_id: null
}

export const modelsSample = makeSampleResults([
  {
    id: 'modelid',
    name: 'test-model',
    rights: ['read', 'write', 'admin']
  },
  {
    id: 'modelid2',
    name: 'test-model2',
    rights: ['read', 'write']
  }
])

export const modelVersionsSample = makeSampleResults([
  {
    id: 'versionid1',
    model_id: 'modelid',
    created: '2022-03-30T14:01:34.476283Z',
    parent: null,
    description: '',
    tag: null,
    state: 'created',
    size: 8,
    configuration: {}
  },
  {
    id: 'versionid2',
    model_id: 'modelid',
    created: '2022-03-31T14:01:34.476283Z',
    parent: 'versionid1',
    description: '',
    tag: null,
    state: 'available',
    size: 8,
    configuration: {}
  }
])

export const makeTranscriptionResult = text => ({
  id: text + '-transcription',
  text,
  zone: {
    id: text + '-zone',
    polygon: [[1, 0], [2, 1], [2, 2], [2, 0], [1, 0]],
    url: 'http://nothing',
    image_url: 'http://nothing2'
  }
})

export const transcriptionsPage1 = {
  count: 3,
  number: 1,
  previous: null,
  next: 'http://url?page=2',
  results: [
    makeTranscriptionResult('michel')
  ]
}

export const transcriptionsPage2 = {
  count: 3,
  number: 2,
  previous: 'http://url?page=1',
  next: null,
  results: [
    makeTranscriptionResult('I drink coffee'),
    makeTranscriptionResult('everyday')
  ]
}

export const artifactSample = {
  id: 'artifactid',
  size: 42,
  path: 'path/to/file.json'
}

export const agentSample = {
  id: 'agentid',
  cpu_cores: 16,
  cpu_load: 0.5,
  ram_total: 16,
  ram_load: 0.42,
  last_ping: '1987-06-02',
  active: true,
  farm: { name: 'Tegridy' },
  running_tasks_count: 1,
  gpus: [
    {
      id: 'gpuid',
      index: 0,
      name: 'Super Fast & Expensive GPU',
      ram_total: 1024 * 1024 * 1024
    }
  ]
}

export const farmsSample = makeSampleResults([
  {
    id: 'farm1',
    name: 'Wheat farm'
  }, {
    id: 'farm2',
    name: 'Corn farm'
  }])

export const repoSample = {
  id: 'repoid',
  url: 'http://repo',
  corpus: 'himanis',
  workers: [{ id: 'worker 1' }]
}

export const reposSample = makeSampleResults([repoSample])

export const providersSample = [
  {
    name: 'GitLabProvider',
    display_name: 'GitLab'
  }
]

export const credentialsSample = makeSampleResults([
  {
    id: 'credid',
    provider_name: 'gitlab',
    provider_url: 'https://gitlab.example.com',
    account_name: 'John Doe'
  }
])

export const userSample = {
  id: 42,
  email: 'bob@ross.com',
  display_name: 'Bob Ross',
  is_admin: true,
  verified_email: true,
  auth_token: 'cafe',
  features: {
    signup: false,
    selection: true
  }
}

export const entitySample = {
  id: 'entityid',
  name: 'Paris',
  type: 'location'
}

export const entitiesInTranscriptionSample = {
  count: 1,
  next: null,
  results: [
    {
      entity: {
        id: 'entityid',
        name: 'Paris',
        type: 'location'
      },
      length: 5,
      offset: 0
    }
  ]
}

export const elementNeighborsSample = [
  {
    ordering: 3,
    previous: {
      id: 'elementidx',
      type: 'page',
      name: 'element 3'
    },
    next: {
      id: 'elementidx',
      type: 'page',
      name: 'element 4'
    },
    path: [
      {
        id: 'volumeid',
        type: 'volume',
        name: 'this is a volume'
      }
    ]
  },
  {
    ordering: 8,
    previous: {
      id: 'elementidx',
      type: 'page',
      name: 'element 8'
    },
    next: {
      id: 'elementidx',
      type: 'page',
      name: 'element 10'
    },
    path: [
      {
        id: 'volumeid',
        type: 'volume',
        name: 'this is a volume'
      }
    ]
  }
]

export const linksSample = makeSampleResults(
  [{
    id: 'linkid',
    parent: {
      entitySample
    },
    child: {
      entitySample
    },
    role: {
      id: 'roleid',
      parent_name: 'parent',
      child_name: 'child',
      parent_type: 'location',
      child_type: 'location'
    }
  }]
)

export const workerSample = {
  id: 'workerid',
  name: 'my worker',
  slug: 'my_worker',
  type: 'classifier'
}

export const workersSample = makeSampleResults([
  {
    id: 'workerid1',
    name: 'Worker 1',
    slug: 'worker_1',
    type: 'classifier'
  },
  {
    id: 'workerid2',
    name: 'Worker 2',
    slug: 'worker_2',
    type: 'classifier'
  },
  {
    id: 'workerid3',
    name: 'Generic worker',
    slug: 'worker_generic',
    type: 'generic'
  }
])

export const workerTypesSample = makeSampleResults([
  {
    display_name: 'Classifier',
    slug: 'classifier',
    id: 'worker_type_1'
  },
  {
    display_name: 'OCR',
    slug: 'ocr',
    id: 'worker_type_2'
  }
])

export const workerConfigurationsSample = [
  {
    id: 'configid1',
    name: 'configname1',
    configuration: {
      test: 'test'
    }
  },
  {
    id: 'configid2',
    name: 'configname2',
    configuration: {
      test: 'test'
    }
  }
]

export const workerVersionsSample = makeSampleResults([
  {
    id: 'versionid1',
    configuration: {
      id: 'configurationid1',
      test: 'test'
    },
    revision: {
      id: 'revisionid1',
      state: 'created',
      hash: 'xxxxxxxxxxxxxxxx',
      author: 'Bob',
      message: 'commit message',
      created: '2020-05-27',
      commit_url: 'https://xxxxxxxxxxxxxxxx',
      refs: [
        { id: 'refid1', name: 'master', type: 'branch' },
        { id: 'refid2', name: 'v1.10.02', type: 'tag' }
      ]
    },
    worker: workersSample.results[0]
  },
  {
    id: 'versionid2',
    configuration: {
      id: 'configurationid2',
      test: 'test'
    },
    revision: {
      id: 'revisionid2',
      state: 'processing',
      hash: 'yyyyyyyyyyyyyyyy',
      author: 'Patrick',
      message: 'merge message',
      created: '2020-05-27',
      commit_url: 'https://yyyyyyyyyyyyyyyy',
      refs: []
    },
    worker: workersSample.results[1]
  },
  {
    id: 'versionid3',
    configuration: {
      id: 'configurationid3',
      test: 'test'
    },
    revision: {
      id: 'revisionid3',
      state: 'processing',
      hash: 'hehehehehehe',
      author: 'Patrick',
      message: 'Create generic worker',
      created: '2020-05-27',
      commit_url: 'https://hehehehehehe',
      refs: []
    },
    worker: workersSample.results[2]
  }
])

export const workerVersionsCacheSample = makeSampleResults([
  {
    id: 'worker_version_cache_1',
    worker_version: workerVersionsSample.results[0],
    model_version: null,
    worker_configuration: null
  }, {
    id: 'worker_version_cache_2',
    worker_version: workerVersionsSample.results[1],
    model_version: modelVersionsSample.results[0],
    worker_configuration: workerConfigurationsSample[0]
  }
])

export const workerRunSample = {
  id: 'singleworkerrun',
  parents: [],
  worker_version: workerVersionsSample.results[0],
  configuration: {},
  model_version: {},
  process: {},
  summary: 'a worker run'
}

export const workerRunsSample = [
  {
    id: 'workerRun1',
    parents: [],
    worker_version: workerVersionsSample.results[0],
    configuration: workerConfigurationsSample[0],
    model_version: {},
    process: {},
    summary: 'worker run 1'
  },
  {
    id: 'workerRun2',
    parents: ['workerRun1'],
    worker_version: workerVersionsSample.results[1],
    configuration: workerConfigurationsSample[1],
    model_version: {},
    process: {},
    summary: 'worker run 2'
  },
  {
    id: 'workerRun3',
    parents: [],
    worker_version: workerVersionsSample.results[2],
    model_version: modelVersionsSample.results[0],
    configuration: {},
    process: {},
    summary: 'worker run 3'
  }
]

export const processesSample = {
  process_id: {
    id: 'process_id',
    state: 'unscheduled',
    element: elementSample,
    mode: 'workers',
    corpus: 'corpus_id',
    template_id: null
  }
}

export const processElementsSample = makeCursorSampleResults([elementSample])

export const groupSample = {
  id: 'groupid',
  name: 'Dream Team',
  public: true,
  members_count: 1,
  level: 100
}

export const jobsSample = [
  {
    id: 'jobid',
    status: 'started',
    enqueued_at: '2020-02-12T10:11:12.123456+0100',
    started_at: '2020-02-12T20:21:22.789101+0100',
    ended_at: null,
    progress: null,
    description: 'Something'
  }
]

export const membersPageSample = {
  count: 2,
  number: 1,
  next: '/group/groupid/members/?page=2',
  previous: null,
  results: [
    {
      id: 'member1id',
      display_name: 'member1',
      email: 'mem1@group.fr',
      level: 'admin'
    },
    {
      id: 'member2id',
      display_name: 'member2',
      email: 'mem2@group.fr',
      level: 'write'
    }
  ]
}

export const workersActivitySample = [
  {
    worker_version_id: 'version1',
    queued: 50,
    started: 8,
    processed: 42,
    error: 0
  },
  {
    worker_version_id: 'version2',
    queued: 0,
    started: 0,
    processed: 99,
    error: 1
  }
]

export const exportSample = {
  id: 'exportid',
  created: '2020-01-01T00:00:00Z',
  updated: '2020-01-02T00:00:00Z',
  corpus_id: 'corpusid',
  state: 'created',
  user: {
    id: 42,
    display_name: 'The Chosen One',
    email: 'me@me.me'
  }
}

export const exportSourcesSample = [
  {
    name: 'default',
    last_update: null
  },
  {
    name: 'export',
    last_update: '2038-01-19T03:14:07.999999Z'
  }
]

export const bucketsSample =
  [
    {
      name: 'bucket number one'
    },
    {
      name: 'secchio numero due'
    },
    {
      name: 'emmer nummer drie'
    }
  ]

export const s3ProcessSample = {
  id: 'processid',
  state: 'created',
  mode: 's3',
  corpus: 'some corpus'
}

export const elementDatasetsSample = makeSampleResults([
  {
    dataset_id: 'dataset_1',
    dataset_name: 'dataset',
    set: 'test'
  }, {
    dataset_id: 'dataset_1',
    dataset_name: 'dataset',
    set: 'train'
  }
])