Skip to content

Commit 0950e84

Browse files
committed
fixed ruff errors, yamllint,pythonlint and removed yaml try except block
Signed-off-by: sduvvuri1603 <sduvvuri@redhat.com>
1 parent 57fedc5 commit 0950e84

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

.github/scripts/compile_check/compile_check.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,8 @@
1818
from dataclasses import dataclass, field
1919
from pathlib import Path
2020
from typing import Dict, Iterable, List, Optional, Sequence, Tuple
21-
22-
try:
23-
import yaml
24-
except ImportError as exc: # pragma: no cover - import guard
25-
sys.stderr.write(
26-
"PyYAML is required to run compile_check.py. "
27-
"Install it with `pip install pyyaml`.\n"
28-
)
29-
raise
21+
22+
import yaml
3023

3124
try:
3225
from packaging.specifiers import SpecifierSet
@@ -72,7 +65,9 @@ def add_warning(self, message: str) -> None:
7265

7366

7467
def parse_args(argv: Optional[Sequence[str]] = None) -> argparse.Namespace:
75-
parser = argparse.ArgumentParser(description="Compile Kubeflow components and pipelines.")
68+
parser = argparse.ArgumentParser(
69+
description="Compile Kubeflow components and pipelines."
70+
)
7671
parser.add_argument(
7772
"--tier",
7873
choices=["core", "all"],
@@ -164,7 +159,9 @@ def create_targets(
164159
for metadata_path, tier, target_kind in discovered:
165160
if normalized_filters:
166161
absolute_metadata_dir = metadata_path.parent.resolve()
167-
if not any(absolute_metadata_dir.is_relative_to(f) for f in normalized_filters):
162+
if not any(
163+
absolute_metadata_dir.is_relative_to(f) for f in normalized_filters
164+
):
168165
continue
169166

170167
try:
@@ -177,10 +174,16 @@ def create_targets(
177174
logging.debug("Skipping %s (compile_check disabled).", metadata_path)
178175
continue
179176

180-
module_filename = "component.py" if target_kind == "component" else "pipeline.py"
177+
module_filename = (
178+
"component.py" if target_kind == "component" else "pipeline.py"
179+
)
181180
module_path = metadata_path.with_name(module_filename)
182181
if not module_path.exists():
183-
logging.error("Expected module %s not found for metadata %s", module_path, metadata_path)
182+
logging.error(
183+
"Expected module %s not found for metadata %s",
184+
module_path,
185+
metadata_path,
186+
)
184187
continue
185188

186189
module_import = build_module_import_path(module_path)
@@ -197,7 +200,9 @@ def create_targets(
197200
return targets
198201

199202

200-
def find_objects(module, target_kind: str) -> List[Tuple[str, base_component.BaseComponent]]:
203+
def find_objects(
204+
module, target_kind: str
205+
) -> List[Tuple[str, base_component.BaseComponent]]:
201206
found: List[Tuple[str, base_component.BaseComponent]] = []
202207
for attr_name in dir(module):
203208
attr = getattr(module, attr_name)
@@ -239,7 +244,9 @@ def validate_dependencies(metadata: Dict, result: ValidationResult) -> None:
239244
if not name:
240245
result.add_error(f"{label} is missing a `name` field.")
241246
if not version:
242-
result.add_error(f"{label} for {name or '<unknown>'} is missing a `version` field.")
247+
result.add_error(
248+
f"{label} for {name or '<unknown>'} is missing a `version` field."
249+
)
243250
elif SpecifierSet is not None:
244251
try:
245252
SpecifierSet(str(version))
@@ -347,7 +354,9 @@ def run_validation(args: argparse.Namespace) -> int:
347354
logging.info(
348355
"✓ %s compiled successfully (%s)",
349356
target.metadata.get("name", target.module_import),
350-
", ".join(result.compiled_objects) if result.compiled_objects else "no output",
357+
", ".join(result.compiled_objects)
358+
if result.compiled_objects
359+
else "no output",
351360
)
352361
else:
353362
logging.error(
@@ -359,7 +368,11 @@ def run_validation(args: argparse.Namespace) -> int:
359368
break
360369

361370
failed = [res for res in results if not res.success]
362-
logging.info("Validation complete: %d succeeded, %d failed.", len(results) - len(failed), len(failed))
371+
logging.info(
372+
"Validation complete: %d succeeded, %d failed.",
373+
len(results) - len(failed),
374+
len(failed),
375+
)
363376

364377
if failed:
365378
logging.error("Compile check failed for the targets listed above.")
@@ -379,4 +392,3 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
379392

380393
if __name__ == "__main__": # pragma: no cover - CLI entry point
381394
sys.exit(main())
382-

.github/scripts/compile_check/tests/test_compile_check.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,3 @@ def test_dependency_validation_failure(self) -> None:
140140

141141
if __name__ == "__main__":
142142
unittest.main()
143-

.github/workflows/compile-and-deps.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Compile and Validate Components
23

34
on:
@@ -20,6 +21,6 @@ jobs:
2021
python-version: "3.11"
2122

2223
- name: Run compile check
23-
run: |d
24-
uv run python .github/scripts/compile_check/compile_check.py --tier all
25-
24+
run: |
25+
uv run python .github/scripts/compile_check/compile_check.py \
26+
--tier all

0 commit comments

Comments
 (0)