|
1 |
| -# BIIGLE GPU Module |
| 1 | +# Remote Queue |
2 | 2 |
|
3 |
| -Handle communication between BIIGLE and the BIIGLE GPU server. |
| 3 | +Submit jobs to other Laravel or Lumen instances. |
4 | 4 |
|
5 | 5 | ## Installation
|
6 | 6 |
|
7 |
| -This module needs to be installed both for the BIIGLE instance and the GPU server. |
8 |
| - |
9 | 7 | ```
|
10 |
| -composer config repositories.gpu vcs https://github.com/biigle/gpu |
11 |
| -composer require biigle/gpu |
| 8 | +composer config repositories.laravel-remote-queue vcs https://github.com/biigle/larave-remote-queue |
| 9 | +composer require biigle/laravel-remote-queue |
12 | 10 | ```
|
13 | 11 |
|
14 |
| -### BIIGLE |
| 12 | +### Laravel |
15 | 13 |
|
16 |
| -The service provider and `Gpu` facade are auto discovered by BIIGLE. |
| 14 | +The service provider is auto-discovered by Laravel. |
17 | 15 |
|
18 |
| -### GPU Server |
| 16 | +### Lumen |
19 | 17 |
|
20 |
| -Add `$app->register(Biigle\Modules\Gpu\GpuServerServiceProvider::class);` to `bootstrap/app.php`. |
| 18 | +Add `$app->register(Biigle\RemoteQueue\RemoteQueueServiceProvider::class);` to `bootstrap/app.php`. |
21 | 19 |
|
22 | 20 | ## Configuration
|
23 | 21 |
|
24 | 22 | todo
|
25 | 23 |
|
26 | 24 | ## Usage
|
27 | 25 |
|
28 |
| -To submit a job to the GPU server, it must extend `Biigle\Modules\Gpu\Jobs\GpuJob`. A job instance can be submitted with `Gpu::push($job)` and will be executed on the GPU server. To return the result data back to the BIIGLE instance, the job must call `$this->submitResponse($response)` at the end of its `handle` method. The response object must extend `Biigle\Jobs\Job` and will be executed on the BIIGLE instance where it can handle storage of the result data. |
29 |
| - |
30 |
| -Be aware that the GPU server has no database access. All required information needs to be stored in the `GpuJob`. |
31 |
| - |
32 |
| -**Example:** |
33 |
| - |
34 | 26 | ```php
|
35 |
| -use Gpu; |
36 |
| -use Biigle\Jobs\Job; |
37 |
| -use Biigle\Modules\Gpu\Jobs\GpuJob; |
| 27 | +use App\Jobs\MyJob; |
38 | 28 |
|
39 |
| -/* |
40 |
| - * Instances of this class are submitted to the GPU server with Gpu::push(). |
41 |
| - */ |
42 |
| -class MyGpuJob extends GpuJob |
43 |
| -{ |
44 |
| - /* |
45 |
| - * Instances of this class are created in BIIGLE. |
46 |
| - */ |
47 |
| - public function __construct($data) |
48 |
| - { |
49 |
| - $this->data = $data; |
50 |
| - } |
51 |
| - |
52 |
| - /* |
53 |
| - * But the handle() method is executed on the GPU server. |
54 |
| - */ |
55 |
| - public function handle() |
56 |
| - { |
57 |
| - $result = $this->computeGpuStuff($data); |
58 |
| - $this->submitResponse(new MyGpuResponse($result)); |
59 |
| - } |
60 |
| -} |
| 29 | +MyJob::dispatch($data)->onConnection('remote'); |
| 30 | +``` |
61 | 31 |
|
62 |
| -/* |
63 |
| - * Instances of this class are used as argument for GpuJob::submitResponse. |
64 |
| - */ |
65 |
| -class MyGpuResponse extends Job |
66 |
| -{ |
67 |
| - /* |
68 |
| - * Instances of this class are created on the GPU server. |
69 |
| - */ |
70 |
| - public function __construct($result) |
71 |
| - { |
72 |
| - $this->result = $result; |
73 |
| - } |
| 32 | +## Submit/Response Pattern |
74 | 33 |
|
75 |
| - /* |
76 |
| - * But the handle() method is executed in BIIGLE. |
77 |
| - */ |
78 |
| - public function handle() |
79 |
| - { |
80 |
| - $this->storeResultInDatabase($this->result); |
81 |
| - } |
82 |
| -} |
| 34 | +We developed this package to be able to process jobs on a remote machine with GPU. To return the computed results, we applied what we call the "submit/response" pattern. |
83 | 35 |
|
84 |
| -// In the BIIGLE instance: |
85 |
| -Gpu::push(new MyGpuJob('some data')); |
86 |
| -``` |
| 36 | +In this pattern, this package is installed on both Laravel/Lumen instances (let's call them A and B). In instance A, the remote queue is configured to push jobs to instance B (the one with the GPU). In instance B, the remote queue is configured to push jobs to instance A. New GPU jobs are submitted from instance A to the remote queue on instance B. Once the results are computed, they are returned as a "response job" to the remote queue on instance A where the results can be further processed. |
0 commit comments