Browse Source

Fixed D417 and remove file

tags/test-git
Mati-ur-rehman-017 10 months ago
parent
commit
ef3f988dc4
7 changed files with 39 additions and 26 deletions
  1. +0
    -3
      .vscode/settings.json
  2. +13
    -11
      binaries/cli/src/template/python/operator/operator-template.py
  3. +10
    -5
      examples/python-operator-dataflow/llm_op.py
  4. +2
    -1
      examples/reachy2/parse_bbox.py
  5. +2
    -1
      examples/reachy2/parse_bbox_minimal.py
  6. +2
    -1
      examples/reachy2/pick_place.py
  7. +10
    -4
      node-hub/llama-factory-recorder/llama_factory_recorder/main.py

+ 0
- 3
.vscode/settings.json View File

@@ -1,3 +0,0 @@
{
"cmake.sourceDirectory": "/home/granger/coding/dora/examples/cmake-dataflow"
}

+ 13
- 11
binaries/cli/src/template/python/operator/operator-template.py View File

@@ -15,17 +15,19 @@ class Operator:
send_output,
) -> DoraStatus:
"""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:
CONTINUE means that the operator will
keep listening for further inputs.


+ 10
- 5
examples/python-operator-dataflow/llm_op.py View File

@@ -70,7 +70,8 @@ def extract_python_code_blocks(text):

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
-------
@@ -94,11 +95,13 @@ def extract_json_code_blocks(text):

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
-------
- 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```"
@@ -117,11 +120,13 @@ def remove_last_line(python_code):

Parameters
----------
- python_code: A string representing Python source code.
python_code : str
A string representing Python source code.

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


+ 2
- 1
examples/reachy2/parse_bbox.py View File

@@ -17,7 +17,8 @@ def extract_bboxes(json_text):

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
-------


+ 2
- 1
examples/reachy2/parse_bbox_minimal.py View File

@@ -17,7 +17,8 @@ def extract_bboxes(json_text) -> (np.ndarray, np.ndarray):

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
-------


+ 2
- 1
examples/reachy2/pick_place.py View File

@@ -86,7 +86,8 @@ def extract_bboxes(json_text) -> (np.ndarray, np.ndarray):

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
-------


+ 10
- 4
node-hub/llama-factory-recorder/llama_factory_recorder/main.py View File

@@ -18,13 +18,19 @@ DEFAULT_QUESTION = os.getenv(

def write_dict_to_json(file_path, key: str, new_data):
"""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
----------
- 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:


Loading…
Cancel
Save