@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,139 @@
1
+ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
+ import grpc
3
+
4
+ from colabo.flow.go import go_pb2 as colabo_dot_flow_dot_go_dot_go__pb2
5
+
6
+
7
+ class ActionsHostStub(object):
8
+ # missing associated documentation comment in .proto file
9
+ pass
10
+
11
+ def __init__(self, channel):
12
+ """Constructor.
13
+
14
+ Args:
15
+ channel: A grpc.Channel.
16
+ """
17
+ self.executeAction = channel.unary_unary(
18
+ '/colabo.flow.ActionsHost/executeAction',
19
+ request_serializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionExecuteRequest.SerializeToString,
20
+ response_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionExecuteReply.FromString,
21
+ )
22
+
23
+
24
+ class ActionsHostServicer(object):
25
+ # missing associated documentation comment in .proto file
26
+ pass
27
+
28
+ def executeAction(self, request, context):
29
+ """FlowsHost asks the ActionsHost to execute the action
30
+ """
31
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
32
+ context.set_details('Method not implemented!')
33
+ raise NotImplementedError('Method not implemented!')
34
+
35
+
36
+ def add_ActionsHostServicer_to_server(servicer, server):
37
+ rpc_method_handlers = {
38
+ 'executeAction': grpc.unary_unary_rpc_method_handler(
39
+ servicer.executeAction,
40
+ request_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionExecuteRequest.FromString,
41
+ response_serializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionExecuteReply.SerializeToString,
42
+ ),
43
+ }
44
+ generic_handler = grpc.method_handlers_generic_handler(
45
+ 'colabo.flow.ActionsHost', rpc_method_handlers)
46
+ server.add_generic_rpc_handlers((generic_handler,))
47
+
48
+
49
+ class FlowsHostStub(object):
50
+ # missing associated documentation comment in .proto file
51
+ pass
52
+
53
+ def __init__(self, channel):
54
+ """Constructor.
55
+
56
+ Args:
57
+ channel: A grpc.Channel.
58
+ """
59
+ self.registerFlowDescription = channel.unary_unary(
60
+ '/colabo.flow.FlowsHost/registerFlowDescription',
61
+ request_serializer=colabo_dot_flow_dot_go_dot_go__pb2.FlowRegisterRequestV1.SerializeToString,
62
+ response_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.FlowRegisterReplyV1.FromString,
63
+ )
64
+ self.registerActionDescription = channel.unary_unary(
65
+ '/colabo.flow.FlowsHost/registerActionDescription',
66
+ request_serializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionRegisterRequestV1.SerializeToString,
67
+ response_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionRegisterReplyV1.FromString,
68
+ )
69
+ self.startFlowInstance = channel.unary_unary(
70
+ '/colabo.flow.FlowsHost/startFlowInstance',
71
+ request_serializer=colabo_dot_flow_dot_go_dot_go__pb2.FlowInstanceRequest.SerializeToString,
72
+ response_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.FlowInstanceReply.FromString,
73
+ )
74
+ self.executeActionSync = channel.unary_unary(
75
+ '/colabo.flow.FlowsHost/executeActionSync',
76
+ request_serializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionExecuteRequest.SerializeToString,
77
+ response_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionExecuteReply.FromString,
78
+ )
79
+
80
+
81
+ class FlowsHostServicer(object):
82
+ # missing associated documentation comment in .proto file
83
+ pass
84
+
85
+ def registerFlowDescription(self, request, context):
86
+ """client registers particular flow description at the FlowsHost that can be later instantiated and executed
87
+ """
88
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
89
+ context.set_details('Method not implemented!')
90
+ raise NotImplementedError('Method not implemented!')
91
+
92
+ def registerActionDescription(self, request, context):
93
+ """(ActionsHost) client registers particular action description at the FlowsHost that can be later executed at the originating ActionsHost
94
+ """
95
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
96
+ context.set_details('Method not implemented!')
97
+ raise NotImplementedError('Method not implemented!')
98
+
99
+ def startFlowInstance(self, request, context):
100
+ """client asks the host to execute (wherever is expected) the flow
101
+ """
102
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
103
+ context.set_details('Method not implemented!')
104
+ raise NotImplementedError('Method not implemented!')
105
+
106
+ def executeActionSync(self, request, context):
107
+ """client asks the host to execute (wherever is expected) the action
108
+ """
109
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
110
+ context.set_details('Method not implemented!')
111
+ raise NotImplementedError('Method not implemented!')
112
+
113
+
114
+ def add_FlowsHostServicer_to_server(servicer, server):
115
+ rpc_method_handlers = {
116
+ 'registerFlowDescription': grpc.unary_unary_rpc_method_handler(
117
+ servicer.registerFlowDescription,
118
+ request_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.FlowRegisterRequestV1.FromString,
119
+ response_serializer=colabo_dot_flow_dot_go_dot_go__pb2.FlowRegisterReplyV1.SerializeToString,
120
+ ),
121
+ 'registerActionDescription': grpc.unary_unary_rpc_method_handler(
122
+ servicer.registerActionDescription,
123
+ request_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionRegisterRequestV1.FromString,
124
+ response_serializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionRegisterReplyV1.SerializeToString,
125
+ ),
126
+ 'startFlowInstance': grpc.unary_unary_rpc_method_handler(
127
+ servicer.startFlowInstance,
128
+ request_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.FlowInstanceRequest.FromString,
129
+ response_serializer=colabo_dot_flow_dot_go_dot_go__pb2.FlowInstanceReply.SerializeToString,
130
+ ),
131
+ 'executeActionSync': grpc.unary_unary_rpc_method_handler(
132
+ servicer.executeActionSync,
133
+ request_deserializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionExecuteRequest.FromString,
134
+ response_serializer=colabo_dot_flow_dot_go_dot_go__pb2.ActionExecuteReply.SerializeToString,
135
+ ),
136
+ }
137
+ generic_handler = grpc.method_handlers_generic_handler(
138
+ 'colabo.flow.FlowsHost', rpc_method_handlers)
139
+ server.add_generic_rpc_handlers((generic_handler,))
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.1
2
+ Name: colabo.flow.go
3
+ Version: 0.2.2
4
+ Summary: A python puzzle for sending ColaboFlow.Go (CF.Go) actions over gRPC
5
+ Home-page: https://github.com/Cha-OS/colabo
6
+ Author: ChaOS
7
+ Author-email: chaos.ngo@gmail.com
8
+ License: MIT
9
+ Project-URL: website, http://colabo.space
10
+ Project-URL: organization, http://cha-os.org
11
+ Description: # Install
12
+
13
+ ```sh
14
+ # the latest
15
+ pip install colabo.flow.go
16
+
17
+ # upgrade AFTER installing
18
+ pip install --upgrade colabo.flow.go
19
+
20
+ # a speciffic one
21
+ pip install colabo.flow.go==0.0.4
22
+ ```
23
+
24
+ # Use
25
+
26
+ ```py
27
+ # import
28
+ from colabo.flow.go import go_pb2
29
+ from colabo.flow.go import ColaboFlowGo
30
+
31
+ # create an ColaboFlowGo object
32
+ colaboFlowGo = ColaboFlowGo()
33
+
34
+ create an execute request object
35
+ request = go_pb2.ActionExecuteRequest(
36
+ flowId='search-sounds', name='mediator', flowInstanceId='fa23', dataIn='hello from client', params='quick')
37
+
38
+ # send the go object to the go service
39
+ response = colaboFlowGo.executeActionSync(request)
40
+
41
+ # print the respons from the go service
42
+ print("response = %s" % (response))
43
+ ```
44
+
45
+ # More Details
46
+
47
+ + [Github Colabo repository](https://github.com/Cha-OS/colabo)
48
+ + [This package inside the Colabo repo](https://github.com/Cha-OS/colabo/tree/master/src/services/puzzles/flow/go/python)
49
+ + [DEVELOPMENT.md](https://github.com/Cha-OS/colabo/blob/master/src/services/puzzles/flow/go/python/DEVELOPMENT.md)
50
+ + Relevant Colabo Puzzles
51
+ + [Python](https://github.com/Cha-OS/colabo/tree/master/src/services/puzzles/flow/go/python)
52
+ + [ColaboFlow Go Services](https://github.com/Cha-OS/colabo/tree/master/src/services/puzzles/flow/go)
53
+ + [Backend](https://github.com/Cha-OS/colabo/tree/master/src/backend/dev_puzzles/flow/go)
54
+ + [Frontend](https://github.com/Cha-OS/colabo/tree/master/src/frontend/dev_puzzles/flow/go)
55
+ + [Isomorphic](https://github.com/Cha-OS/colabo/tree/master/src/isomorphic/dev_puzzles/flow/go)
56
+ Keywords: colabo,grpc,flow,colaboflow,go,process,process mining
57
+ Platform: UNKNOWN
58
+ Description-Content-Type: text/markdown
@@ -0,0 +1,16 @@
1
+ README.md
2
+ setup.py
3
+ colabo/__init__.py
4
+ colabo.flow.go.egg-info/PKG-INFO
5
+ colabo.flow.go.egg-info/SOURCES.txt
6
+ colabo.flow.go.egg-info/dependency_links.txt
7
+ colabo.flow.go.egg-info/requires.txt
8
+ colabo.flow.go.egg-info/top_level.txt
9
+ colabo/flow/__init__.py
10
+ colabo/flow/go/__init__.py
11
+ colabo/flow/go/colaboflow_go_actionhost.py
12
+ colabo/flow/go/colaboflow_go_client.py
13
+ colabo/flow/go/colaboflow_go_demo.py
14
+ colabo/flow/go/go_pb2.py
15
+ colabo/flow/go/go_pb2_grpc.py
16
+ use-cases/__init__.py
@@ -0,0 +1,3 @@
1
+ grpcio
2
+ googleapis-common-protos
3
+ python-dateutil
@@ -0,0 +1,2 @@
1
+ colabo
2
+ use-cases
@@ -0,0 +1,69 @@
1
+ # __package__ = "use-cases"
2
+
3
+ import uuid
4
+ # from colabo.flow.go import ColaboFlowGo, go_pb2
5
+ from colabo.flow.go import ColaboFlowGo
6
+
7
+ from random import randint
8
+ from time import sleep
9
+
10
+ colaboFlowGo = ColaboFlowGo()
11
+
12
+
13
+ print("colaboFlowGo = %s" % (colaboFlowGo))
14
+
15
+
16
+ # gets the name of function inspectig stack
17
+ def gTFN():
18
+ import traceback
19
+ return traceback.extract_stack(None, 2)[0][2]
20
+
21
+ # Set of functions
22
+ def f1(dataIn):
23
+ print(("[%s] started." % (gTFN())))
24
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
25
+ dataOut = gTFN()+":result:"+dataIn
26
+ return dataOut
27
+
28
+
29
+ def f2(dataIn):
30
+ print(("[%s] started." % (gTFN())))
31
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
32
+ dataOut = gTFN()+":result:"+dataIn
33
+ return dataOut
34
+
35
+ def f3(dataIn):
36
+ print(("[%s] started." % (gTFN())))
37
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
38
+ dataOut = gTFN()+":result:"+dataIn
39
+ return dataOut
40
+
41
+ def f4(dataIn):
42
+ print(("[%s] started." % (gTFN())))
43
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
44
+ dataOut = gTFN()+":result:"+dataIn
45
+ return dataOut
46
+
47
+ def f5(dataIn):
48
+ print(("[%s] started." % (gTFN())))
49
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
50
+ dataOut = gTFN()+":result:"+dataIn
51
+ return dataOut
52
+
53
+
54
+ # Running functions
55
+ print("---")
56
+ r1 = f1("hello 1")
57
+ print("r1: %s" %(r1))
58
+ print("---")
59
+ r2 = f2(r1)
60
+ print("r2: %s" % (r2))
61
+ print("---")
62
+ r3 = f3(r2)
63
+ print("r3: %s" % (r3))
64
+ print("---")
65
+ r4 = f4(r3)
66
+ print("r4: %s" % (r4))
67
+ print("---")
68
+ r5 = f5(r4)
69
+ print("r5: %s" % (r5))
@@ -0,0 +1,146 @@
1
+ # __package__ = "use-cases"
2
+
3
+ # NOTE:
4
+ # ColaboFlow.Go version of the previous
5
+
6
+ import uuid
7
+ # from colabo.flow.go import ColaboFlowGoDemo, go_pb2
8
+ from colabo.flow.go import ColaboFlowGoDemo
9
+
10
+ from random import randint
11
+ from time import sleep
12
+
13
+ # RUNNING_SCENARIO = 'manual'
14
+ # RUNNING_SCENARIO = 'sequential_data_flow'
15
+ RUNNING_SCENARIO = 'descriptive_data_flow'
16
+ # RUNNING_SCENARIO = 'descriptive_multidata_flow'
17
+ # RUNNING_SCENARIO = 'descriptive_multidataoutput_flow'
18
+
19
+ colaboFlowGo = ColaboFlowGoDemo()
20
+
21
+
22
+ print("colaboFlowGo = %s" % (colaboFlowGo))
23
+
24
+
25
+ # gets the name of function inspectig stack
26
+ def gTFN():
27
+ import traceback
28
+ return traceback.extract_stack(None, 2)[0][2]
29
+
30
+ # Set of functions
31
+ def f1(dataIn):
32
+ print(("[%s] started." % (gTFN())))
33
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
34
+ dataOut = gTFN()+":result:"+dataIn
35
+ return dataOut
36
+
37
+
38
+ def f2(dataIn):
39
+ print(("[%s] started." % (gTFN())))
40
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
41
+ dataOut = gTFN()+":result:"+dataIn
42
+ return dataOut
43
+
44
+ def f3(dataIn):
45
+ print(("[%s] started." % (gTFN())))
46
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
47
+ dataOut = gTFN()+":result:"+dataIn
48
+ return dataOut
49
+
50
+ def f4(dataIn):
51
+ print(("[%s] started." % (gTFN())))
52
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
53
+ dataOut = gTFN()+":result:"+dataIn
54
+ return dataOut
55
+
56
+ def f5(dataIn):
57
+ print(("[%s] started." % (gTFN())))
58
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
59
+ dataOut = gTFN()+":result:"+dataIn
60
+ return dataOut
61
+
62
+ dataIn1 = "hello 2"
63
+
64
+ print("Running flow as: %s" % (RUNNING_SCENARIO))
65
+
66
+ if RUNNING_SCENARIO == 'manual':
67
+ # Running functions
68
+ print("---")
69
+ r1 = f1(dataIn1)
70
+ print("r1: %s" %(r1))
71
+ print("---")
72
+ r2 = f2(r1)
73
+ print("r2: %s" % (r2))
74
+ print("---")
75
+ r3 = f3(r2)
76
+ print("r3: %s" % (r3))
77
+ print("---")
78
+ r4 = f4(r3)
79
+ print("r4: %s" % (r4))
80
+ print("---")
81
+ r5 = f5(r4)
82
+ print("r5: %s" % (r5))
83
+
84
+ if RUNNING_SCENARIO == 'sequential_data_flow':
85
+ (colaboFlowGo
86
+ .addActionAsFunction(f1, "f1")
87
+ .addActionAsFunction(f2, "f2")
88
+ .addActionAsFunction(f3, "f3")
89
+ .addActionAsFunction(f4, "f4")
90
+ .addActionAsFunction(f5, "f5")
91
+ )
92
+
93
+ colaboFlowGo.runWithSequentialDataFlow(dataIn1)
94
+
95
+ if RUNNING_SCENARIO == 'descriptive_data_flow':
96
+ (colaboFlowGo
97
+ .addActionAsFunctionWithInputParam(f1, "f1", "f0")
98
+ .addActionAsFunctionWithInputParam(f2, "f2", "f1")
99
+ # the data flow is not necessary to be sequential anymore
100
+ .addActionAsFunctionWithInputParam(f3, "f3", "f0")
101
+ .addActionAsFunctionWithInputParam(f4, "f4", "f1")
102
+ .addActionAsFunctionWithInputParam(f5, "f5", "f2")
103
+ )
104
+
105
+ colaboFlowGo.runWithDescriptiveDataFlow("f0", dataIn1)
106
+
107
+ def f6(dataIn1, dataIn2):
108
+ print(("[%s] started." % (gTFN())))
109
+ print(("[%s] dataIn1: %s" % (gTFN(), dataIn1)))
110
+ print(("[%s] dataIn2: %s" % (gTFN(), dataIn2)))
111
+ dataOut = (gTFN()+":(result1:"+dataIn1+"+"
112
+ + ":result2:"+dataIn1+")")
113
+ return dataOut
114
+
115
+ if RUNNING_SCENARIO == 'descriptive_multidata_flow':
116
+ (colaboFlowGo
117
+ .addActionAsFunctionWithInputParams(f1, "f1", ["f0"])
118
+ .addActionAsFunctionWithInputParams(f2, "f2", ["f1"])
119
+ # the data flow is not necessary to be sequential anymore
120
+ .addActionAsFunctionWithInputParams(f3, "f3", ["f0"])
121
+ .addActionAsFunctionWithInputParams(f4, "f4", ["f1"])
122
+ .addActionAsFunctionWithInputParams(f5, "f5", ["f1"])
123
+ .addActionAsFunctionWithInputParams(f6, "f6", ["f1", "f5"])
124
+ )
125
+
126
+ colaboFlowGo.runWithDescriptiveMultiDataFlow("f0", dataIn1)
127
+
128
+ def f7(dataIn):
129
+ print(("[%s] started." % (gTFN())))
130
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
131
+ dataOut1 = gTFN()+":result1:"+dataIn
132
+ dataOut2 = gTFN()+":result2:"+dataIn
133
+ return dataOut1, dataOut2
134
+
135
+ if RUNNING_SCENARIO == 'descriptive_multidataoutput_flow':
136
+ (colaboFlowGo
137
+ .addActionAsFunctionWithOutputParams(f1, "f1", ["f0"])
138
+ .addActionAsFunctionWithOutputParams(f2, "f2", ["f1"])
139
+ # the data flow is not necessary to be sequential anymore
140
+ .addActionAsFunctionWithOutputParams(f3, "f3", ["f0"])
141
+ .addActionAsFunctionWithOutputParams(f7, "f7", ["f0"], ["f7.1", "f7.2"])
142
+ .addActionAsFunctionWithOutputParams(f5, "f5", ["f7.1"])
143
+ .addActionAsFunctionWithOutputParams(f6, "f6", ["f7.2", "f2"])
144
+ )
145
+
146
+ colaboFlowGo.runWithDescriptiveOutDataFlow("f0", dataIn1)
@@ -0,0 +1,47 @@
1
+ # __package__ = "use-cases"
2
+
3
+ from enum import Enum
4
+ import uuid
5
+ # from colabo.flow.go import ColaboFlowGoDemo, go_pb2
6
+ from colabo.flow.go import ColaboFlowGoActionHost
7
+ from colabo.flow.go import go_pb2
8
+ from colabo.flow.go import go_pb2_grpc
9
+
10
+ from random import randint
11
+ from time import sleep
12
+
13
+ # https://stackoverflow.com/questions/1977362/how-to-create-module-wide-variables-in-python
14
+ _ACTION_EXECUTION_ID = 0
15
+
16
+ # https://docs.python.org/3/library/enum.html
17
+ class SupportedActions(Enum):
18
+ SearchSounds = 'search-sounds'
19
+
20
+ def searchSounds(actionExId, request, context):
21
+ return go_pb2.ActionExecuteReply(id=actionExId, dataOut="Hello From ActionHost", params="All good!")
22
+
23
+ class ActionsHostServicerImplementation(go_pb2_grpc.ActionsHostServicer):
24
+
25
+ def executeAction(self, request, context):
26
+ global _ACTION_EXECUTION_ID
27
+ actionExId = str(_ACTION_EXECUTION_ID)
28
+ _ACTION_EXECUTION_ID = _ACTION_EXECUTION_ID+1
29
+ print("request: %s" % (request))
30
+ print("request.name: %s" % (request.name))
31
+ print("SupportedActions.SearchSounds: %s" % (SupportedActions.SearchSounds.value))
32
+
33
+ # https://docs.python.org/3/library/enum.html#iteration
34
+ # https://stackoverflow.com/questions/44781681/how-to-compare-a-string-with-a-python-enum
35
+ if(request.name == SupportedActions.SearchSounds.value):
36
+ result = searchSounds(actionExId, request, context)
37
+ else:
38
+ print("ERROR: request.name '%s' is not supported" % (request.name))
39
+ result = go_pb2.ActionExecuteReply(id=actionExId, dataOut="Error", params="", error=("ERROR: request.name '%s' is not supported" % (request.name)) )
40
+ return result
41
+
42
+ colaboFlowGoActionHost = ColaboFlowGoActionHost(
43
+ ActionsHostServicerImplementation)
44
+
45
+ print("colaboFlowGoActionHost = %s" % (colaboFlowGoActionHost))
46
+
47
+ colaboFlowGoActionHost.startService()
@@ -0,0 +1,13 @@
1
+ # Exacute
2
+
3
+ Execute flow:
4
+
5
+ ```sh
6
+ python3 demo-2.py -p ./demo-puzzles/ -f demo-flows/flow-demo.json
7
+ ```
8
+
9
+ Execute a single task in a flow:
10
+
11
+ ```sh
12
+ python3 demo-2.py -p ./demo-puzzles/ -f demo-flows/flow-demo.json -t task-test-B
13
+ ```
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ # http://www.python.org/dev/peps/pep-0263/
4
+ from __future__ import division
5
+ from decimal import Decimal
6
+ import re
7
+ from collections import OrderedDict
8
+ import csv
9
+ import json
10
+ import os
11
+ import uuid
12
+ from random import randint
13
+ from time import sleep
14
+
15
+ from colabo.flow.go import ColaboFlowGoBasic
16
+
17
+ colaboFlowGo = ColaboFlowGoBasic()
18
+
19
+
20
+ print("colaboFlowGo = %s" % (colaboFlowGo))
21
+
22
+ # colaboFlowGo.loadFlow("flows/flow-test.json")
23
+ colaboFlowGo.loadFlow()
24
+ colaboFlowGo.execute()
25
+
26
+
27
+ # gets the name of function inspectig stack
28
+ def gTFN():
29
+ import traceback
30
+ return traceback.extract_stack(None, 2)[0][2]
31
+
32
+ # Set of functions
33
+ def f1(dataIn):
34
+ print(("[%s] started." % (gTFN())))
35
+ print(("[%s] dataIn: %s" % (gTFN(), dataIn)))
36
+ dataOut = gTFN()+":result:"+dataIn
37
+ return dataOut
38
+
@@ -0,0 +1,32 @@
1
+ # __package__ = "use-cases"
2
+
3
+ # NOTE:
4
+ # ColaboFlow.Go version of the previous
5
+
6
+ import uuid
7
+ import json
8
+ # from colabo.flow.go import ColaboFlowGo, go_pb2
9
+ from colabo.flow.go import ColaboFlowGo
10
+ from colabo.flow.go import go_pb2
11
+
12
+ from random import randint
13
+ from time import sleep
14
+
15
+ colaboFlowGo = ColaboFlowGo()
16
+
17
+
18
+ print("colaboFlowGo = %s" % (colaboFlowGo))
19
+
20
+ requestData = {
21
+ 'query': 'PREFIX cc: <http://creativecommons.org/ns#>\nPREFIX ac: <https://w3id.org/ac-ontology/aco#>\nPREFIX dc: <http://purl.org/dc/elements/1.1/>\nPREFIX iter: <http://w3id.org/sparql-generate/iter/>\nPREFIX fn: <http://w3id.org/sparql-generate/fn/>\nPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX prov: <http://www.w3.org/ns/prov#>\nPREFIX foaf: <http://xmlns.com/foaf/0.1/>\nPREFIX schema: <http://schema.org/>\nPREFIX ebu: <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#>\n\nPREFIX europeana-res: <https://w3id.org/audiocommons/services/europeana/resources>\n\nPREFIX europeana-api: <https://www.europeana.eu/api/v2/>\n\n GENERATE {\n \nGENERATE {\n\n GENERATE {\n <http://europeana.eu>\n rdf:type prov:Agent, foaf:Organization ;\n foaf:name "Europeana" .\n\n ?searchAction\n a schema:SearchAction ;\n schema:object <http://europeana.eu> ;\n schema:query $pattern ;\n schema:startTime $startTime;\n schema:endTime ?endTime;\n schema:actionStatus ?actionStatus;\n schema:result ?audioCollection ;\n schema:error ?error .\n\n ?audioCollection\n rdf:type ac:AudioCollection; #, prov:Entity ;\n # prov:wasAttributedTo <http://europeana.eu> ;\n ac:nodeCount ?nodeCount .\n\n ?error rdfs:label ?errorMessage .\n\n GENERATE {\n ?audioCollection ac:memberNode ?audioCollectionNode .\n ?audioCollectionNode\n a ac:AudioCollectionNode ;\n ac:nodeIndex ?index ;\n ac:nodeContent ?audioClip .\n\n ?audioClip\n rdf:type ac:AudioClip ;\n dc:title ?title ;\n \t dc:description ?desc ;\n \t ac:author ?author ;\n \t cc:license ?license ;\n #\t ac:originalFile _:originalFile ;\n ac:availableAs ?audioPreviewFile .\n # rdf:type prov:Entity ;\n # prov:wasAttributedTo <http://europeana.eu> .\n ?audioPreviewFile rdf:type ac:AudioFile ;\n ebu:locator ?audioPreviewFileUrl .\n\n }\n ITERATOR iter:JSONElement(?source,"items[*]") AS ?resIterator\n WHERE {\n BIND(BNODE() AS ?audioCollectionNode)\n BIND(fn:JSONPath(?resIterator, "element") AS ?res)\n BIND(fn:JSONPath(?resIterator, "position") AS ?indexFromZero)\n BIND(?indexFromZero + 1 AS ?index)\n\n BIND(IRI(CONCAT(STR(europeana-res:), STR(fn:JSONPath(?res, "id")))) AS ?audioClip)\n BIND(fn:JSONPath(?res, "type") AS ?type)\n BIND(fn:JSONPath(?res, "title[0]") AS ?title)\n BIND(IRI(fn:JSONPath(?res, "rights[0]")) AS ?license)\n BIND(fn:JSONPath(?res, "dcCreator[0]") AS ?author)\n BIND(fn:JSONPath(?res, "dcDescription[0]") AS ?desc)\n # BIND(IRI(fn:JSONPath(?res, "edmIsShownAt[0]")) AS ?origFile)\n BIND(IRI(fn:JSONPath(?res, "edmIsShownBy[0]")) AS ?audioPreviewFileUrl)\n OPTIONAL {\n BIND(BNODE() AS ?audioPreviewFile).\n FILTER(BOUND(?audioPreviewFileUrl))\n }\n } .\n }\n SOURCE ?serviceCall AS ?source\n WHERE {\n BIND(BNODE() AS ?searchAction)\n BIND(fn:JSONPath(?source, "success") AS ?wasSuccessful)\n BIND(IF(BOUND(?wasSuccessful), schema:CompletedActionStatus, schema:FailedActionStatus) AS ?actionStatus)\n OPTIONAL {\n \tBIND(BNODE() AS ?audioCollection) .\n FILTER(BOUND(?wasSuccessful))\n }\n OPTIONAL {\n \tBIND(BNODE() AS ?error) .\n FILTER(!BOUND(?wasSuccessful))\n }\n BIND(fn:JSONPath(?source, "error") AS ?errorMessage) .\n BIND(NOW() AS ?endTime)\n } .\n}\nWHERE {\n BIND(IRI(CONCAT(\n STR(europeana-api:), "search.json",\n "?wskey=", ENCODE_FOR_URI("6NPvpkHH4"),\n "&qf=what:SOUND",\n "&reusability=RESTRICTED&reusability=OPEN",\n "&media=true&profile=rich",\n "&query=", ENCODE_FOR_URI($pattern),\n IF(BOUND($limit), CONCAT("&rows=", ENCODE_FOR_URI(STR($limit))),""),\n IF(BOUND($page), CONCAT("&start=", ENCODE_FOR_URI(STR($limit * ($page - 1) + 1))),"")\n )) AS ?serviceCall)\n}\n.\n }\n WHERE {\n BIND("dog" AS $pattern). BIND("2018-12-17T16:35:15.874683"^^<http://www.w3.org/2001/XMLSchema#dateTime> AS $startTime). BIND(12 AS $limit). BIND(1 AS $page).\n } '}
22
+
23
+ requestDataStr = json.dumps(requestData)
24
+ request = go_pb2.ActionExecuteRequest(
25
+ flowId='search-sounds', name='sparql-gen', flowInstanceId='fa23', dataIn=requestDataStr)
26
+ response = colaboFlowGo.executeActionSync(request)
27
+ print("response = %s" % (response))
28
+
29
+ # request = go_pb2.ActionExecuteRequest(
30
+ # flowId='search-sounds', name='mediator', flowInstanceId='fa23', dataIn='hello from client', params='quick')
31
+ # response = colaboFlowGo.executeActionSync(request)
32
+ # print("response = %s" % (response))
@@ -0,0 +1,36 @@
1
+ {
2
+ "tasks": [{
3
+ "name": "task-test-A",
4
+ "comment": "example of puzzle inside module `puzzles.puzzle-a`, and class `PuzzleA` and default method `process`",
5
+ "puzzle": "puzzles.puzzle-a:PuzzleA",
6
+ "parameters": {
7
+ "_test": "temp_data/cache/epub/15008/pg15008.rdf",
8
+ "test": "example_data/cache/epub/100/pg100.rdf",
9
+ "foldersIn": [
10
+ "example_data/cache/epub"
11
+ ],
12
+ "DB": {
13
+ "database": "litterra"
14
+ }
15
+ }
16
+ },
17
+ {
18
+ "name": "task-test-B",
19
+ "comment": "example of puzzle inside module `puzzles.puzzle-b`, without class and method `processB`",
20
+ "puzzle": "puzzles.puzzle-b::processB",
21
+ "parameters": {
22
+ "_gutenbergFolder": "/var/data/litterra/Gutenberg",
23
+ "gutenbergFolder": "./example_data/content",
24
+ "resourceId": "15008"
25
+ }
26
+ },
27
+ {
28
+ "name": "task-test-C",
29
+ "comment": "example of puzzle inside module `puzzles.puzzle-c`, without class and default method `process`",
30
+ "puzzle": "puzzles.puzzle-c",
31
+ "parameters": {
32
+ "p1": "Hello puzzle C"
33
+ }
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,19 @@
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
+
12
+ class PuzzleA():
13
+
14
+ def __init__(self, taskName="taskA"):
15
+
16
+ print("[PuzzleA] new task created: %s" % (taskName))
17
+
18
+ def process(self, task):
19
+ print("[PuzzleA] task: %s" % (task))
@@ -0,0 +1,21 @@
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
+ def processB(task):
12
+ print("[PuzzleB] task: %s" % (task))
13
+
14
+ class PuzzleB():
15
+
16
+ def __init__(self, taskName="taskB"):
17
+
18
+ print("[PuzzleB] new task created: %s" % (taskName))
19
+
20
+ def process(self, task):
21
+ print("[PuzzleB] task: %s" % (task))