Skip to content

Commit fa7916e

Browse files
committed
ADD pipeline listing
1 parent 2bb2b00 commit fa7916e

File tree

7 files changed

+122
-22
lines changed

7 files changed

+122
-22
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ Settings need to be passed as enviroment variables:
4242
## Routes
4343
Arguments need to be send as JSON (`content-type: application/json`).
4444

45-
- `/pipeline/ocr`: Handle OCR actions
46-
- GET: Obtain a list of previous OCR actions
47-
- POST: Register an new OCR job. The `file` argument with the file url (or an object containing the `name` property) is mandatory.
48-
- GET `/pipeline/ocr/id`: Gets the status of an OCR job. The response is in the following format (changing the status):
45+
- GET `/pipeline/options`: returns all pipeline options
46+
- POST `/pipeline/:type`: Register an new pipeline job. `type` is the pipeline ID, and you need to pass the `input` arguments.
47+
- GET: `/pipeline`Obtain a list of previous pipeline jobs
48+
- GET `/pipeline/:id`: Gets the status of an pipeline job. The response is in the following format (changing the status):
4949
```json
5050
{
5151
"type": "ocr",

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ services:
33
dashboard:
44
build: .
55
image: maxjf1/easytopic-dashboard-api:latest
6-
# command: npm run dev
7-
# volumes:
8-
# - ./:/app
6+
command: npm run dev
7+
volumes:
8+
- ./:/app
99
depends_on:
1010
- rabbitmq
1111
ports:

src/pipelines.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/pipelines/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import ocr from './ocr.json';
2+
import ocrTest from './ocrTest.json';
3+
4+
export default [
5+
ocr,
6+
ocrTest,
7+
];

src/pipelines/ocr.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"version": "1.0",
3+
"id": "ocr",
4+
"name": "OCR",
5+
"description": "Runs OCR on an image files",
6+
"input": [
7+
{
8+
"id": "image",
9+
"name": "Image",
10+
"description": "The image from the OCR will be generated",
11+
"type": "file",
12+
"accept": [
13+
"image/*"
14+
]
15+
}
16+
],
17+
"output": [
18+
{
19+
"id": "ocr",
20+
"type": "text",
21+
"name": "OCR Result",
22+
"description": "The result of the OCR processing"
23+
}
24+
],
25+
"pipeline": [
26+
{
27+
"id": "ocr-service",
28+
"queues": [
29+
{
30+
"env": "OCR_INPUT_QUEUE",
31+
"default": "ocr-in"
32+
},
33+
{
34+
"env": "OCR_OUTPUT_QUEUE",
35+
"default": "ocr-out"
36+
}
37+
],
38+
"arguments": {
39+
"file": "image"
40+
},
41+
"output": [
42+
"ocr"
43+
]
44+
}
45+
]
46+
}

src/pipelines/ocrTest.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"version": "1.0",
3+
"id": "ocr-jpg",
4+
"name": "OCR",
5+
"description": "Runs OCR on jpg files",
6+
"input": [
7+
{
8+
"id": "image",
9+
"name": "Image",
10+
"description": "The image from the OCR will be generated",
11+
"type": "file",
12+
"accept": ".jpg"
13+
},
14+
{
15+
"id": "args",
16+
"name": "Arguments",
17+
"description": "The arguments will be passed to the OCR worker",
18+
"type": "text"
19+
}
20+
],
21+
"output": [
22+
{
23+
"id": "ocr",
24+
"type": "text",
25+
"name": "OCR Result",
26+
"description": "The result of the OCR processing"
27+
},
28+
{
29+
"id": "ocr-duplicate",
30+
"type": "text",
31+
"name": "OCR duplicate",
32+
"description": "Just a duplicate result of the OCR"
33+
}
34+
],
35+
"pipeline": [
36+
{
37+
"id": "ocr-service",
38+
"queues": [
39+
{
40+
"env": "OCR_INPUT_QUEUE",
41+
"default": "ocr-in"
42+
},
43+
{
44+
"env": "OCR_OUTPUT_QUEUE",
45+
"default": "ocr-out"
46+
}
47+
],
48+
"arguments": {
49+
"file": "image"
50+
},
51+
"output": {
52+
"ocr": "ocr",
53+
"ocr-duplicate": "ocr"
54+
}
55+
}
56+
]
57+
}

src/routers/pipelineRouter.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Router } from 'express';
22
import LocalDatabase from '../lib/LocalDatabase';
33
import { getChannel, queues } from '../lib/queueConnection';
4+
import pipelines from '../pipelines';
45

56
const pipelineRouter = new Router();
67
/**
@@ -29,6 +30,10 @@ pipelineRouter.post('/ocr', async ({ body: { file } }, res) => {
2930
res.send(item);
3031
});
3132

33+
pipelineRouter.get('/options', (req, res) => res.send(
34+
pipelines.map(({ pipeline, ...info }) => info),
35+
));
36+
3237
pipelineRouter.get('/:id', ({ params: { id } }, res) => res
3338
.send(LocalDatabase.getItem(id) || 404));
3439

0 commit comments

Comments
 (0)