@colabo-flow/s-go 0.1.2

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.
Files changed (106) hide show
  1. package/DEVELOPMENT.md +38 -0
  2. package/README.md +110 -0
  3. package/__init__.py +0 -0
  4. package/__pycache__/__init__.cpython-39.pyc +0 -0
  5. package/create_client.py +84 -0
  6. package/create_host.py +91 -0
  7. package/create_host_terra.py +103 -0
  8. package/demo/__init__.py +0 -0
  9. package/demo/create-client.ts +51 -0
  10. package/demo/create-host.ts +136 -0
  11. package/demo/send-simple-recommended.py +26 -0
  12. package/demo/send-simple.py +50 -0
  13. package/demo/send.py +352 -0
  14. package/demo/send.ts +40 -0
  15. package/demo/threading/README.md +14 -0
  16. package/demo/threading/basic_consumer_connection_threaded.png +0 -0
  17. package/demo/threading/basic_consumer_connection_threaded.py +135 -0
  18. package/demo/threading/basic_consumer_threaded.py +100 -0
  19. package/demo/threading/long-running-publisher.py +68 -0
  20. package/docs/ColaboFlow-infrastructure-diagram.png +0 -0
  21. package/docs/workflow.md +35 -0
  22. package/index.ts +4 -0
  23. package/jest.config.ts +172 -0
  24. package/lib/__init__.py +0 -0
  25. package/lib/__pycache__/__init__.cpython-39.pyc +0 -0
  26. package/lib/__pycache__/config.cpython-39.pyc +0 -0
  27. package/lib/__pycache__/executor_operators.cpython-39.pyc +0 -0
  28. package/lib/__pycache__/executor_vos.cpython-39.pyc +0 -0
  29. package/lib/__pycache__/go_amqp_client.cpython-39.pyc +0 -0
  30. package/lib/__pycache__/go_amqp_client_threaded.cpython-39.pyc +0 -0
  31. package/lib/__pycache__/go_amqp_host.cpython-39.pyc +0 -0
  32. package/lib/__pycache__/operators.cpython-39.pyc +0 -0
  33. package/lib/__pycache__/vos.cpython-39.pyc +0 -0
  34. package/lib/config.py +21 -0
  35. package/lib/config.ts +22 -0
  36. package/lib/executor_operators.py +23 -0
  37. package/lib/executor_vos.py +318 -0
  38. package/lib/go.amqp.client-old-basic.py +50 -0
  39. package/lib/go.amqp.client.ts +100 -0
  40. package/lib/go.amqp.host-old-basic.py +48 -0
  41. package/lib/go.amqp.host.ts +269 -0
  42. package/lib/go.amqp.host_status.ts +81 -0
  43. package/lib/go.amqp.service.ts +272 -0
  44. package/lib/go_amqp_client.py +263 -0
  45. package/lib/go_amqp_client_non_threaded.py +152 -0
  46. package/lib/go_amqp_host.py +348 -0
  47. package/lib/operators.py +16 -0
  48. package/lib/operators.ts +17 -0
  49. package/lib/params.ts +1 -0
  50. package/lib/vos.py +232 -0
  51. package/lib/vos.ts +212 -0
  52. package/package.json +36 -0
  53. package/requirements.txt +4 -0
  54. package/tests/units/README.md +12 -0
  55. package/tests/units/chalk/index.ts +41 -0
  56. package/tests/units/go.amqp.host.test.ts +116 -0
  57. package/tests/units/tests-vos/tasks-and-flows.vos.ts +128 -0
  58. package/tsconfig.json +45 -0
  59. package/v1 - GRPC/README.md +18 -0
  60. package/v1 - GRPC/node/README.md +13 -0
  61. package/v1 - GRPC/node/colaboflow_go_actionhost_client.ts +91 -0
  62. package/v1 - GRPC/node/colaboflow_go_actionhost_server.ts +84 -0
  63. package/v1 - GRPC/node/colaboflow_go_client.ts +82 -0
  64. package/v1 - GRPC/node/colaboflow_go_server.ts +84 -0
  65. package/v1 - GRPC/node/demos/demo-colaboflow_go_actionhost_client.ts +21 -0
  66. package/v1 - GRPC/node/index.ts +3 -0
  67. package/v1 - GRPC/node/package-lock.json +770 -0
  68. package/v1 - GRPC/node/package.json +30 -0
  69. package/v1 - GRPC/node/tsconfig.json +32 -0
  70. package/v1 - GRPC/node/yarn.lock +642 -0
  71. package/v1 - GRPC/protos/colabo/flow/go/go.proto +135 -0
  72. package/v1 - GRPC/python/DEVELOPMENT.md +86 -0
  73. package/v1 - GRPC/python/DISCUSSION.md +8 -0
  74. package/v1 - GRPC/python/LICENSE.txt +21 -0
  75. package/v1 - GRPC/python/README.md +45 -0
  76. package/v1 - GRPC/python/__init__.py +1 -0
  77. package/v1 - GRPC/python/colabo/__init__.py +3 -0
  78. package/v1 - GRPC/python/colabo/flow/__init__.py +3 -0
  79. package/v1 - GRPC/python/colabo/flow/go/__init__.py +12 -0
  80. package/v1 - GRPC/python/colabo/flow/go/basic/PuzzleImporter.py +77 -0
  81. package/v1 - GRPC/python/colabo/flow/go/basic/__init__.py +5 -0
  82. package/v1 - GRPC/python/colabo/flow/go/basic/colaboflow_go_basic.py +66 -0
  83. package/v1 - GRPC/python/colabo/flow/go/basic/parseFlowJSON.py +32 -0
  84. package/v1 - GRPC/python/colabo/flow/go/colaboflow_go_actionhost.py +44 -0
  85. package/v1 - GRPC/python/colabo/flow/go/colaboflow_go_client.py +48 -0
  86. package/v1 - GRPC/python/colabo/flow/go/colaboflow_go_demo.py +168 -0
  87. package/v1 - GRPC/python/colabo/flow/go/go_pb2.py +976 -0
  88. package/v1 - GRPC/python/colabo/flow/go/go_pb2_grpc.py +139 -0
  89. package/v1 - GRPC/python/colabo.flow.go.egg-info/PKG-INFO +58 -0
  90. package/v1 - GRPC/python/colabo.flow.go.egg-info/SOURCES.txt +16 -0
  91. package/v1 - GRPC/python/colabo.flow.go.egg-info/dependency_links.txt +1 -0
  92. package/v1 - GRPC/python/colabo.flow.go.egg-info/requires.txt +3 -0
  93. package/v1 - GRPC/python/colabo.flow.go.egg-info/top_level.txt +2 -0
  94. package/v1 - GRPC/python/demo-0.py +69 -0
  95. package/v1 - GRPC/python/demo-1.py +146 -0
  96. package/v1 - GRPC/python/demo-actionhost.py +47 -0
  97. package/v1 - GRPC/python/demo-basic.md +13 -0
  98. package/v1 - GRPC/python/demo-basic.py +38 -0
  99. package/v1 - GRPC/python/demo-executeActionSync.py +32 -0
  100. package/v1 - GRPC/python/demo-flows/flow-demo.json +36 -0
  101. package/v1 - GRPC/python/demo-puzzles/puzzles/puzzle-a.py +19 -0
  102. package/v1 - GRPC/python/demo-puzzles/puzzles/puzzle-b.py +21 -0
  103. package/v1 - GRPC/python/demo-puzzles/puzzles/puzzle-c.py +20 -0
  104. package/v1 - GRPC/python/requirements.txt +7 -0
  105. package/v1 - GRPC/python/setup.py +39 -0
  106. package/v1 - GRPC/python/use-cases/__init__.py +0 -0
