Upload 6 files
Browse files- MemoryWritingAtomicFlow.py +31 -0
- README.md +39 -1
MemoryWritingAtomicFlow.py
CHANGED
|
@@ -9,15 +9,39 @@ class MemoryWritingAtomicFlow(AtomicFlow):
|
|
| 9 |
|
| 10 |
*Output Interface*:
|
| 11 |
- `MemWrite_output` (str): message that whether memory write was successful
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
"""
|
| 13 |
def __init__(self, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
super().__init__(**kwargs)
|
| 15 |
self.supported_memories = ["summary"]
|
| 16 |
def _check_input(self, input_data: Dict[str, Any]):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
assert "memory_files" in input_data, "memory_files not passed to MemoryWritingAtomicFlow"
|
| 18 |
assert any(item in input_data for item in self.supported_memories), "no memories to write"
|
| 19 |
|
| 20 |
def _call(self, input_data: Dict[str, Any]):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
try:
|
| 22 |
if "summary" in input_data:
|
| 23 |
assert "logs" in input_data["memory_files"], "there is summary to write, but no logs file in memory_files"
|
|
@@ -34,5 +58,12 @@ class MemoryWritingAtomicFlow(AtomicFlow):
|
|
| 34 |
self,
|
| 35 |
input_data: Dict[str, Any]
|
| 36 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
self._check_input(input_data)
|
| 38 |
return self._call(input_data)
|
|
|
|
| 9 |
|
| 10 |
*Output Interface*:
|
| 11 |
- `MemWrite_output` (str): message that whether memory write was successful
|
| 12 |
+
|
| 13 |
+
*Configuration Parameters*:
|
| 14 |
+
- `input_interface`: the input interface of the atomic flow
|
| 15 |
+
- `output_interface`: the output interface of the atomic flow
|
| 16 |
"""
|
| 17 |
def __init__(self, **kwargs):
|
| 18 |
+
"""
|
| 19 |
+
Initialize the atomic flow.
|
| 20 |
+
:param kwargs: additional key-value arguments to pass to the atomic flow
|
| 21 |
+
:type kwargs: Dict[str, Any]
|
| 22 |
+
"""
|
| 23 |
super().__init__(**kwargs)
|
| 24 |
self.supported_memories = ["summary"]
|
| 25 |
def _check_input(self, input_data: Dict[str, Any]):
|
| 26 |
+
"""
|
| 27 |
+
Check whether the input data is valid.
|
| 28 |
+
:param input_data: the input data to check
|
| 29 |
+
:type input_data: Dict[str, Any]
|
| 30 |
+
:raises AssertionError: if memory_files is not passed to MemoryWritingAtomicFlow
|
| 31 |
+
:raises AssertionError: if input data is not supported by MemoryWritingAtomicFlow
|
| 32 |
+
"""
|
| 33 |
assert "memory_files" in input_data, "memory_files not passed to MemoryWritingAtomicFlow"
|
| 34 |
assert any(item in input_data for item in self.supported_memories), "no memories to write"
|
| 35 |
|
| 36 |
def _call(self, input_data: Dict[str, Any]):
|
| 37 |
+
"""
|
| 38 |
+
Write memory to memory files.
|
| 39 |
+
:param input_data: the input data to write
|
| 40 |
+
:type input_data: Dict[str, Any]
|
| 41 |
+
:return: the output data
|
| 42 |
+
:rtype: Dict[str, Any]
|
| 43 |
+
:raises AssertionError: if logs is not in memory_files
|
| 44 |
+
"""
|
| 45 |
try:
|
| 46 |
if "summary" in input_data:
|
| 47 |
assert "logs" in input_data["memory_files"], "there is summary to write, but no logs file in memory_files"
|
|
|
|
| 58 |
self,
|
| 59 |
input_data: Dict[str, Any]
|
| 60 |
):
|
| 61 |
+
"""
|
| 62 |
+
Run the atomic flow.
|
| 63 |
+
:param input_data: the input data to run
|
| 64 |
+
:type input_data: Dict[str, Any]
|
| 65 |
+
:return: the output data
|
| 66 |
+
:rtype: Dict[str, Any]
|
| 67 |
+
"""
|
| 68 |
self._check_input(input_data)
|
| 69 |
return self._call(input_data)
|
README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
| 2 |
|
| 3 |
* [MemoryWritingAtomicFlow](#MemoryWritingAtomicFlow)
|
| 4 |
* [MemoryWritingAtomicFlow](#MemoryWritingAtomicFlow.MemoryWritingAtomicFlow)
|
|
|
|
|
|
|
| 5 |
* [run\_memwrite](#run_memwrite)
|
| 6 |
* [\_\_init\_\_](#__init__)
|
| 7 |
|
|
@@ -17,7 +19,7 @@
|
|
| 17 |
class MemoryWritingAtomicFlow(AtomicFlow)
|
| 18 |
```
|
| 19 |
|
| 20 |
-
This class is used to write memory to memory files.
|
| 21 |
|
| 22 |
*Input Interface*:
|
| 23 |
- `summary` (str): summary to write to memory file (logs)
|
|
@@ -26,6 +28,42 @@ This class is used to write memory to memory files. For now, it writes summary t
|
|
| 26 |
*Output Interface*:
|
| 27 |
- `MemWrite_output` (str): message that whether memory write was successful
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
<a id="run_memwrite"></a>
|
| 30 |
|
| 31 |
# run\_memwrite
|
|
|
|
| 2 |
|
| 3 |
* [MemoryWritingAtomicFlow](#MemoryWritingAtomicFlow)
|
| 4 |
* [MemoryWritingAtomicFlow](#MemoryWritingAtomicFlow.MemoryWritingAtomicFlow)
|
| 5 |
+
* [\_\_init\_\_](#MemoryWritingAtomicFlow.MemoryWritingAtomicFlow.__init__)
|
| 6 |
+
* [run](#MemoryWritingAtomicFlow.MemoryWritingAtomicFlow.run)
|
| 7 |
* [run\_memwrite](#run_memwrite)
|
| 8 |
* [\_\_init\_\_](#__init__)
|
| 9 |
|
|
|
|
| 19 |
class MemoryWritingAtomicFlow(AtomicFlow)
|
| 20 |
```
|
| 21 |
|
| 22 |
+
This class is used to write memory to memory files.
|
| 23 |
|
| 24 |
*Input Interface*:
|
| 25 |
- `summary` (str): summary to write to memory file (logs)
|
|
|
|
| 28 |
*Output Interface*:
|
| 29 |
- `MemWrite_output` (str): message that whether memory write was successful
|
| 30 |
|
| 31 |
+
*Configuration Parameters*:
|
| 32 |
+
- `input_interface`: the input interface of the atomic flow
|
| 33 |
+
- `output_interface`: the output interface of the atomic flow
|
| 34 |
+
|
| 35 |
+
<a id="MemoryWritingAtomicFlow.MemoryWritingAtomicFlow.__init__"></a>
|
| 36 |
+
|
| 37 |
+
#### \_\_init\_\_
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
def __init__(**kwargs)
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
Initialize the atomic flow.
|
| 44 |
+
|
| 45 |
+
**Arguments**:
|
| 46 |
+
|
| 47 |
+
- `kwargs` (`Dict[str, Any]`): additional key-value arguments to pass to the atomic flow
|
| 48 |
+
|
| 49 |
+
<a id="MemoryWritingAtomicFlow.MemoryWritingAtomicFlow.run"></a>
|
| 50 |
+
|
| 51 |
+
#### run
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
def run(input_data: Dict[str, Any])
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
Run the atomic flow.
|
| 58 |
+
|
| 59 |
+
**Arguments**:
|
| 60 |
+
|
| 61 |
+
- `input_data` (`Dict[str, Any]`): the input data to run
|
| 62 |
+
|
| 63 |
+
**Returns**:
|
| 64 |
+
|
| 65 |
+
`Dict[str, Any]`: the output data
|
| 66 |
+
|
| 67 |
<a id="run_memwrite"></a>
|
| 68 |
|
| 69 |
# run\_memwrite
|