File size: 1,259 Bytes
d436392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os

import hydra

from aiflows.messages import InputMessage
from aiflows.utils.general_helpers import read_yaml_file

from aiflows import logging
from aiflows.flow_cache import CACHING_PARAMETERS, clear_cache

CACHING_PARAMETERS.do_caching = False  # Set to True in order to disable caching
# clear_cache() # Uncomment this line to clear the cache

logging.set_verbosity_debug()
logging.auto_set_dir()

dependencies = [
    {"url": "aiflows/InterpreterFlowModule", "revision": "main"},
]

from aiflows import flow_verse

flow_verse.sync_dependencies(dependencies)

if __name__ == "__main__":
    current_dir = os.getcwd()
    cfg_path = os.path.join(current_dir, "InterpreterAtomicFlow.yaml")
    cfg = read_yaml_file(cfg_path)


    # ~~~ instantiating the flow and input data ~~~
    InterpreterFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")
    code = """
print("Hello World!")
    """
    input_data = {
        "language": "Python",
        "code": code,
    }
    input_message = InputMessage.build(
        data_dict=input_data,
        src_flow="Launcher",
        dst_flow=InterpreterFlow.name
    )

    # ~~~ calling the flow ~~~
    output_message = InterpreterFlow(input_message)
    print(output_message.data)