Skip to content

Commit a097968

Browse files
gmfrascamprahl
authored andcommitted
chore: Update Usage Section to use example_pipelines.py (plural)
- example_pipelines.py, not example_pipeline.py, is the required filename Signed-off-by: Giulio Frasca <[email protected]>
1 parent ddce513 commit a097968

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

scripts/generate_readme/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ uv run python -m scripts.generate_readme --component components/some_category/my
2626
- **Google-style docstring parsing**: Extracts parameter descriptions and return values
2727
- **Custom content preservation**: Preserves user-added content after the `<!-- custom-content -->` marker
2828
- **Type annotation support**: Handles complex type annotations including Optional, Union, and generics
29-
- **Component-specific usage examples**: Includes/Updates an example usage for the given pipeline or component, if provided via `example_pipeline.py`
29+
- **Component-specific usage examples**: Includes/Updates an example usage for the given pipeline or component, if provided via `example_pipelines.py`
3030

3131
## Custom Content
3232

scripts/generate_readme/README.md.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{% endif %}
2424

2525
{% if example_code %}
26-
## Usage Example 🧪
26+
## Usage Examples 🧪
2727

2828
```python
2929
{{ example_code }}

scripts/generate_readme/content_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, metadata: Dict[str, Any], source_dir: Path):
2323
self.metadata = metadata
2424
self.source_dir = source_dir
2525
self.metadata_file = source_dir / 'metadata.yaml'
26-
self.example_file = source_dir / 'example_pipeline.py'
26+
self.example_file = source_dir / 'example_pipelines.py'
2727
self.owners_file = source_dir / 'OWNERS'
2828
self.feature_metadata = self._load_feature_metadata()
2929

@@ -81,7 +81,7 @@ def _load_owners(self) -> Dict[str, Any]:
8181
return {}
8282
return {}
8383

84-
def _load_example_pipeline(self) -> str:
84+
def _load_example_pipelines(self) -> str:
8585
"""Load the Example Pipeline file if it exists.
8686
8787
Returns:
@@ -92,7 +92,7 @@ def _load_example_pipeline(self) -> str:
9292
with open(self.example_file, 'r', encoding='utf-8') as f:
9393
return f.read()
9494
except Exception as e:
95-
logger.warning(f"Error reading Example Pipeline file ({self.example_file}): {e}")
95+
logger.warning(f"Error reading Example Pipelines file ({self.example_file}): {e}")
9696
return ''
9797
return ''
9898

@@ -244,7 +244,7 @@ def _prepare_template_context(self) -> Dict[str, Any]:
244244
}
245245

246246
# Load example pipeline if it exists
247-
example_code = self._load_example_pipeline()
247+
example_code = self._load_example_pipelines()
248248

249249
# Extract links for separate Additional Resources section (removes from feature_metadata)
250250
links = self.feature_metadata.pop('links', {})

scripts/generate_readme/tests/test_content_generator.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_prepare_template_context(self, component_dir, sample_extracted_metadata
207207
assert context['title'] == 'Sample Component'
208208
assert context['component_name'] == 'sample_component'
209209

210-
# Check example_code is empty string when no example_pipeline.py exists
210+
# Check example_code is empty string when no example_pipelines.py file exists
211211
assert context['example_code'] == ''
212212

213213
# Check formatted metadata exists
@@ -296,17 +296,17 @@ def test_load_example_pipelines(self, component_dir, sample_extracted_metadata):
296296
component_dir
297297
)
298298

299-
# When no example_pipeline.py exists, should return empty string
300-
example_code = generator._load_example_pipeline()
299+
# When no example_pipelines.py exists, should return empty string
300+
example_code = generator._load_example_pipelines()
301301
assert example_code == ''
302302

303-
# Create an example_pipeline.py file
304-
example_file = component_dir / 'example_pipeline.py'
303+
# Create an example_pipelines.py file
304+
example_file = component_dir / 'example_pipelines.py'
305305
example_content = 'from kfp import dsl\n\n@dsl.pipeline()\ndef my_pipeline():\n pass'
306306
example_file.write_text(example_content)
307307

308308
# Now it should load the content
309-
example_code = generator._load_example_pipeline()
309+
example_code = generator._load_example_pipelines()
310310
assert example_code == example_content
311311

312312
def test_generate_readme_component(self, component_dir, sample_extracted_metadata):
@@ -318,18 +318,18 @@ def test_generate_readme_component(self, component_dir, sample_extracted_metadat
318318

319319
readme = generator.generate_readme()
320320

321-
# Check all sections are present (except Usage Example since no example_pipeline.py exists)
321+
# Check all sections are present (except Usage Examples since no example_pipelines.py exists)
322322
assert '# Sample Component' in readme
323323
assert '## Overview' in readme
324324
assert '## Inputs' in readme
325325
assert '## Outputs' in readme
326326
assert '## Metadata' in readme
327327

328-
# Usage Example should NOT be present when example_pipeline.py doesn't exist
329-
assert '## Usage Example' not in readme
328+
# Usage Examples should NOT be present when example_pipelines.py doesn't exist
329+
assert '## Usage Examples' not in readme
330330

331-
# Now test with example_pipeline.py present
332-
example_file = component_dir / 'example_pipeline.py'
331+
# Now test with example_pipelines.py present
332+
example_file = component_dir / 'example_pipelines.py'
333333
example_file.write_text('from kfp import dsl\n\n@dsl.pipeline()\ndef test_pipeline():\n pass')
334334

335335
# Regenerate readme
@@ -339,8 +339,8 @@ def test_generate_readme_component(self, component_dir, sample_extracted_metadat
339339
)
340340
readme2 = generator2.generate_readme()
341341

342-
# Now Usage Example should be present
343-
assert '## Usage Example' in readme2
342+
# Now Usage Examples should be present
343+
assert '## Usage Examples' in readme2
344344
assert 'from kfp import dsl' in readme2
345345

346346
def test_generate_readme_pipeline(self, pipeline_dir, sample_extracted_metadata):
@@ -360,8 +360,8 @@ def test_generate_readme_pipeline(self, pipeline_dir, sample_extracted_metadata)
360360
assert '## Outputs' in readme
361361
assert '## Metadata' in readme
362362

363-
# Usage example should NOT be present for pipelines
364-
assert '## Usage Example' not in readme
363+
# Usage Examples should NOT be present for pipelines
364+
assert '## Usage Examples' not in readme
365365

366366
def test_generate_readme_empty_metadata(self, temp_dir):
367367
"""Test README generation with empty metadata."""

scripts/generate_readme/tests/test_writer.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def test_generate_component_readme(self, component_dir):
108108
assert "## Overview" in content
109109
assert "## Inputs" in content
110110
assert "## Outputs" in content
111-
# Usage Example should NOT be present when example_pipeline.py doesn't exist
112-
assert "## Usage Example" not in content
111+
# Usage Examples should NOT be present when example_pipelines.py doesn't exist
112+
assert "## Usage Examples" not in content
113113
assert "## Metadata" in content
114114

115115
def test_generate_pipeline_readme(self, pipeline_dir):
@@ -127,7 +127,7 @@ def test_generate_pipeline_readme(self, pipeline_dir):
127127
content = readme_file.read_text()
128128
assert "# Sample Pipeline" in content
129129
assert "## Overview" in content
130-
assert "## Usage Example" not in content # Pipelines don't have usage examples
130+
assert "## Usage Examples" not in content # Pipelines don't have usage examples
131131

132132
def test_generate_preserves_custom_content(self, component_dir):
133133
"""Test that generation preserves custom content."""
@@ -254,14 +254,14 @@ def test_readme_format_is_markdown(self, component_dir):
254254
assert '|' in content # Has tables
255255
assert '##' in content # Has subheaders
256256

257-
def test_readme_with_example_pipeline(self, component_dir):
258-
"""Test that README includes usage example when example_pipeline.py exists."""
259-
# Create example_pipeline.py file
260-
example_file = component_dir / 'example_pipeline.py'
257+
def test_readme_with_example_pipelines(self, component_dir):
258+
"""Test that README includes usage examples when example_pipelines.py exists."""
259+
# Create example_pipelines.py file
260+
example_file = component_dir / 'example_pipelines.py'
261261
example_content = '''from kfp import dsl
262262
from kubeflow.pipelines.components.components import sample_category
263263
264-
@dsl.pipeline(name='example-pipeline')
264+
@dsl.pipeline(name='example-pipelines')
265265
def my_pipeline():
266266
sample_component_task = sample_category.sample_component(
267267
input_path="input.txt",
@@ -281,6 +281,6 @@ def my_pipeline():
281281

282282
# Now code blocks should be present
283283
assert '```' in content # Has code blocks
284-
assert '## Usage Example' in content
284+
assert '## Usage Examples' in content
285285
assert 'from kfp import dsl' in content
286286

0 commit comments

Comments
 (0)