# Table of Contents * [Structure of TestCodeFlow](#structure-of-testcodeflow) * [TestCodeFlow](#TestCodeFlow) * [TestCodeFlow](#TestCodeFlow.TestCodeFlow) * [\_\_init\_\_](#TestCodeFlow.TestCodeFlow.__init__) * [instantiate\_from\_config](#TestCodeFlow.TestCodeFlow.instantiate_from_config) * [run](#TestCodeFlow.TestCodeFlow.run) * [TestCodeFileEditAtomicFlow](#TestCodeFileEditAtomicFlow) * [TestCodeFileEditAtomicFlow](#TestCodeFileEditAtomicFlow.TestCodeFileEditAtomicFlow) * [run](#run) * [\_\_init\_\_](#__init__) * [CodeTestingAtomicFlow](#CodeTestingAtomicFlow) * [CodeTestingAtomicFlow](#CodeTestingAtomicFlow.CodeTestingAtomicFlow) * [run](#CodeTestingAtomicFlow.CodeTestingAtomicFlow.run) # Structure of TestCodeFlow ``` code | v +-------------------+ | TestCodeFileEdit | Edit a temp code file with the code to be tested and necessary imports (manually added): https://huggingface.co/aiflows/TestCodeFlowModule/blob/main/TestCodeFileEditAtomicFlow.py +-------------------+ | | (temp_code_file_location) | v +------------------+ | CodeTesting | Opens up the temp file until user closes the file, run the test code. +------------------+ | | (feedback) | v feedback ``` Memory_files: - `library.py` # TestCodeFlow ## TestCodeFlow Objects ```python class TestCodeFlow(SequentialFlow) ``` This class is used to test code. It is a sequential flow that runs the following steps: 1. Prepares the code to be tested, it is composed of the code to be tested and necessary import statements manually added. 2. Opens the code in VSCode and waits for the user to clode the vscode session. The user is able to add tests. 3. The following will be tested: a. (Default & Compulsory) Code syntax; b. (Added by user) Any other tests. 4. Runs the test and returns the output. *Input Interface*: - `code` (str): The code to be tested. *Output Interface*: - `feedback` (str): The test results. *Configuration Parameters*: - `memory_files`: The memory files to be used in the flow, typically we need to have the code library as memory file here. - `input_interface`: The input interface of the flow. - `output_interface`: The output interface of the flow. - `subflows_config`: The subflows configuration. - `topology`: The topology of the subflows. #### \_\_init\_\_ ```python def __init__(memory_files: Dict[str, Any], **kwargs) ``` This function instantiates the class. **Arguments**: - `memory_files` (`Dict[str, Any]`): The memory files to be used in the flow, typically we need to have the code library as memory file here. - `kwargs` (`Any`): The keyword arguments. #### instantiate\_from\_config ```python @classmethod def instantiate_from_config(cls, config) ``` This function instantiates the class from a configuration dictionary. **Arguments**: - `config` (`Dict[str, Any]`): The configuration dictionary. **Returns**: `TestCodeFlow`: The instantiated class. #### run ```python def run(input_data: Dict[str, Any]) -> Dict[str, Any] ``` This function runs the flow. **Arguments**: - `input_data` (`Dict[str, Any]`): The input data. **Returns**: `Dict[str, Any]`: The output data. # TestCodeFileEditAtomicFlow ## TestCodeFileEditAtomicFlow Objects ```python class TestCodeFileEditAtomicFlow(CodeFileEditAtomicFlow) ``` Refer to: https://huggingface.co/aiflows/CodeFileEditFlowModule/tree/main *Input Interface*: - `code`: str - `memory_files`: Dict[str, str] *Output Interface*: - `code_editor_output`: str, the code editor output - `temp_code_file_location`: str, the location of the temporary code file *Configuration Parameters*: - `input_interface`: The input interface of the flow. - `output_interface`: The output interface of the flow. # run # \_\_init\_\_ # CodeTestingAtomicFlow ## CodeTestingAtomicFlow Objects ```python class CodeTestingAtomicFlow(InterpreterAtomicFlow) ``` This class inherits from InterpreterAtomicFlow and is used to test code. *Input Interface*: - `temp_code_file_location`: Location of the file containing the code to be tested. *Output Interface*: - `feedback`: Feedback from the test (i.e. test results). *Configuration Parameters*: - `input_interface`: the input interface of the atomic flow. - `output_interface`: the output interface of the atomic flow. #### run ```python def run(input_data: Dict[str, Any]) ``` Runs the atomic flow. **Arguments**: - `input_data` (`Dict[str, Any]`): The input data to the atomic flow. **Returns**: `Dict[str, Any]`: The output data of the atomic flow.