add example run
Browse files
run.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/InterpreterFlowModule", "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, "InterpreterAtomicFlow.yaml")
|
| 28 |
+
cfg = read_yaml_file(cfg_path)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# ~~~ instantiating the flow and input data ~~~
|
| 32 |
+
InterpreterFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")
|
| 33 |
+
code = """
|
| 34 |
+
print("Hello World!")
|
| 35 |
+
"""
|
| 36 |
+
input_data = {
|
| 37 |
+
"language": "Python",
|
| 38 |
+
"code": code,
|
| 39 |
+
}
|
| 40 |
+
input_message = InputMessage.build(
|
| 41 |
+
data_dict=input_data,
|
| 42 |
+
src_flow="Launcher",
|
| 43 |
+
dst_flow=InterpreterFlow.name
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# ~~~ calling the flow ~~~
|
| 47 |
+
output_message = InterpreterFlow(input_message)
|
| 48 |
+
print(output_message.data)
|