Tachi67 commited on
Commit
6c31409
·
1 Parent(s): 7bb2097

Upload 2 files

Browse files
Files changed (2) hide show
  1. library.py +2 -0
  2. run.py +57 -0
library.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ def add_two_numbers(a, b):
2
+ return a + b
run.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import hydra
4
+
5
+ from flows.backends.api_info import ApiInfo
6
+ from flows.messages import InputMessage
7
+ from flows.utils.general_helpers import read_yaml_file
8
+
9
+ from flows import logging
10
+ from flows.flow_cache import CACHING_PARAMETERS, clear_cache
11
+
12
+ CACHING_PARAMETERS.do_caching = False # Set to True in order to disable caching
13
+ # clear_cache() # Uncomment this line to clear the cache
14
+
15
+ logging.set_verbosity_debug()
16
+ logging.auto_set_dir()
17
+
18
+ dependencies = [
19
+ {"url": "Tachi67/CodeFileEditFlowModule", "revision": "main"},
20
+ {"url": "Tachi67/InterpreterFlowModule", "revision": "main"},
21
+ {"url": "aiflows/HumanStandardInputFlowModule", "revision": "5683a922372c5fa90be9f6447d6662d8d80341fc"},
22
+ {"url": "Tachi67/RunCodeFlowModule", "revision": "main"}
23
+ ]
24
+
25
+ from flows import flow_verse
26
+
27
+ flow_verse.sync_dependencies(dependencies)
28
+
29
+ if __name__ == "__main__":
30
+ current_dir = os.getcwd()
31
+ cfg_path = os.path.join(current_dir, "RunCodeFlow.yaml")
32
+ cfg = read_yaml_file(cfg_path)
33
+
34
+
35
+ # ~~~ instantiating the flow and input data ~~~
36
+ RunCodeFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")
37
+ memory_files = {"code_library": os.path.join(current_dir, "library.py")}
38
+ code = """
39
+ from library import add_two_numbers
40
+
41
+ add_two_numbers(1,1)
42
+ """
43
+ input_data = {
44
+ "memory_files": memory_files,
45
+ "language": "Python",
46
+ "code": code,
47
+ }
48
+ input_message = InputMessage.build(
49
+ data_dict=input_data,
50
+ src_flow="Launcher",
51
+ dst_flow=RunCodeFlow.name
52
+ )
53
+
54
+ # ~~~ calling the flow ~~~
55
+ output_message = RunCodeFlow(input_message)
56
+
57
+ print(output_message)