Tachi67 commited on
Commit
cea643f
1 Parent(s): ab7b844

Upload run.py

Browse files
Files changed (1) hide show
  1. run.py +52 -0
run.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import hydra
4
+
5
+ from aiflows.messages import InputMessage
6
+ from aiflows.utils.general_helpers import read_yaml_file
7
+
8
+ from aiflows import logging
9
+ from aiflows.flow_cache import CACHING_PARAMETERS, clear_cache
10
+
11
+ CACHING_PARAMETERS.do_caching = False # Set to True in order to disable caching
12
+ # clear_cache() # Uncomment this line to clear the cache
13
+
14
+ logging.set_verbosity_debug()
15
+ logging.auto_set_dir()
16
+
17
+ dependencies = [
18
+ {"url": "aiflows/PlanFileEditFlowModule", "revision": "main"},
19
+ ]
20
+
21
+ from aiflows import flow_verse
22
+
23
+ flow_verse.sync_dependencies(dependencies)
24
+
25
+ if __name__ == "__main__":
26
+ current_dir = os.getcwd()
27
+ cfg_path = os.path.join(current_dir, "PlanFileEditAtomicFlow.yaml")
28
+ cfg = read_yaml_file(cfg_path)
29
+ with open(os.path.join(current_dir, "plan.txt"), "w") as file:
30
+ pass
31
+
32
+ # ~~~ instantiating the flow and input data ~~~
33
+ PlanFileEditFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")
34
+ plan = """
35
+ 1. Go to Italy.
36
+ 2. Order pineapple pizza.
37
+ """
38
+ input_data = {
39
+ "plan": plan,
40
+ "plan_file_location": os.path.join(current_dir, "plan.txt")
41
+ }
42
+ input_message = InputMessage.build(
43
+ data_dict=input_data,
44
+ src_flow="Launcher",
45
+ dst_flow=PlanFileEditFlow.name
46
+ )
47
+
48
+ # ~~~ calling the flow ~~~
49
+ output_message = PlanFileEditFlow(input_message)
50
+
51
+ # By now, the plan should have been written to the temp_plan.txt file.
52
+ print(output_message.data)