@colabo-flow/s-go 0.1.2 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/demo/create-client.d.ts +1 -0
- package/dist/cjs/demo/create-host.d.ts +1 -0
- package/dist/cjs/demo/send.d.ts +1 -0
- package/{index.ts → dist/cjs/index.d.ts} +3 -4
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/jest.config.d.ts +3 -0
- package/dist/cjs/lib/config.d.ts +13 -0
- package/dist/cjs/lib/go.amqp.client.d.ts +4 -0
- package/dist/cjs/lib/go.amqp.host.d.ts +6 -0
- package/dist/cjs/lib/go.amqp.host_status.d.ts +1 -0
- package/dist/cjs/lib/go.amqp.service.d.ts +1 -0
- package/dist/cjs/lib/operators.d.ts +2 -0
- package/dist/cjs/lib/params.d.ts +1 -0
- package/dist/cjs/lib/vos.d.ts +173 -0
- package/dist/cjs/test_ts.d.ts +1 -0
- package/dist/cjs/tests/units/chalk/index.d.ts +21 -0
- package/dist/cjs/tests/units/tests-vos/tasks-and-flows.vos.d.ts +20 -0
- package/dist/esm/demo/create-client.d.ts +1 -0
- package/dist/esm/demo/create-host.d.ts +1 -0
- package/dist/esm/demo/send.d.ts +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/jest.config.d.ts +3 -0
- package/dist/esm/lib/config.d.ts +13 -0
- package/dist/esm/lib/go.amqp.client.d.ts +4 -0
- package/dist/esm/lib/go.amqp.host.d.ts +6 -0
- package/dist/esm/lib/go.amqp.host_status.d.ts +1 -0
- package/dist/esm/lib/go.amqp.service.d.ts +1 -0
- package/dist/esm/lib/operators.d.ts +2 -0
- package/dist/esm/lib/params.d.ts +1 -0
- package/dist/esm/lib/vos.d.ts +173 -0
- package/dist/esm/test_ts.d.ts +1 -0
- package/dist/esm/tests/units/chalk/index.d.ts +21 -0
- package/dist/esm/tests/units/tests-vos/tasks-and-flows.vos.d.ts +20 -0
- package/dist/index.d.ts +184 -0
- package/package.json +43 -6
- package/DEVELOPMENT.md +0 -38
- package/__init__.py +0 -0
- package/__pycache__/__init__.cpython-39.pyc +0 -0
- package/create_client.py +0 -84
- package/create_host.py +0 -91
- package/create_host_terra.py +0 -103
- package/demo/__init__.py +0 -0
- package/demo/create-client.ts +0 -51
- package/demo/create-host.ts +0 -136
- package/demo/send-simple-recommended.py +0 -26
- package/demo/send-simple.py +0 -50
- package/demo/send.py +0 -352
- package/demo/send.ts +0 -40
- package/demo/threading/README.md +0 -14
- package/demo/threading/basic_consumer_connection_threaded.png +0 -0
- package/demo/threading/basic_consumer_connection_threaded.py +0 -135
- package/demo/threading/basic_consumer_threaded.py +0 -100
- package/demo/threading/long-running-publisher.py +0 -68
- package/docs/ColaboFlow-infrastructure-diagram.png +0 -0
- package/docs/workflow.md +0 -35
- package/jest.config.ts +0 -172
- package/lib/__init__.py +0 -0
- package/lib/__pycache__/__init__.cpython-39.pyc +0 -0
- package/lib/__pycache__/config.cpython-39.pyc +0 -0
- package/lib/__pycache__/executor_operators.cpython-39.pyc +0 -0
- package/lib/__pycache__/executor_vos.cpython-39.pyc +0 -0
- package/lib/__pycache__/go_amqp_client.cpython-39.pyc +0 -0
- package/lib/__pycache__/go_amqp_client_threaded.cpython-39.pyc +0 -0
- package/lib/__pycache__/go_amqp_host.cpython-39.pyc +0 -0
- package/lib/__pycache__/operators.cpython-39.pyc +0 -0
- package/lib/__pycache__/vos.cpython-39.pyc +0 -0
- package/lib/config.py +0 -21
- package/lib/config.ts +0 -22
- package/lib/executor_operators.py +0 -23
- package/lib/executor_vos.py +0 -318
- package/lib/go.amqp.client-old-basic.py +0 -50
- package/lib/go.amqp.client.ts +0 -100
- package/lib/go.amqp.host-old-basic.py +0 -48
- package/lib/go.amqp.host.ts +0 -269
- package/lib/go.amqp.host_status.ts +0 -81
- package/lib/go.amqp.service.ts +0 -272
- package/lib/go_amqp_client.py +0 -263
- package/lib/go_amqp_client_non_threaded.py +0 -152
- package/lib/go_amqp_host.py +0 -348
- package/lib/operators.py +0 -16
- package/lib/operators.ts +0 -17
- package/lib/params.ts +0 -1
- package/lib/vos.py +0 -232
- package/lib/vos.ts +0 -212
- package/requirements.txt +0 -4
- package/tests/units/README.md +0 -12
- package/tests/units/chalk/index.ts +0 -41
- package/tests/units/go.amqp.host.test.ts +0 -116
- package/tests/units/tests-vos/tasks-and-flows.vos.ts +0 -128
- package/tsconfig.json +0 -45
- package/v1 - GRPC/README.md +0 -18
- package/v1 - GRPC/node/README.md +0 -13
- package/v1 - GRPC/node/colaboflow_go_actionhost_client.ts +0 -91
- package/v1 - GRPC/node/colaboflow_go_actionhost_server.ts +0 -84
- package/v1 - GRPC/node/colaboflow_go_client.ts +0 -82
- package/v1 - GRPC/node/colaboflow_go_server.ts +0 -84
- package/v1 - GRPC/node/demos/demo-colaboflow_go_actionhost_client.ts +0 -21
- package/v1 - GRPC/node/index.ts +0 -3
- package/v1 - GRPC/node/package-lock.json +0 -770
- package/v1 - GRPC/node/package.json +0 -30
- package/v1 - GRPC/node/tsconfig.json +0 -32
- package/v1 - GRPC/node/yarn.lock +0 -642
- package/v1 - GRPC/protos/colabo/flow/go/go.proto +0 -135
- package/v1 - GRPC/python/DEVELOPMENT.md +0 -86
- package/v1 - GRPC/python/DISCUSSION.md +0 -8
- package/v1 - GRPC/python/LICENSE.txt +0 -21
- package/v1 - GRPC/python/README.md +0 -45
- package/v1 - GRPC/python/__init__.py +0 -1
- package/v1 - GRPC/python/colabo/__init__.py +0 -3
- package/v1 - GRPC/python/colabo/flow/__init__.py +0 -3
- package/v1 - GRPC/python/colabo/flow/go/__init__.py +0 -12
- package/v1 - GRPC/python/colabo/flow/go/basic/PuzzleImporter.py +0 -77
- package/v1 - GRPC/python/colabo/flow/go/basic/__init__.py +0 -5
- package/v1 - GRPC/python/colabo/flow/go/basic/colaboflow_go_basic.py +0 -66
- package/v1 - GRPC/python/colabo/flow/go/basic/parseFlowJSON.py +0 -32
- package/v1 - GRPC/python/colabo/flow/go/colaboflow_go_actionhost.py +0 -44
- package/v1 - GRPC/python/colabo/flow/go/colaboflow_go_client.py +0 -48
- package/v1 - GRPC/python/colabo/flow/go/colaboflow_go_demo.py +0 -168
- package/v1 - GRPC/python/colabo/flow/go/go_pb2.py +0 -976
- package/v1 - GRPC/python/colabo/flow/go/go_pb2_grpc.py +0 -139
- package/v1 - GRPC/python/colabo.flow.go.egg-info/PKG-INFO +0 -58
- package/v1 - GRPC/python/colabo.flow.go.egg-info/SOURCES.txt +0 -16
- package/v1 - GRPC/python/colabo.flow.go.egg-info/dependency_links.txt +0 -1
- package/v1 - GRPC/python/colabo.flow.go.egg-info/requires.txt +0 -3
- package/v1 - GRPC/python/colabo.flow.go.egg-info/top_level.txt +0 -2
- package/v1 - GRPC/python/demo-0.py +0 -69
- package/v1 - GRPC/python/demo-1.py +0 -146
- package/v1 - GRPC/python/demo-actionhost.py +0 -47
- package/v1 - GRPC/python/demo-basic.md +0 -13
- package/v1 - GRPC/python/demo-basic.py +0 -38
- package/v1 - GRPC/python/demo-executeActionSync.py +0 -32
- package/v1 - GRPC/python/demo-flows/flow-demo.json +0 -36
- package/v1 - GRPC/python/demo-puzzles/puzzles/puzzle-a.py +0 -19
- package/v1 - GRPC/python/demo-puzzles/puzzles/puzzle-b.py +0 -21
- package/v1 - GRPC/python/demo-puzzles/puzzles/puzzle-c.py +0 -20
- package/v1 - GRPC/python/requirements.txt +0 -7
- package/v1 - GRPC/python/setup.py +0 -39
- package/v1 - GRPC/python/use-cases/__init__.py +0 -0
package/create_host.py
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# https://pypi.org/project/pika/
|
|
3
|
-
import pika
|
|
4
|
-
import json
|
|
5
|
-
from yachalk import chalk
|
|
6
|
-
from dataclasses import replace
|
|
7
|
-
# https://docs.python.org/3/library/uuid.html
|
|
8
|
-
import uuid
|
|
9
|
-
from typing import Any, Optional, Callable
|
|
10
|
-
import threading
|
|
11
|
-
import asyncio
|
|
12
|
-
|
|
13
|
-
from dacite import from_dict, Config
|
|
14
|
-
|
|
15
|
-
from lib.config import connectConfig
|
|
16
|
-
# from lib.go_amqp_host import run, executeTask, close
|
|
17
|
-
from lib.go_amqp_host import run, registerTaskExecutor, registerTask, sendHeartbeatToHost, close
|
|
18
|
-
|
|
19
|
-
from lib.vos import IColaboFlowHostData
|
|
20
|
-
from lib.executor_vos import ITaskExecutor, EExecutingEnvironment, IExecutorImplementationReference, IFlowTask, EFlowTaskType, EExecutingEnvironment, EFlowPlaceType, IExecutorReference
|
|
21
|
-
|
|
22
|
-
hostName = "host-python-1"
|
|
23
|
-
appNameText = f'[{chalk.red.bold("Colabo")}{chalk.blue.bold("Flow")}{chalk.green.bold(".Go")}.{chalk.white.bold(hostName)}]';
|
|
24
|
-
|
|
25
|
-
def appNameTextWithContext(context: str) -> str:
|
|
26
|
-
threadId = threading.get_native_id()
|
|
27
|
-
return f'[[{chalk.blue.bold(threadId)}]{chalk.red.bold("Colabo")}{chalk.blue.bold("Flow")}{chalk.green.bold(".Go")}.{chalk.white.bold(hostName)}:{chalk.yellow.bold(context)}]';
|
|
28
|
-
|
|
29
|
-
hostPython1 = IColaboFlowHostData(
|
|
30
|
-
hostName = hostName,
|
|
31
|
-
appNameText = appNameText,
|
|
32
|
-
appNameTextWithContext = appNameTextWithContext,
|
|
33
|
-
amqpUrl = connectConfig.AMQP_URL,
|
|
34
|
-
queueHost = connectConfig.HOST_QUEUE,
|
|
35
|
-
queueHostHeartbeat = connectConfig.HOST_HEARTBEAT_QUEUE,
|
|
36
|
-
queueServiceOrchestrator = connectConfig.ORCHESTRATOR_QUEUE,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
from dataclasses import dataclass
|
|
40
|
-
|
|
41
|
-
@dataclass
|
|
42
|
-
class IExecutorMultipleInput():
|
|
43
|
-
a: int
|
|
44
|
-
b: int
|
|
45
|
-
|
|
46
|
-
async def asyncExecutor_executeMultiple(inputAny: Any) -> int:
|
|
47
|
-
input: IExecutorMultipleInput = from_dict(data_class=IExecutorMultipleInput, data=inputAny)
|
|
48
|
-
if not input:
|
|
49
|
-
print(f"[asyncExecutor_executeBar] Missing input")
|
|
50
|
-
return -1
|
|
51
|
-
|
|
52
|
-
print(f"[asyncExecutor_executeBar] a: {input.a}, b: {input.b}")
|
|
53
|
-
asyncio.sleep(2)
|
|
54
|
-
return input.a * input.b;
|
|
55
|
-
|
|
56
|
-
executorMultiple: ITaskExecutor = ITaskExecutor(
|
|
57
|
-
id = "com.welcometerra.video.ffmpeg-multiple",
|
|
58
|
-
description = "Multiple ffmpeg videos",
|
|
59
|
-
# TODO: In future it should be isomorphic-like: should work on frontend if provided, on backend if provided (with CLI flow overview), or isomorphic if nothing provide
|
|
60
|
-
environment = EExecutingEnvironment.BACKEND,
|
|
61
|
-
reference = IExecutorImplementationReference(
|
|
62
|
-
async_method = asyncExecutor_executeMultiple,
|
|
63
|
-
),
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
taskMultiple: IFlowTask = IFlowTask(
|
|
67
|
-
id = "com.welcometerra.video.ffmpeg-multiple",
|
|
68
|
-
type = EFlowTaskType.SCRIPT,
|
|
69
|
-
description = "Demo multiplying numbers",
|
|
70
|
-
executorRef = IExecutorReference(
|
|
71
|
-
id = executorMultiple.id,
|
|
72
|
-
environment = EExecutingEnvironment.BACKEND,
|
|
73
|
-
),
|
|
74
|
-
)
|
|
75
|
-
print(f"taskMultiple: {taskMultiple}")
|
|
76
|
-
|
|
77
|
-
registerTaskExecutor(hostPython1, executorMultiple);
|
|
78
|
-
registerTask(hostPython1, taskMultiple);
|
|
79
|
-
|
|
80
|
-
async def main():
|
|
81
|
-
print(f"{appNameTextWithContext('main')} Initializing ColaboFlow")
|
|
82
|
-
|
|
83
|
-
await run(hostPython1)
|
|
84
|
-
# we need it to keep the asyncio loop running, as otherwise the loop would stop triggering
|
|
85
|
-
# for example `await asyncio.sleep(1)` in the `go_amqp_host.py:sendHeartbeatsToHost()` would never wake up
|
|
86
|
-
while hostPython1.running:
|
|
87
|
-
# print(f"{appNameTextWithContext('main')} looping in main ...")
|
|
88
|
-
await asyncio.sleep(1)
|
|
89
|
-
|
|
90
|
-
asyncio.run(main())
|
|
91
|
-
|
package/create_host_terra.py
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# https://pypi.org/project/pika/
|
|
3
|
-
import pika
|
|
4
|
-
import json
|
|
5
|
-
from yachalk import chalk
|
|
6
|
-
from dataclasses import replace
|
|
7
|
-
# https://docs.python.org/3/library/uuid.html
|
|
8
|
-
import uuid
|
|
9
|
-
from typing import Any, Optional, Callable
|
|
10
|
-
import threading
|
|
11
|
-
import asyncio
|
|
12
|
-
|
|
13
|
-
from lib.config import connectConfig
|
|
14
|
-
# from lib.go_amqp_host import run, executeTask, close
|
|
15
|
-
from lib.go_amqp_host import run, registerTaskExecutor, registerTask, sendHeartbeatToHost, stop_consuming, close
|
|
16
|
-
|
|
17
|
-
from lib.vos import IColaboFlowHostData
|
|
18
|
-
from lib.executor_vos import ITaskExecutor, EExecutingEnvironment, IExecutorImplementationReference, IFlowTask, EFlowTaskType, EExecutingEnvironment, EFlowPlaceType, IExecutorReference
|
|
19
|
-
|
|
20
|
-
# https://stackoverflow.com/a/53713336/257561
|
|
21
|
-
# https://github.com/konradhalas/dacite
|
|
22
|
-
from dacite import from_dict, Config
|
|
23
|
-
|
|
24
|
-
hostName = "host-python-1"
|
|
25
|
-
appNameText = f'[{chalk.red.bold("Colabo")}{chalk.blue.bold("Flow")}{chalk.green.bold(".Go")}.{chalk.white.bold(hostName)}]';
|
|
26
|
-
|
|
27
|
-
def appNameTextWithContext(context: str) -> str:
|
|
28
|
-
threadId = threading.get_native_id()
|
|
29
|
-
return f'[ (thread:{chalk.blue.bold(threadId)}) {chalk.red.bold("Colabo")}{chalk.blue.bold("Flow")}{chalk.green.bold(".Go")}.{chalk.white.bold(hostName)}:{chalk.yellow.bold(context)}]';
|
|
30
|
-
|
|
31
|
-
hostPython1 = IColaboFlowHostData(
|
|
32
|
-
hostName = hostName,
|
|
33
|
-
appNameText = appNameText,
|
|
34
|
-
appNameTextWithContext = appNameTextWithContext,
|
|
35
|
-
amqpUrl = connectConfig.AMQP_URL,
|
|
36
|
-
queueHost = connectConfig.HOST_QUEUE,
|
|
37
|
-
queueHostHeartbeat = connectConfig.HOST_HEARTBEAT_QUEUE,
|
|
38
|
-
queueServiceOrchestrator = connectConfig.ORCHESTRATOR_QUEUE,
|
|
39
|
-
sendHeartbeat = True,
|
|
40
|
-
listenForOrchestratorRequests = True,
|
|
41
|
-
processOrchestratorTaskExecuteRequests = True,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
from dataclasses import dataclass
|
|
45
|
-
|
|
46
|
-
@dataclass
|
|
47
|
-
class IExecutorMultipleInput():
|
|
48
|
-
a: int
|
|
49
|
-
b: int
|
|
50
|
-
|
|
51
|
-
async def asyncExecutor_executeMultiple(inputAny: Any) -> int:
|
|
52
|
-
input: IExecutorMultipleInput = from_dict(data_class=IExecutorMultipleInput, data=inputAny)
|
|
53
|
-
if not input:
|
|
54
|
-
print(f"[asyncExecutor_executeBar] Missing input")
|
|
55
|
-
return -1
|
|
56
|
-
|
|
57
|
-
print(f"[asyncExecutor_executeBar] a: {input.a}, b: {input.b}")
|
|
58
|
-
asyncio.sleep(2)
|
|
59
|
-
return input.a * input.b;
|
|
60
|
-
|
|
61
|
-
executorMultiple: ITaskExecutor = ITaskExecutor(
|
|
62
|
-
id = "com.welcometerra.video.ffmpeg-multiple",
|
|
63
|
-
description = "Multiple ffmpeg videos",
|
|
64
|
-
# TODO: In future it should be isomorphic-like: should work on frontend if provided, on backend if provided (with CLI flow overview), or isomorphic if nothing provide
|
|
65
|
-
environment = EExecutingEnvironment.BACKEND,
|
|
66
|
-
reference = IExecutorImplementationReference(
|
|
67
|
-
method = asyncExecutor_executeMultiple,
|
|
68
|
-
),
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
taskMultiple: IFlowTask = IFlowTask(
|
|
72
|
-
id = "com.welcometerra.video.ffmpeg-multiple",
|
|
73
|
-
type = EFlowTaskType.SCRIPT,
|
|
74
|
-
description = "Demo multiplying numbers",
|
|
75
|
-
executorRef = IExecutorReference(
|
|
76
|
-
id = executorMultiple.id,
|
|
77
|
-
environment = EExecutingEnvironment.BACKEND,
|
|
78
|
-
),
|
|
79
|
-
)
|
|
80
|
-
print(f"taskMultiple: {taskMultiple}")
|
|
81
|
-
|
|
82
|
-
registerTaskExecutor(hostPython1, executorMultiple);
|
|
83
|
-
registerTask(hostPython1, taskMultiple);
|
|
84
|
-
|
|
85
|
-
async def main():
|
|
86
|
-
print(f"{appNameTextWithContext('main')} Initializing ColaboFlow")
|
|
87
|
-
|
|
88
|
-
await run(hostPython1)
|
|
89
|
-
# we need it to keep the asyncio loop running, as otherwise the loop would stop triggering
|
|
90
|
-
# for example `await asyncio.sleep(1)` in the `go_amqp_host.py:sendHeartbeatsToHost()` would never wake up
|
|
91
|
-
while hostPython1.running:
|
|
92
|
-
# print(f"{appNameTextWithContext('main')} looping in main ...")
|
|
93
|
-
await asyncio.sleep(1)
|
|
94
|
-
|
|
95
|
-
try:
|
|
96
|
-
asyncio.run(main())
|
|
97
|
-
except KeyboardInterrupt:
|
|
98
|
-
# extra line to compensate the CTRL+C keystroke
|
|
99
|
-
print(f"")
|
|
100
|
-
print(f"{appNameTextWithContext('main')} keyboard interrupt, _stop_consuming")
|
|
101
|
-
stop_consuming(hostPython1)
|
|
102
|
-
close(hostPython1)
|
|
103
|
-
|
package/demo/__init__.py
DELETED
|
File without changes
|
package/demo/create-client.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
|
|
3
|
-
import { clientClose, clientExecuteTask, clientRun } from "../lib/go.amqp.client";
|
|
4
|
-
|
|
5
|
-
import { connectConfig } from "../lib/config";
|
|
6
|
-
import { IColaboFlowClientData } from "../lib/vos";
|
|
7
|
-
|
|
8
|
-
const appNameText = `[${chalk.red.bold("Colabo")}${chalk.blue.bold("Flow")}${chalk.green.bold(".Go")}${chalk.green.yellow("client")}]`;
|
|
9
|
-
|
|
10
|
-
const clientNode1: IColaboFlowClientData = {
|
|
11
|
-
clientName: "client-node-1",
|
|
12
|
-
amqpUrl: connectConfig.AMQP_URL,
|
|
13
|
-
queueServiceOrchestrator: connectConfig.ORCHESTRATOR_QUEUE,
|
|
14
|
-
|
|
15
|
-
taskInstances: {},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
await clientRun(clientNode1);
|
|
19
|
-
|
|
20
|
-
console.log(`${appNameText} Launching Task 1`);
|
|
21
|
-
const task1Id: string = "com.welcometerra.video.ffmpeg-combine";
|
|
22
|
-
const task1Input: any = {
|
|
23
|
-
a: 5,
|
|
24
|
-
b: 3,
|
|
25
|
-
};
|
|
26
|
-
const task1OutputPromised: Promise<any> = clientExecuteTask(clientNode1, task1Id, task1Input);
|
|
27
|
-
|
|
28
|
-
console.log(`${appNameText} Launching Task 2`);
|
|
29
|
-
const task2Id: string = "colabo.flow.demo.reduce";
|
|
30
|
-
const task2Input: any = {
|
|
31
|
-
a: 5,
|
|
32
|
-
b: 8,
|
|
33
|
-
};
|
|
34
|
-
const task2Output: any = await clientExecuteTask(clientNode1, task2Id, task2Input);
|
|
35
|
-
console.log(`${appNameText} Task 2 Execution taskOutput: ${chalk.blueBright(JSON.parse(task2Output))}`);
|
|
36
|
-
|
|
37
|
-
console.log(`${appNameText} Launching Task 3`);
|
|
38
|
-
const task3Id: string = "com.welcometerra.video.ffmpeg-multiple";
|
|
39
|
-
const task3Input: any = {
|
|
40
|
-
a: 5,
|
|
41
|
-
b: 5,
|
|
42
|
-
};
|
|
43
|
-
const task3Output: any = await clientExecuteTask(clientNode1, task3Id, task3Input);
|
|
44
|
-
console.log(`${appNameText} Task 3 Execution taskOutput: ${chalk.blueBright(JSON.parse(task3Output))}`);
|
|
45
|
-
|
|
46
|
-
const task1Output: any = await task1OutputPromised;
|
|
47
|
-
console.log(`${appNameText} Task 1 Execution taskOutput: ${chalk.blueBright(JSON.parse(task1Output))}`);
|
|
48
|
-
|
|
49
|
-
await clientClose(clientNode1);
|
|
50
|
-
|
|
51
|
-
process.exit(0);
|
package/demo/create-host.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { EExecutingEnvironment, EFlowPlaceType, EFlowTaskType, IFlowTask, ITaskExecutor } from "@colabo-flow/i-core/vos";
|
|
2
|
-
|
|
3
|
-
import { hostSetTitles, hostRegisterTaskExecutor, hostRegisterTask, hostRun } from "../lib/go.amqp.host";
|
|
4
|
-
import { IColaboFlowHostData } from "../lib/vos";
|
|
5
|
-
|
|
6
|
-
import { connectConfig } from "../lib/config";
|
|
7
|
-
|
|
8
|
-
const asyncExecutor_executeFoo = async (video_path: string): Promise<void> => {
|
|
9
|
-
console.log(`[asyncExecutor_executeFoo] video_path: ${video_path}`);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
interface IExecutorCombineInput {
|
|
13
|
-
a: number;
|
|
14
|
-
b: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const asyncExecutor_executeCombine = async (input: IExecutorCombineInput): Promise<number> => {
|
|
18
|
-
if(!input) {
|
|
19
|
-
console.log(`[asyncExecutor_executeBar] Missing input`);
|
|
20
|
-
return -1;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
console.log(`[asyncExecutor_executeBar] a: ${input.a}, b: ${input.b}`);
|
|
24
|
-
// await new Promise((r) => setTimeout(r, 2000));
|
|
25
|
-
return input.a + input.b;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
interface IExecutorReduceInput {
|
|
29
|
-
a: number;
|
|
30
|
-
b: number;
|
|
31
|
-
}
|
|
32
|
-
const asyncExecutor_executeReduce = async (input: IExecutorReduceInput): Promise<number> => {
|
|
33
|
-
if(!input) {
|
|
34
|
-
console.log(`[asyncExecutor_executeMinus] Missing input`);
|
|
35
|
-
return -1;
|
|
36
|
-
}
|
|
37
|
-
console.log(`[asyncExecutor_executeMinus] a: ${input.a}, b: ${input.b}`);
|
|
38
|
-
// await new Promise((r) => setTimeout(r, 2000));
|
|
39
|
-
return input.a - input.b;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const executorFoo: ITaskExecutor = {
|
|
43
|
-
id: "com.welcometerra.video.ffmpeg",
|
|
44
|
-
description: "Process ffmpeg videos",
|
|
45
|
-
// TODO: In future it should be isomorphic-like: should work on frontend if provided, on backend if provided (with CLI flow overview), or isomorphic if nothing provide
|
|
46
|
-
environment: EExecutingEnvironment.BACKEND,
|
|
47
|
-
reference: {
|
|
48
|
-
method: asyncExecutor_executeFoo,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const executorCombine: ITaskExecutor = {
|
|
53
|
-
id: "com.welcometerra.video.ffmpeg-combine",
|
|
54
|
-
description: "Combine ffmpeg videos",
|
|
55
|
-
// TODO: In future it should be isomorphic-like: should work on frontend if provided, on backend if provided (with CLI flow overview), or isomorphic if nothing provide
|
|
56
|
-
environment: EExecutingEnvironment.BACKEND,
|
|
57
|
-
reference: {
|
|
58
|
-
method: asyncExecutor_executeCombine,
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const executorReduce: ITaskExecutor = {
|
|
63
|
-
id: "colabo.flow.demo.reduce",
|
|
64
|
-
description: "It demos colabo flow tasks",
|
|
65
|
-
// TODO: In future it should be isomorphic-like: should work on frontend if provided, on backend if provided (with CLI flow overview), or isomorphic if nothing provide
|
|
66
|
-
environment: EExecutingEnvironment.BACKEND,
|
|
67
|
-
reference: {
|
|
68
|
-
method: asyncExecutor_executeReduce,
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const taskFoo: IFlowTask = {
|
|
73
|
-
id: "com.welcometerra.video.ffmpeg",
|
|
74
|
-
type: EFlowTaskType.SCRIPT,
|
|
75
|
-
executorRef: {
|
|
76
|
-
environment: EExecutingEnvironment.BACKEND,
|
|
77
|
-
id: executorFoo.id,
|
|
78
|
-
},
|
|
79
|
-
placeType: EFlowPlaceType.TASK,
|
|
80
|
-
inputs: [],
|
|
81
|
-
outputs: [],
|
|
82
|
-
inoutputs: [],
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const taskCombine: IFlowTask = {
|
|
86
|
-
id: "com.welcometerra.video.ffmpeg-combine",
|
|
87
|
-
type: EFlowTaskType.SCRIPT,
|
|
88
|
-
executorRef: {
|
|
89
|
-
environment: EExecutingEnvironment.BACKEND,
|
|
90
|
-
id: executorCombine.id,
|
|
91
|
-
},
|
|
92
|
-
placeType: EFlowPlaceType.TASK,
|
|
93
|
-
inputs: [],
|
|
94
|
-
outputs: [],
|
|
95
|
-
inoutputs: [],
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const taskReduce: IFlowTask = {
|
|
99
|
-
id: "colabo.flow.demo.reduce",
|
|
100
|
-
type: EFlowTaskType.SCRIPT,
|
|
101
|
-
executorRef: {
|
|
102
|
-
environment: EExecutingEnvironment.BACKEND,
|
|
103
|
-
id: executorReduce.id,
|
|
104
|
-
},
|
|
105
|
-
placeType: EFlowPlaceType.TASK,
|
|
106
|
-
inputs: [],
|
|
107
|
-
outputs: [],
|
|
108
|
-
inoutputs: [],
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const hostNode1: IColaboFlowHostData = {
|
|
112
|
-
hostname: "host-node-1",
|
|
113
|
-
amqpUrl: connectConfig.AMQP_URL,
|
|
114
|
-
queueHost: connectConfig.HOST_NODE_QUEUE,
|
|
115
|
-
queueHostHeartbeat: connectConfig.HOST_HEARTBEAT_QUEUE,
|
|
116
|
-
|
|
117
|
-
chHostHeartbeat: undefined,
|
|
118
|
-
|
|
119
|
-
taskExecutorsAvailable: {},
|
|
120
|
-
tasksAvailable: {},
|
|
121
|
-
taskInstances: {},
|
|
122
|
-
runningTaskInstancesInfos: {},
|
|
123
|
-
finalizedTaskInstancesInfos: {},
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
hostSetTitles(hostNode1);
|
|
127
|
-
|
|
128
|
-
hostRegisterTaskExecutor(hostNode1, executorFoo);
|
|
129
|
-
hostRegisterTaskExecutor(hostNode1, executorCombine);
|
|
130
|
-
hostRegisterTaskExecutor(hostNode1, executorReduce);
|
|
131
|
-
|
|
132
|
-
hostRegisterTask(hostNode1, taskFoo);
|
|
133
|
-
hostRegisterTask(hostNode1, taskCombine);
|
|
134
|
-
hostRegisterTask(hostNode1, taskReduce);
|
|
135
|
-
|
|
136
|
-
hostRun(hostNode1);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# NOTE: not working yet
|
|
2
|
-
# https://pypi.org/project/pika/
|
|
3
|
-
import pika
|
|
4
|
-
|
|
5
|
-
amqp_server = "localhost"
|
|
6
|
-
queue_name = "test"
|
|
7
|
-
|
|
8
|
-
parameters = (
|
|
9
|
-
pika.ConnectionParameters(
|
|
10
|
-
host=amqp_server,
|
|
11
|
-
connection_attempts=5,
|
|
12
|
-
retry_delay=1
|
|
13
|
-
)
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
print(f"Connecting to server: {amqp_server}")
|
|
17
|
-
connection = pika.BlockingConnection()
|
|
18
|
-
|
|
19
|
-
channel = connection.channel()
|
|
20
|
-
|
|
21
|
-
msg = b'Test message.'
|
|
22
|
-
print(f'Sending message to the queue "{amqp_server}": {msg}')
|
|
23
|
-
channel.basic_publish(exchange=queue_name, routing_key=queue_name,
|
|
24
|
-
body=msg)
|
|
25
|
-
|
|
26
|
-
connection.close()
|
package/demo/send-simple.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# https://pypi.org/project/pika/
|
|
3
|
-
import pika
|
|
4
|
-
import json
|
|
5
|
-
|
|
6
|
-
amqp_server = "localhost"
|
|
7
|
-
ORCHESTRATOR_QUEUE = "colabo.flow.orchestrator"
|
|
8
|
-
|
|
9
|
-
import pika
|
|
10
|
-
# import time
|
|
11
|
-
|
|
12
|
-
# https://pypi.org/project/setproctitle/
|
|
13
|
-
# https://github.com/dvarrazzo/py-setproctitle
|
|
14
|
-
# https://stackoverflow.com/a/1866700/257561
|
|
15
|
-
from setproctitle import setproctitle
|
|
16
|
-
proc_title = "ColaboFlow.Go.Orchestrator-Python-sending-example"
|
|
17
|
-
setproctitle(proc_title)
|
|
18
|
-
|
|
19
|
-
appNameText = f'[{chalk.red.bold("Colabo")}{chalk.blue.bold("Flow")}{chalk.green.bold(".Go")}{chalk.green.yellow(".Client-Python")}]';
|
|
20
|
-
|
|
21
|
-
parameters = (
|
|
22
|
-
pika.ConnectionParameters(
|
|
23
|
-
host=amqp_server,
|
|
24
|
-
port=5672,
|
|
25
|
-
connection_attempts=5,
|
|
26
|
-
retry_delay=1
|
|
27
|
-
)
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
print(f"{appNameText} Connecting to the server: {amqp_server}");
|
|
31
|
-
connection = pika.BlockingConnection(pika.ConnectionParameters(host=amqp_server))
|
|
32
|
-
|
|
33
|
-
queue = ORCHESTRATOR_QUEUE
|
|
34
|
-
channel = connection.channel()
|
|
35
|
-
# https://github.com/MassTransit/MassTransit/issues/370
|
|
36
|
-
channel.queue_declare(queue=ORCHESTRATOR_QUEUE, durable=True, exclusive=False, auto_delete=False)
|
|
37
|
-
msg = {
|
|
38
|
-
"client": "send-simple.py",
|
|
39
|
-
"type": "string",
|
|
40
|
-
"msg": "sudo: make me a pie",
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
print(f'{appNameText} Sending [queue: "{chalk.blue_bright(queue)}"]: {json.dumps(msg)}');
|
|
44
|
-
channel.basic_publish(exchange='', routing_key=queue, body=json.dumps(msg))
|
|
45
|
-
|
|
46
|
-
print(f" [x] Sent {msg}")
|
|
47
|
-
|
|
48
|
-
connection.close()
|
|
49
|
-
|
|
50
|
-
# time.sleep(10) # Sleep for 10 seconds
|