@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,168 @@
1
+ # -*- coding: utf-8 -*-
2
+ #!/usr/bin/python
3
+
4
+ from __future__ import print_function
5
+
6
+ import random
7
+
8
+ from datetime import datetime
9
+ # import dateutil.parser
10
+
11
+ class ColaboFlowGoDemo():
12
+ goRequestDefault = None
13
+ stubDefault = None
14
+
15
+ def __init__(self, flowName="basic-flow"):
16
+
17
+ print("[ColaboFlowGoDemo] new flow created: %s" % (flowName))
18
+ self.flow = []
19
+ self.flowPointer = 0
20
+
21
+ # ---------------------------------------------------------------------------------------
22
+ # NOTE: SEQUENTIAL DATA FLOW: In this scenario, user can describe control flow order,
23
+ # but the data flow HAS to follow the same control-flow
24
+ # (so data output of action `i` is the input for the action `i+1`)
25
+ # ---------------------------------------------------------------------------------------
26
+
27
+ # Add action in a sequence with
28
+ # - action name and
29
+ # = reference to the function implementing it
30
+ def addActionAsFunction(self, funcRef, actionName):
31
+ action = {
32
+ 'name': actionName,
33
+ 'funcRef': funcRef
34
+ }
35
+ self.flow.append(action)
36
+ # print(len(self.flow))
37
+ return self
38
+
39
+ # runs functions in a sequence
40
+ # data input for the function `i+1` is data output of the function `i`
41
+ def runWithSequentialDataFlow(self, dataIn):
42
+ print("---")
43
+ for action in self.flow:
44
+ print("running action: ", action['name'])
45
+ func = action['funcRef']
46
+ result = func(dataIn)
47
+ print("result: ", result)
48
+ dataIn = result
49
+ print("---")
50
+
51
+ # ---------------------------------------------------------------------------------------
52
+ # NOTE: DESCRIPTIVE_DATA_FLOW: In this way data flow doesn't need to follow control flow
53
+ # but it can be described separtelly
54
+ # ---------------------------------------------------------------------------------------
55
+
56
+ # Add action in a sequence with
57
+ # - action name
58
+ # - reference to the function implementing it
59
+ # - inputParameterName name that holds the input parameter
60
+ def addActionAsFunctionWithInputParam(self, funcRef, actionName, inputParameterName=None):
61
+ action = {
62
+ 'name': actionName,
63
+ 'funcRef': funcRef,
64
+ 'inputParameterName': inputParameterName
65
+ }
66
+ self.flow.append(action)
67
+ # print(len(self.flow))
68
+ return self
69
+
70
+ def runWithDescriptiveDataFlow(self, dataName, dataIn):
71
+ print("---")
72
+ self.results = {}
73
+ self.results[dataName] = dataIn
74
+ for action in self.flow:
75
+ # print("running action: ", action)
76
+ print("running action: ", action['name'])
77
+ func = action['funcRef']
78
+ inputParameterName = action['inputParameterName']
79
+ result = func(self.results[inputParameterName])
80
+ self.results[action['name']] = result
81
+ print("result: ", result)
82
+ print("---")
83
+
84
+ # ---------------------------------------------------------------------------------------
85
+ # NOTE: DESCRIPTIVE_MULTIDATA_FLOW: data flow doesn't follow control flow
86
+ # and it can have multiple input datasets
87
+ # ---------------------------------------------------------------------------------------
88
+
89
+ # Add action in a sequence with
90
+ # - action name
91
+ # - reference to the function implementing it
92
+ # - inputParameterNames - list of names that hold input parameters
93
+ def addActionAsFunctionWithInputParams(self, funcRef, actionName, inputParameterNames=None):
94
+ action = {
95
+ 'name': actionName,
96
+ 'funcRef': funcRef,
97
+ 'inputParameterNames': inputParameterNames
98
+ }
99
+ self.flow.append(action)
100
+ # print(len(self.flow))
101
+ return self
102
+
103
+ def runWithDescriptiveMultiDataFlow(self, dataName, dataIn):
104
+ print("---")
105
+ self.results = {}
106
+ self.results[dataName] = dataIn
107
+ for action in self.flow:
108
+ # print("running action: ", action)
109
+ print("running action: ", action['name'])
110
+ func = action['funcRef']
111
+ inputParameterNames = action['inputParameterNames']
112
+ inputParameters = []
113
+ for inputParameterName in inputParameterNames:
114
+ inputParameters.append(self.results[inputParameterName])
115
+ result = func(*inputParameters)
116
+ self.results[action['name']] = result
117
+ print("result: ", result)
118
+ print("---")
119
+
120
+ # ---------------------------------------------------------------------------------------
121
+ # NOTE: DESCRIPTIVE_MULTIDATAOUTPUT_FLOW: output data flow can have multiple datasets
122
+ # each with its own name
123
+ # ---------------------------------------------------------------------------------------
124
+
125
+ # Add action in a sequence with
126
+ # - action name
127
+ # - reference to the function implementing it
128
+ # - inputParameterNames - list of names that hold input parameters
129
+ def addActionAsFunctionWithOutputParams(self, funcRef, actionName, inputParameterNames=None, outputParameterNames=None):
130
+ action = {
131
+ 'name': actionName,
132
+ 'funcRef': funcRef,
133
+ 'inputParameterNames': inputParameterNames,
134
+ 'outputParameterNames': outputParameterNames
135
+ }
136
+ self.flow.append(action)
137
+ # print(len(self.flow))
138
+ return self
139
+
140
+ def runWithDescriptiveOutDataFlow(self, dataName, dataIn):
141
+ print("---")
142
+ self.results = {}
143
+ self.results[dataName] = dataIn
144
+ for action in self.flow:
145
+ # print("running action: ", action)
146
+ print("running action: ", action['name'])
147
+ func = action['funcRef']
148
+ inputParameterNames = action['inputParameterNames']
149
+ inputParameters = []
150
+ for inputParameterName in inputParameterNames:
151
+ inputParameters.append(self.results[inputParameterName])
152
+ outputParameterNames = action['outputParameterNames']
153
+ result = func(*inputParameters)
154
+ if outputParameterNames != None and len(outputParameterNames)>1:
155
+ results = result
156
+ print("results: ", results)
157
+ if(len(outputParameterNames) != len(results)):
158
+ print("Expected number of parameters: %s, but got %s instead" %
159
+ (len(outputParameterNames), len(results)))
160
+ for i in range(len(outputParameterNames)):
161
+ outputParameterName = outputParameterNames[i]
162
+ result = results[i]
163
+ self.results[outputParameterName] = result
164
+ print("result[%s]: %s" % (i, result))
165
+ else:
166
+ print("result: ", result)
167
+ self.results[action['name']] = result
168
+ print("---")