summaryrefslogtreecommitdiff
path: root/app/client/modules/samplernn/samplernn.tasks.js
blob: bb227912cd555d0ecbb7b12a8314bd608f49726d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import uuidv1 from 'uuid/v1'

import socket from '../../socket'
import types from '../../types'

import actions from '../../actions'

export const train_task = (dataset, folder_id, epochs=1) => dispatch => {
  const task = {
    module: 'samplernn',
    activity: 'train',
    dataset: dataset.name,
    epoch: dataset.checkpoints.length ? dataset.checkpoints[0].epoch || 0 : 0,
    epochs: epochs,
    folder_id: folder_id,
    opt: {
      sample_length: 44100 * 5,
      n_samples: 6,
      keep_old_checkpoints: false,
    }
  }
  console.log(task)
  return actions.queue.add_task(task)
}
export const fetch_task = (url, folder_id, file_id, dataset) => dispatch => {
  if (! url) return console.log('input file inaccessible (no url)')
  const task = {
    module: 'samplernn',
    activity: 'fetch',
    dataset: dataset,
    folder_id: folder_id,
    opt: {
      url,
      file_id,
      dataset,
    }
  }
  return actions.queue.add_task(task)
}
export const log_task = (dataset) => dispatch => {
  const task = {
    module: 'samplernn',
    activity: 'log',
    dataset: dataset.name,
  }
  return actions.queue.add_task(task)
}
export const clear_cache_task = (dataset) => dispatch => {
  const task = {
    module: 'samplernn',
    activity: 'clear_cache',
    dataset: dataset.name,
  }
  return actions.queue.add_task(task)
}