Copilot commented on code in PR #356:
URL: https://github.com/apache/hugegraph-ai/pull/356#discussion_r3343889199


##########
hugegraph-llm/src/tests/test_vector_index_utils.py:
##########
@@ -0,0 +1,129 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from types import SimpleNamespace
+
+import gradio as gr
+import pytest
+from docx import Document
+
+from hugegraph_llm.utils import vector_index_utils
+from hugegraph_llm.utils.vector_index_utils import read_documents
+
+
+def _build_pdf(content_stream: bytes) -> bytes:
+    objects = [
+        b"<< /Type /Catalog /Pages 2 0 R >>",
+        b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
+        (
+            b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] "
+            b"/Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>"
+        ),
+        b"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
+        (b"<< /Length " + str(len(content_stream)).encode() + b" >>\nstream\n" 
+ content_stream + b"\nendstream"),
+    ]
+
+    pdf = b"%PDF-1.4\n"
+    offsets = []
+    for index, obj in enumerate(objects, start=1):
+        offsets.append(len(pdf))
+        pdf += f"{index} 0 obj\n".encode()
+        pdf += obj + b"\nendobj\n"
+
+    xref_offset = len(pdf)
+    pdf += f"xref\n0 {len(objects) + 1}\n".encode()
+    pdf += b"0000000000 65535 f \n"
+    for offset in offsets:
+        pdf += f"{offset:010d} 00000 n \n".encode()
+
+    pdf += (f"trailer\n<< /Size {len(objects) + 1} /Root 1 0 R 
>>\nstartxref\n{xref_offset}\n%%EOF\n").encode()

Review Comment:
   This trailing-string construction is a single very long line and is likely 
to fail `ruff format --check` in CI. Splitting the trailer into multiple 
shorter string fragments keeps the formatting stable and improves readability.



##########
hugegraph-llm/src/tests/test_vector_index_utils.py:
##########
@@ -0,0 +1,129 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from types import SimpleNamespace
+
+import gradio as gr
+import pytest
+from docx import Document
+
+from hugegraph_llm.utils import vector_index_utils
+from hugegraph_llm.utils.vector_index_utils import read_documents
+
+
+def _build_pdf(content_stream: bytes) -> bytes:
+    objects = [
+        b"<< /Type /Catalog /Pages 2 0 R >>",
+        b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
+        (
+            b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] "
+            b"/Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>"
+        ),
+        b"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
+        (b"<< /Length " + str(len(content_stream)).encode() + b" >>\nstream\n" 
+ content_stream + b"\nendstream"),

Review Comment:
   This long bytes-concatenation line is likely to be reformatted by `ruff 
format --check` (CI runs Ruff formatting checks). Wrapping the expression 
across multiple lines will keep formatting stable and avoid CI failures.



##########
hugegraph-llm/src/tests/test_vector_index_utils.py:
##########
@@ -0,0 +1,129 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from types import SimpleNamespace
+
+import gradio as gr
+import pytest
+from docx import Document
+
+from hugegraph_llm.utils import vector_index_utils
+from hugegraph_llm.utils.vector_index_utils import read_documents
+
+
+def _build_pdf(content_stream: bytes) -> bytes:
+    objects = [
+        b"<< /Type /Catalog /Pages 2 0 R >>",
+        b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
+        (
+            b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] "
+            b"/Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>"
+        ),
+        b"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
+        (b"<< /Length " + str(len(content_stream)).encode() + b" >>\nstream\n" 
+ content_stream + b"\nendstream"),
+    ]
+
+    pdf = b"%PDF-1.4\n"
+    offsets = []
+    for index, obj in enumerate(objects, start=1):
+        offsets.append(len(pdf))
+        pdf += f"{index} 0 obj\n".encode()
+        pdf += obj + b"\nendobj\n"
+
+    xref_offset = len(pdf)
+    pdf += f"xref\n0 {len(objects) + 1}\n".encode()
+    pdf += b"0000000000 65535 f \n"
+    for offset in offsets:
+        pdf += f"{offset:010d} 00000 n \n".encode()
+
+    pdf += (f"trailer\n<< /Size {len(objects) + 1} /Root 1 0 R 
>>\nstartxref\n{xref_offset}\n%%EOF\n").encode()
+    return pdf
+
+
+def test_read_documents_reads_txt_file(tmp_path):
+    txt_path = tmp_path / "sample.txt"
+    txt_path.write_text("hello hugegraph", encoding="utf-8")
+
+    result = read_documents([SimpleNamespace(name=str(txt_path))], "")

Review Comment:
   This new test module may not run in CI: the HugeGraph-LLM workflow invokes 
pytest on a fixed list of paths (e.g., `src/tests/...` directories plus 
`src/tests/test_utils.py`) and does not include 
`src/tests/test_vector_index_utils.py`. Consider updating the CI pytest targets 
to include this file (or a broader `src/tests/` pattern) so the new PDF upload 
behavior is exercised in CI.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to