@@ -0,0 +1,100 @@
1
+ import functools
2
+ import logging
3
+ import pika
4
+ import threading
5
+ import time
6
+ from yachalk import chalk
7
+
8
+ # LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
9
+ # '-35s %(lineno) -5d: %(message)s')
10
+ # LOGGER = logging.getLogger(__name__)
11
+
12
+ # logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
13
+
14
+ publisherName = "demo"
15
+ def appNameTextWithContext(context: str) -> str:
16
+ threadId = threading.get_native_id()
17
+ thread_id = threading.get_ident()
18
+ return f'[[{chalk.blue.bold(threadId)}:{chalk.blue.bold(thread_id)}]{chalk.red.bold("Colabo")}{chalk.blue.bold("Flow")}{chalk.green.bold(".Go")}.{chalk.white.bold(publisherName)}:{chalk.yellow.bold(context)}]';
19
+
20
+ def ack_message(channel, delivery_tag):
21
+ print(f"{appNameTextWithContext('ack_message')}")
22
+ """Note that `channel` must be the same pika channel instance via which
23
+ the message being ACKed was retrieved (AMQP protocol constraint).
24
+ """
25
+ if channel.is_open:
26
+ channel.basic_ack(delivery_tag)
27
+ else:
28
+ # Channel is already closed, so we can't ACK this message;
29
+ # log and/or do something that makes sense for your app in this case.
30
+ pass
31
+
32
+ def do_work(connection, channel, delivery_tag, body):
33
+ print(f"{appNameTextWithContext('do_work')} starting ... ")
34
+ thread_id = threading.get_ident()
35
+ fmt1 = 'Thread id: {} Delivery tag: {} Message body: {}'
36
+ # LOGGER.info(fmt1.format(thread_id, delivery_tag, body))
37
+ # Sleeping to simulate 10 seconds of work
38
+ time.sleep(10)
39
+ print(f"{appNameTextWithContext('do_work')} done, acknowledging ... ")
40
+ cb = functools.partial(ack_message, channel, delivery_tag)
41
+ connection.add_callback_threadsafe(cb)
42
+
43
+ def on_message(channel, method_frame, header_frame, body, args):
44
+ print(f"{appNameTextWithContext('on_message')}")
45
+ (connection, threads) = args
46
+ delivery_tag = method_frame.delivery_tag
47
+ t = threading.Thread(target=do_work, args=(connection, channel, delivery_tag, body))
48
+ t.start()
49
+ threads.append(t)
50
+
51
+ # https://docs.python.org/3/library/threading.html#threading.Thread
52
+ threads: list[threading.Thread] = []
53
+
54
+ def connect():
55
+ global connection, channel
56
+
57
+ print(f"{appNameTextWithContext('connect')} connecting ...")
58
+
59
+ credentials = pika.PlainCredentials('guest', 'guest')
60
+ # Note: sending a short heartbeat to prove that heartbeats are still
61
+ # sent even though the worker simulates long-running work
62
+ parameters = pika.ConnectionParameters('localhost', credentials=credentials, heartbeat=5)
63
+ connection = pika.BlockingConnection(parameters)
64
+
65
+ channel = connection.channel()
66
+ channel.exchange_declare(exchange="test_exchange", exchange_type="direct", passive=False, durable=True, auto_delete=False)
67
+ channel.queue_declare(queue="standard", auto_delete=True)
68
+ channel.queue_bind(queue="standard", exchange="test_exchange", routing_key="standard_key")
69
+
70
+ # Note: prefetch is set to 1 here as an example only and to keep the number of threads created
71
+ # to a reasonable amount. In production you will want to test with different prefetch values
72
+ # to find which one provides the best performance and usability for your solution
73
+ # channel.basic_qos(prefetch_count=1)
74
+ channel.basic_qos(prefetch_count=2)
75
+ print(f"{appNameTextWithContext('connect')} connected")
76
+
77
+ on_message_callback = functools.partial(on_message, args=(connection, threads))
78
+ channel.basic_consume(on_message_callback=on_message_callback, queue='standard')
79
+
80
+ def start_consuming():
81
+ try:
82
+ print(f"{appNameTextWithContext('start_consuming')} start_consuming")
83
+ channel.start_consuming()
84
+ except KeyboardInterrupt:
85
+ print(f"{appNameTextWithContext('start_consuming')} keyboard interrupt, stop_consuming")
86
+ channel.stop_consuming()
87
+ print(f"{appNameTextWithContext('start_consuming')} finished")
88
+
89
+ connect()
90
+ start_consuming()
91
+
92
+ print(f"{appNameTextWithContext('main')} waiting for threads to finish processing")
93
+
94
+ # Wait for all to complete
95
+ for thread in threads:
96
+ print(f"{appNameTextWithContext('main')} waiting for thread '{thread.name} ('{thread.native_id}') to finish processing")
97
+ thread.join()
98
+ print(f"{appNameTextWithContext('main')} all threads finished processing")
99
+
100
+ connection.close()
@@ -0,0 +1,68 @@
1
+ # -*- coding: utf-8 -*-
2
+ # pylint: disable=C0111,C0103,R0205
3
+
4
+ import threading
5
+ from time import sleep
6
+ from pika import ConnectionParameters, BlockingConnection, PlainCredentials
7
+ from yachalk import chalk
8
+
9
+ clientName = "demo"
10
+ def appNameTextWithContext(context: str) -> str:
11
+ threadId = threading.get_native_id()
12
+ return f'[[{chalk.blue.bold(threadId)}]{chalk.red.bold("Colabo")}{chalk.blue.bold("Flow")}{chalk.green.bold(".Go")}.{chalk.white.bold(clientName)}:{chalk.yellow.bold(context)}]';
13
+
14
+ class Publisher(threading.Thread):
15
+ def __init__(self, *args, **kwargs):
16
+ super().__init__(*args, **kwargs)
17
+ print(f"{appNameTextWithContext('__init__')} Initializing ...")
18
+ self.daemon = True
19
+ self.is_running = True
20
+ self.name = "Publisher"
21
+ self.queue = "downstream_queue"
22
+
23
+ credentials = PlainCredentials("guest", "guest")
24
+ parameters = ConnectionParameters("localhost", credentials=credentials)
25
+ self.connection = BlockingConnection(parameters)
26
+ self.channel = self.connection.channel()
27
+ self.channel.queue_declare(queue=self.queue, auto_delete=True)
28
+
29
+ def run(self):
30
+ print(f"{appNameTextWithContext('run')} run")
31
+ while self.is_running:
32
+ print(f"{appNameTextWithContext('run')} run loop")
33
+ self.connection.process_data_events(time_limit=1)
34
+
35
+ def _publish(self, message):
36
+ print(f"{appNameTextWithContext('_publish')} publishing message: {message}")
37
+ self.channel.basic_publish("", self.queue, body=message.encode())
38
+
39
+ def publish(self, message):
40
+ print(f"{appNameTextWithContext('publish')} publishing message to connection-thread: {message}")
41
+ self.connection.add_callback_threadsafe(lambda: self._publish(message))
42
+
43
+ def stop(self):
44
+ print(f"{appNameTextWithContext('stop')} stopping")
45
+ print("Stopping...")
46
+ self.is_running = False
47
+ # Wait until all the data events have been processed
48
+ self.connection.process_data_events(time_limit=1)
49
+ if self.connection.is_open:
50
+ self.connection.close()
51
+ print("Stopped")
52
+
53
+ if __name__ == "__main__":
54
+ print(f"{appNameTextWithContext('__main__')} starting")
55
+ publisher = Publisher()
56
+ publisher.start()
57
+ try:
58
+ for i in range(9999):
59
+ msg = f"Message {i}"
60
+ print(f"{appNameTextWithContext('__main__')} Publishing: {msg!r}")
61
+ publisher.publish(msg)
62
+ sleep(1)
63
+ except KeyboardInterrupt:
64
+ print(f"{appNameTextWithContext('__main__')} KeyboardInterrupt")
65
+ publisher.stop()
66
+ finally:
67
+ print(f"{appNameTextWithContext('__main__')} waiting for the thread to finish")
68
+ publisher.join()
@@ -0,0 +1,35 @@
1
+ # Components
2
+
3
+ Note: for more info on the entities, please check the [Concepts Explanation](/colabo/src/isomorphic/dev_puzzles/flow/core/README.md#Concepts-Explanation) section.
4
+
5
+ ## Clients
6
+
7
+ `go.amqp.client` - asks from the ColaboFlow service to perform a task
8
+ + we currently have support of 2 client types; `node` and `python`
9
+
10
+ ## Hosts
11
+
12
+ + `go.amqp.host` - offers task executors to the rest of the ColaboFlow infrastructure
13
+ + we currently have support of 2 host types; `node` and `python`
14
+
15
+ ## Service
16
+
17
+ + `go.amqp.service` - listens to the clients' requests for the task execution and route them to the proper hosts to be delivered on the task executors.
18
+
19
+ ## Service
20
+
21
+ # Workflow
22
+
23
+ ![ColaboFlow infrastructure - diagram](./ColaboFlow-infrastructure-diagram.png)
24
+
25
+ Service (as a listener) creates a `HOST_HEARTBEAT_QUEUE` queue that accepts info and heartbeats from the active hosts.
26
+
27
+ Host (as a listener) creates a queue (something in a form of `colabo.flow.host.*`, like `colabo.flow.host.node` or `colabo.flow.host.python`) that accepts requests from the service on task execution, etc.
28
+
29
+ ## Task Execution
30
+
31
+ A client sends a `task execution request` message and sends it to the service. The message contains a `replyTo` queue that makes RPC possible. The service will reply any task execution (task instance) related notification (succeeded, failed, progress, ...) back to the client vie the `replyTo` queue.
32
+
33
+ When service receives the `task execution request` message it has to identify what is the colabo host that should handle the task based on the task executor id, current hosts' load and the load balancing algorithm. After that it will store all relevant info about the task request in its internal data state and create another (service "originated") `task execution request` message addressed to the chosen ColaboFlow.Go host expected to execute the task. That message will also contain a `replyTo` queue that makes RPC possible but in this case a ColaboFlow.Go service related to make service as a proxy on the response.
34
+
35
+ Finally, ColaboFlow.Go host will receive the `task execution request` message and resolve the task executer and provide it with the task instance to be executed. Upon the task is finalized (either succeeded or failed) its result is returned back to the service via the service's `replyTo` queue. Eventually, the progress will be also possible to return back to the service.
package/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./lib/go.amqp.client";
2
+ // export * from "./lib/go.amqp.service";
3
+ export * from "./lib/go.amqp.host";
4
+ export * from "./lib/vos";
package/jest.config.ts ADDED
@@ -0,0 +1,172 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ /* eslint-disable no-undef */
3
+ // load (as JSON5) `tsconfig.colabo.json`
4
+ import fs from "fs";
5
+
6
+ import JSON5 from "json5";
7
+
8
+ import type { Config } from 'jest';
9
+ import { defaults } from 'jest-config';
10
+
11
+ import { pathsToModuleNameMapper } from "ts-jest";
12
+
13
+ // ESM workaround for the missing `__dirname`:
14
+ import path from "path";
15
+ // it doesn't work: https://github.com/facebook/jest/issues/11453#issuecomment-1312747709
16
+ // import { fileURLToPath } from "url";
17
+ // const __filename = fileURLToPath(import.meta.url);
18
+ // const __dirname = path.dirname(__filename);
19
+
20
+ const {
21
+ paths,
22
+ tsconfigFolder
23
+ } = loadPaths("./", "tsconfig.json");
24
+ const tsconfigFolderAbsolute = path.resolve(tsconfigFolder);
25
+ /** loads paths from tsconfig. It follows all `extends` references
26
+ * it returns the first one found (where the bottom, the deepest one has priority over higher, shallower)
27
+ * The reason for this "inversion" is that the bottom one is usually `tsconfig.colabo.json` that has all paths
28
+ * and any higher might have wrong and missing
29
+ * TODO: we can make possibility to merge them, but that can have its own issues, though smart to do
30
+ */
31
+ function loadPaths(tsconfigFolder, tsconfigFile) {
32
+ const tsconfigStr = fs.readFileSync(tsconfigFolder + tsconfigFile, "utf8");
33
+ const {
34
+ extends: extendsPath,
35
+ compilerOptions
36
+ } = JSON5.parse(tsconfigStr);
37
+ if (extendsPath) {
38
+ const tsconfigExtended = tsconfigFolder + extendsPath;
39
+ const tsconfigFolderNext = path.dirname(tsconfigExtended) + "/";
40
+ const tsconfigFile = path.basename(tsconfigExtended);
41
+ const paths = loadPaths(tsconfigFolderNext, tsconfigFile);
42
+
43
+ if (paths) return {
44
+ paths,
45
+ tsconfigFolder: tsconfigFolderNext
46
+ };
47
+ else return {
48
+ paths: compilerOptions.paths,
49
+ tsconfigFolder
50
+ };
51
+ } else {
52
+ return compilerOptions.paths;
53
+ }
54
+ }
55
+
56
+ console.log("paths: ", JSON.stringify(paths, null, 4));
57
+ // https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring
58
+ let moduleNameMapper = pathsToModuleNameMapper(paths, {
59
+ prefix: ""
60
+ });
61
+ if (!moduleNameMapper) {
62
+ console.error(`[jest.config.ts] moduleNameMapper is not defined`);
63
+ process.exit(1);
64
+ }
65
+
66
+ console.log("moduleNameMapper BEFORE: ", JSON.stringify(moduleNameMapper, null, 4));
67
+ // we need it because deep imports like this
68
+ // `import DatatalksChooseTargetNodesComponent from "@colabo-datatalks/f-form/lib/choose-target-nodes/datatalks-choose-target-nodes-component.vue";`
69
+ // which are necessary because vue makes problem importing `*.vue` files from `index.ts` barrels
70
+ for (const key in moduleNameMapper) {
71
+ if (key.endsWith("(.*)$")) continue;
72
+ if (Array.isArray(moduleNameMapper[key])) {
73
+ moduleNameMapper[key.substr(0, key.length - 1) + "/(.*)$"] = [moduleNameMapper[key][0] + "/$1"];
74
+ } else {
75
+ moduleNameMapper[key.substr(0, key.length - 1) + "/(.*)$"] = moduleNameMapper[key] + "/$1";
76
+ }
77
+ }
78
+
79
+ import {
80
+ resolve
81
+ } from "path";
82
+
83
+ // `__dirname` fails due to the `import.meta.url` error
84
+ // probably due to the workaround: https://github.com/facebook/jest/issues/11453#issuecomment-877653950
85
+ // const resolvePath = resolve(__dirname, "./node_modules/$1");
86
+ const resolvePath = resolve("./node_modules/$1");
87
+ console.log(`[jest.config.ts] resolvePath: ${resolvePath}`);
88
+
89
+ // https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring
90
+ delete moduleNameMapper["^(.*)$"];
91
+
92
+ // we cannot use this one because it excludes mappings for asset extensions
93
+ // moduleNameMapper["^@/(.*)$"] = "<rootDir>/src/$1";
94
+ delete moduleNameMapper["^@/(.*)$"];
95
+ // moduleNameMapper["^@/(?!assets)(.*)$"] = "<rootDir>/src/$1";
96
+ // TODO: Necessary to mockup chalk as it breaks in the ESM module
97
+ moduleNameMapper["^chalk$"] = "<rootDir>/tests/units/chalk";
98
+
99
+ // const rootDirForNodeModules = "<rootDir>";
100
+ const rootDirForNodeModules = tsconfigFolderAbsolute;
101
+
102
+ moduleNameMapper = {
103
+ ...moduleNameMapper,
104
+
105
+ // // Support for Vue's `@` shortcut for the src root
106
+ // no need for it explicitly, as we have it in `paths` from tsconfig
107
+ // "^@/(.*)$": "<rootDir>/src/$1",
108
+
109
+ // Workaround for non-symbolic expansion in external puzzles
110
+ // in our case for: `import { ColaboMaterial } from "@colabo-headless/f-components-vue";`
111
+ // this is problem as JEST doesn't respect (preserve) symbolic sandbox
112
+ // "^vue$": `${rootDirForNodeModules}/node_modules/vue`,
113
+ // "^vue/(.*)$": `${rootDirForNodeModules}/node_modules/vue/$1`,
114
+
115
+ // https://jestjs.io/docs/webpack
116
+ // ["Syntax Error: Invalid or unexpected token" with .png #2663](https://github.com/facebook/jest/issues/2663)
117
+ "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
118
+ "\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js",
119
+ };
120
+
121
+ // console.log("__dirname: ", __dirname);
122
+ // console.log("resolvePath: ", resolvePath);
123
+ // console.log("moduleNameMapper: ", JSON.stringify(moduleNameMapper, null, 4));
124
+
125
+ console.log("moduleNameMapper AFTER: ", JSON.stringify(moduleNameMapper, null, 4));
126
+
127
+ // https://jestjs.io/docs/configuration
128
+ const config: Config = {
129
+ // not needed
130
+ // https://stephencharlesweiss.com/jest-configuring-for-typescript-and-esm
131
+ // globals: {
132
+ // "ts-jest": {
133
+ // useESM: true,
134
+ // },
135
+ // },
136
+ moduleFileExtensions: [
137
+ "js",
138
+ "ts",
139
+ "jsx",
140
+ "tsx",
141
+ "json",
142
+ // tell Jest to handle `*.vue` files
143
+ "vue",
144
+ ],
145
+ verbose: true,
146
+ moduleDirectories: ["node_modules", "<rootDir>"],
147
+ transform: {
148
+ // process `*.ts` and `*.tsx` files with `ts-jest`
149
+ "^.+\\.tsx?$": "ts-jest",
150
+ },
151
+ // testURL: "http://localhost/",
152
+ testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
153
+
154
+ moduleNameMapper,
155
+ };
156
+
157
+ export default config;
158
+
159
+ // not working for ESM projects
160
+ // module.exports = { /* ... */ };
161
+
162
+ // old version or vue suggested, but either not working well with Vue+Jest
163
+ // or we wanted to avoid babel
164
+ // module.exports = {
165
+ // preset: "@vue/cli-plugin-unit-jest/presets/typescript-and-babel",
166
+ // };
167
+
168
+ // version for isomorphic code, not working well with Vue+Jest
169
+ // module.exports = {
170
+ // preset: 'ts-jest',
171
+ // testEnvironment: 'node',
172
+ // };
File without changes
package/lib/config.py ADDED
@@ -0,0 +1,21 @@
1
+ from lib.vos import ReportsConfig, ConnectConfig
2
+
3
+ AMQP_URL = "localhost";
4
+ ORCHESTRATOR_QUEUE = "colabo.flow.orchestrator";
5
+ HOST_NODE_QUEUE = "colabo.flow.host.node";
6
+ HOST_PYTHON_QUEUE = "colabo.flow.host.python";
7
+ HOST_HEARTBEAT_QUEUE = "colabo.flow.host.heartbeat";
8
+
9
+ reportsConfig = ReportsConfig(
10
+ showHeartbeatMsgs = False,
11
+ showReportsMsgs = True,
12
+ showExecutionMsgs = True,
13
+ )
14
+
15
+ connectConfig = ConnectConfig(
16
+ APP_NAME="client-python",
17
+ AMQP_URL=AMQP_URL,
18
+ ORCHESTRATOR_QUEUE=ORCHESTRATOR_QUEUE,
19
+ HOST_HEARTBEAT_QUEUE=HOST_HEARTBEAT_QUEUE,
20
+ HOST_QUEUE=HOST_PYTHON_QUEUE
21
+ )
package/lib/config.ts ADDED
@@ -0,0 +1,22 @@
1
+ // const amqp = "amqp://guest:guest@localhost:5672//";
2
+ const amqp = "amqp://localhost";
3
+ const ORCHESTRATOR_QUEUE = "colabo.flow.orchestrator";
4
+ const HOST_NODE_QUEUE = "colabo.flow.host.node";
5
+ const HOST_PYTHON_QUEUE = "colabo.flow.host.python";
6
+ const HOST_HEARTBEAT_QUEUE = "colabo.flow.host.heartbeat";
7
+
8
+ export const reportsConfig = {
9
+ showHeartbeatMsgs: false,
10
+ showReportsMsgs: true,
11
+ showExecutionMsgs: true,
12
+ };
13
+
14
+ export const connectConfig = {
15
+ APP_NAME: "terra",
16
+ AMQP_URL: process.env.AMQP_URL || amqp,
17
+ // BROKER_URL: process.env.BROKER_URL || process.env.RABBIT_URL || amqp,
18
+ ORCHESTRATOR_QUEUE: process.env.ORCHESTRATOR_QUEUE || ORCHESTRATOR_QUEUE,
19
+ HOST_HEARTBEAT_QUEUE: process.env.HOST_HEARTBEAT_QUEUE || HOST_HEARTBEAT_QUEUE,
20
+ HOST_NODE_QUEUE: process.env.HOST_NODE_QUEUE || HOST_NODE_QUEUE,
21
+ HOST_PYTHON_QUEUE: process.env.HOST_PYTHON_QUEUE || HOST_PYTHON_QUEUE,
22
+ };
@@ -0,0 +1,23 @@
1
+ import uuid
2
+
3
+ from lib.executor_vos import EFlowPlaceType, IFlowTask, IFlowTaskInstance
4
+ """
5
+ Creates a task-instance of the provided task. The task instance will relate to its originating task through the `originId` prop
6
+
7
+ @param task the task we want to create the instance of
8
+ @returns the created task instance of the provided task
9
+ """
10
+ def createTaskInstanceForTaskWithoutFlow(task: IFlowTask)->IFlowTaskInstance:
11
+ taskInstance: IFlowTaskInstance = IFlowTaskInstance(
12
+ id = f'{task.id}:{uuid.uuid1()}',
13
+ originId = task.id,
14
+ placeType = EFlowPlaceType.TASK,
15
+ # TBD
16
+ # status = EFlowTaskExecutionStatus.WAITING,
17
+ # tokenStatus = ETokenStatusInFlowPlaceInstance.JUST_ENTERED,
18
+ # initiatedTokenIdsPerPorts = {},
19
+ # executionInputReferences = {},
20
+ # executionOutputReferences = {},
21
+ # currentTokenIds = [],
22
+ )
23
+ return taskInstance