File size: 5,605 Bytes
e81ee32 23272f4 e81ee32 23272f4 e81ee32 23272f4 e81ee32 23272f4 e81ee32 55a3a8a e81ee32 23272f4 e81ee32 |
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# 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`
<a id="TestCodeFlow"></a>
# TestCodeFlow
<a id="TestCodeFlow.TestCodeFlow"></a>
## 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.
<a id="TestCodeFlow.TestCodeFlow.__init__"></a>
#### \_\_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.
<a id="TestCodeFlow.TestCodeFlow.instantiate_from_config"></a>
#### 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.
<a id="TestCodeFlow.TestCodeFlow.run"></a>
#### 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.
<a id="TestCodeFileEditAtomicFlow"></a>
# TestCodeFileEditAtomicFlow
<a id="TestCodeFileEditAtomicFlow.TestCodeFileEditAtomicFlow"></a>
## 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.
<a id="run"></a>
# run
<a id="__init__"></a>
# \_\_init\_\_
<a id="CodeTestingAtomicFlow"></a>
# CodeTestingAtomicFlow
<a id="CodeTestingAtomicFlow.CodeTestingAtomicFlow"></a>
## 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.
<a id="CodeTestingAtomicFlow.CodeTestingAtomicFlow.run"></a>
#### 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.
|