| @@ -1,3 +0,0 @@ | |||||
| { | |||||
| "cmake.sourceDirectory": "/home/granger/coding/dora/examples/cmake-dataflow" | |||||
| } | |||||
| @@ -15,17 +15,19 @@ class Operator: | |||||
| send_output, | send_output, | ||||
| ) -> DoraStatus: | ) -> DoraStatus: | ||||
| """TODO :Description. | """TODO :Description. | ||||
| Args: | |||||
| dora_event: Event containing an `id`, `data` and `metadata`. | |||||
| send_output Callable[[str, bytes | pa.Array, Optional[dict]], None]: | |||||
| Function for sending output to the dataflow: | |||||
| - First argument is the `output_id` | |||||
| - Second argument is the data as either bytes or `pa.Array` | |||||
| - Third argument is dora metadata dict | |||||
| e.g.: `send_output("bbox", pa.array([100], type=pa.uint8()), dora_event["metadata"])`. | |||||
| Returns: | |||||
| Parameters | |||||
| ---------- | |||||
| dora_event : dict | |||||
| Event containing an `id`, `data`, and `metadata`. | |||||
| send_output : Callable[[str, bytes | pa.Array, Optional[dict]], None] | |||||
| Function for sending output to the dataflow. The first argument is the `output_id`, the second | |||||
| argument is the data (either as bytes or a pa.Array), and the third argument is the dora metadata | |||||
| dictionary. For example: | |||||
| send_output("bbox", pa.array([100], type=pa.uint8()), dora_event["metadata"]). | |||||
| Returns | |||||
| ------- | |||||
| DoraStatus: | DoraStatus: | ||||
| CONTINUE means that the operator will | CONTINUE means that the operator will | ||||
| keep listening for further inputs. | keep listening for further inputs. | ||||
| @@ -70,7 +70,8 @@ def extract_python_code_blocks(text): | |||||
| Parameters | Parameters | ||||
| ---------- | ---------- | ||||
| - text: A string that may contain one or more Python code blocks. | |||||
| text : str | |||||
| A string that may contain one or more Python code blocks. | |||||
| Returns | Returns | ||||
| ------- | ------- | ||||
| @@ -94,11 +95,13 @@ def extract_json_code_blocks(text): | |||||
| Parameters | Parameters | ||||
| ---------- | ---------- | ||||
| - text: A string that may contain one or more json code blocks. | |||||
| text : str | |||||
| A string that may contain one or more json code blocks. | |||||
| Returns | Returns | ||||
| ------- | ------- | ||||
| - A list of strings, where each string is a block of json code extracted from the text. | |||||
| list of str | |||||
| A list of strings, where each string is a block of json code extracted from the text. | |||||
| """ | """ | ||||
| pattern = r"```json\n(.*?)\n```" | pattern = r"```json\n(.*?)\n```" | ||||
| @@ -117,11 +120,13 @@ def remove_last_line(python_code): | |||||
| Parameters | Parameters | ||||
| ---------- | ---------- | ||||
| - python_code: A string representing Python source code. | |||||
| python_code : str | |||||
| A string representing Python source code. | |||||
| Returns | Returns | ||||
| ------- | ------- | ||||
| - A string with the last line removed. | |||||
| str | |||||
| A string with the last line removed. | |||||
| """ | """ | ||||
| lines = python_code.split("\n") # Split the string into lines | lines = python_code.split("\n") # Split the string into lines | ||||
| @@ -17,7 +17,8 @@ def extract_bboxes(json_text): | |||||
| Parameters | Parameters | ||||
| ---------- | ---------- | ||||
| json_text (str): JSON string containing bounding box data, including ```json markers. | |||||
| json_text : str | |||||
| JSON string containing bounding box data, including ```json markers. | |||||
| Returns | Returns | ||||
| ------- | ------- | ||||
| @@ -17,7 +17,8 @@ def extract_bboxes(json_text) -> (np.ndarray, np.ndarray): | |||||
| Parameters | Parameters | ||||
| ---------- | ---------- | ||||
| json_text (str): JSON string containing bounding box data, including ```json markers. | |||||
| json_text : str | |||||
| JSON string containing bounding box data, including ```json markers. | |||||
| Returns | Returns | ||||
| ------- | ------- | ||||
| @@ -86,7 +86,8 @@ def extract_bboxes(json_text) -> (np.ndarray, np.ndarray): | |||||
| Parameters | Parameters | ||||
| ---------- | ---------- | ||||
| json_text (str): JSON string containing bounding box data, including ```json markers. | |||||
| json_text : str | |||||
| JSON string containing bounding box data, including ```json markers. | |||||
| Returns | Returns | ||||
| ------- | ------- | ||||
| @@ -18,13 +18,19 @@ DEFAULT_QUESTION = os.getenv( | |||||
| def write_dict_to_json(file_path, key: str, new_data): | def write_dict_to_json(file_path, key: str, new_data): | ||||
| """Write a dictionary to a JSON file. | """Write a dictionary to a JSON file. | ||||
| If the file already contains a list of entries,the new data will be appended to that list. Otherwise, it will create a new list. | |||||
| If the JSON file already contains an object with the given key mapping to a list of entries, | |||||
| the new data will be appended to that list. Otherwise, a new key is created with a list | |||||
| containing the provided dictionary. | |||||
| Parameters | Parameters | ||||
| ---------- | ---------- | ||||
| - file_path: str, the path to the JSON file. | |||||
| - new_data: dict, the dictionary to add to the JSON file. | |||||
| file_path : str | |||||
| The path to the JSON file. | |||||
| key : str | |||||
| The key under which the new dictionary entry will be stored. | |||||
| new_data : dict | |||||
| The dictionary to add to the JSON file. | |||||
| """ | """ | ||||
| try: | try: | ||||