Module: Desiru::AsyncCapable

Included in:
Module
Defined in:
lib/desiru/async_capable.rb

Instance Method Summary collapse

Instance Method Details

#call_async(inputs = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/desiru/async_capable.rb', line 9

def call_async(inputs = {})
  job_id = SecureRandom.uuid

  Desiru::Jobs::AsyncPredict.perform_async(
    job_id,
    self.class.name,
    signature.to_s,
    inputs,
    {
      'model_class' => model.class.name,
      'model_config' => model_config,
      'config' => config,
      'demos' => demos
    }
  )

  AsyncResult.new(job_id)
end

#call_batch_async(inputs_array) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/desiru/async_capable.rb', line 28

def call_batch_async(inputs_array)
  batch_id = SecureRandom.uuid

  Desiru::Jobs::BatchProcessor.perform_async(
    batch_id,
    self.class.name,
    signature.to_s,
    inputs_array,
    {
      'model_class' => model.class.name,
      'model_config' => model_config,
      'config' => config,
      'demos' => demos
    }
  )

  BatchResult.new(batch_id)
end