Skip to content

Commit 6cff465

Browse files
authored
fix: make example paths os-friendly using os.path.join() (#1066)
fix: maxke example paths os friendly
1 parent 38c2fe4 commit 6cff465

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

docs/docs/examples/examples/codebase_index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ The flow is composed of the following steps:
5555
We will index the CocoIndex codebase. Here we use the `LocalFile` source to ingest files from the CocoIndex codebase root directory.
5656

5757
```python
58+
import os
59+
5860
@cocoindex.flow_def(name="CodeEmbedding")
5961
def code_embedding_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.DataScope):
6062
data_scope["files"] = flow_builder.add_source(
61-
cocoindex.sources.LocalFile(path="../..",
63+
cocoindex.sources.LocalFile(path=os.path.join('..', '..'),
6264
included_patterns=["*.py", "*.rs", "*.toml", "*.md", "*.mdx"],
6365
excluded_patterns=[".*", "target", "**/node_modules"]))
6466
code_embeddings = data_scope.add_collector()

docs/docs/examples/examples/docs_to_knowledge_graph.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ and then build a knowledge graph.
5454
We will process CocoIndex documentation markdown files (`.md`, `.mdx`) from the `docs/core` directory ([markdown files](https://github.com/cocoindex-io/cocoindex/tree/main/docs/docs/core), [deployed docs](https://cocoindex.io/docs/core/basics)).
5555

5656
```python
57+
import os
58+
5759
@cocoindex.flow_def(name="DocsToKG")
5860
def docs_to_kg_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.DataScope):
5961
data_scope["documents"] = flow_builder.add_source(
60-
cocoindex.sources.LocalFile(path="../../docs/docs/core",
62+
cocoindex.sources.LocalFile(path=os.path.join('..', '..', 'docs', 'docs', 'core'),
6163
included_patterns=["*.md", "*.mdx"]))
6264
```
6365

docs/docs/examples/examples/patient_form_extraction.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Alternatively, we have native support for Gemini, Ollama, LiteLLM. You can choos
5050
Add source from local files.
5151

5252
```python
53+
import os
54+
5355
@cocoindex.flow_def(name="PatientIntakeExtraction")
5456
def patient_intake_extraction_flow(
5557
flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.DataScope
@@ -58,7 +60,7 @@ def patient_intake_extraction_flow(
5860
Define a flow that extracts patient information from intake forms.
5961
"""
6062
data_scope["documents"] = flow_builder.add_source(
61-
cocoindex.sources.LocalFile(path="data/patient_forms", binary=True)
63+
cocoindex.sources.LocalFile(path=os.path.join('data', 'patient_forms'), binary=True)
6264
)
6365
```
6466

examples/code_embedding/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def code_embedding_flow(
4545
"""
4646
data_scope["files"] = flow_builder.add_source(
4747
cocoindex.sources.LocalFile(
48-
path="../..",
48+
path=os.path.join('..', '..'),
4949
included_patterns=["*.py", "*.rs", "*.toml", "*.md", "*.mdx"],
5050
excluded_patterns=["**/.*", "target", "**/node_modules"],
5151
)

examples/docs_to_knowledge_graph/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import dataclasses
66
import cocoindex
7+
import os
78

89
neo4j_conn_spec = cocoindex.add_auth_entry(
910
"Neo4jConnection",
@@ -66,7 +67,7 @@ def docs_to_kg_flow(
6667
"""
6768
data_scope["documents"] = flow_builder.add_source(
6869
cocoindex.sources.LocalFile(
69-
path="../../docs/docs/core", included_patterns=["*.md", "*.mdx"]
70+
path=os.path.join('..', '..','docs','docs','core'), included_patterns=["*.md", "*.mdx"]
7071
)
7172
)
7273

examples/patient_intake_extraction/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def patient_intake_extraction_flow(
118118
Define a flow that extracts patient information from intake forms.
119119
"""
120120
data_scope["documents"] = flow_builder.add_source(
121-
cocoindex.sources.LocalFile(path="data/patient_forms", binary=True)
121+
cocoindex.sources.LocalFile(path=os.path.join('data', 'patient_forms'), binary=True)
122122
)
123123

124124
patients_index = data_scope.add_collector()

0 commit comments

Comments
 (0)