Download run.py from Tachi67/RunCodeFlowModule: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/Tachi67/RunCodeFlowModule/resolve/efed64d608dababb5561cfe1c7962b72ebd95fdd/run.py
- Command line
-
hf download hf://Tachi67/RunCodeFlowModule@efed64d608dababb5561cfe1c7962b72ebd95fdd/run.py
-
curl -L -o run.py https://huggingface.co/Tachi67/RunCodeFlowModule/resolve/efed64d608dababb5561cfe1c7962b72ebd95fdd/run.py
1.62 kB
| 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": "Tachi67/CodeFileEditFlowModule", "revision": "main"}, | |
| {"url": "Tachi67/InterpreterFlowModule", "revision": "main"}, | |
| {"url": "aiflows/HumanStandardInputFlowModule", "revision": "4ff043522c89a964ea3a928ce09811c51a2b5b98"}, | |
| {"url": "Tachi67/RunCodeFlowModule", "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, "RunCodeFlow.yaml") | |
| cfg = read_yaml_file(cfg_path) | |
| # ~~~ instantiating the flow and input data ~~~ | |
| RunCodeFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial") | |
| memory_files = {"code_library": os.path.join(current_dir, "library.py")} | |
| code = """ | |
| from library import add_two_numbers | |
| add_two_numbers(1,1) | |
| """ | |
| input_data = { | |
| "memory_files": memory_files, | |
| "language": "Python", | |
| "code": code, | |
| } | |
| input_message = InputMessage.build( | |
| data_dict=input_data, | |
| src_flow="Launcher", | |
| dst_flow=RunCodeFlow.name | |
| ) | |
| # ~~~ calling the flow ~~~ | |
| output_message = RunCodeFlow(input_message) | |
| print(output_message) |