Skip to content

Conversation

@VaniHaripriya
Copy link
Contributor

@VaniHaripriya VaniHaripriya commented Dec 17, 2025

Description of your changes:

Added a new CI check to validate the package entries in pyproject.toml.

Sample run for an example of the CI working.

Checklist:

Pre-Submission Checklist

Additional Checklist Items for New or Updated Components/Pipelines:

  • metadata.yaml includes fresh lastVerified timestamp
  • All required files are present and complete
  • OWNERS file lists appropriate maintainers
  • README provides clear documentation with usage examples
  • Component follows snake_case naming convention
  • No security vulnerabilities in dependencies

@google-oss-prow google-oss-prow bot requested review from HumairAK and mprahl December 17, 2025 15:01
@VaniHaripriya VaniHaripriya marked this pull request as draft December 17, 2025 15:02
@google-oss-prow google-oss-prow bot added size/L and removed size/XL labels Dec 17, 2025
@VaniHaripriya VaniHaripriya force-pushed the package-validation-ci branch 2 times, most recently from 0d33245 to eddc10f Compare December 17, 2025 20:17
@VaniHaripriya VaniHaripriya marked this pull request as ready for review December 17, 2025 20:17
@VaniHaripriya VaniHaripriya force-pushed the package-validation-ci branch 3 times, most recently from 660ff58 to ddc342c Compare December 18, 2025 22:53
Comment on lines 159 to 167
(tmp_path / "__init__.py").write_text("")

components_dir = tmp_path / "components"
components_dir.mkdir()
(components_dir / "__init__.py").write_text("")

training_dir = components_dir / "training"
training_dir.mkdir()
(training_dir / "__init__.py").write_text("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is duplicated. It appears 3 times in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the duplicate code and created common directory structure for the tests.

if (repo_root / "__init__.py").exists():
packages.add("kfp_components")

def _discover_recursive(directory: Path, base_package: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base_package is unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the function to use base_package.

except FileNotFoundError:
raise RuntimeError(f"pyproject.toml not found at {pyproject_path}")
except tomllib.TOMLDecodeError as e:
raise RuntimeError(f"Failed to parse pyproject.toml: {e}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tomllib.TOMLDecodeError is caught and re-raised as a RuntimeError, which loses the original traceback context.

Suggested change
raise RuntimeError(f"Failed to parse pyproject.toml: {e}")
raise RuntimeError(f"Failed to parse pyproject.toml: {e}") from e

assert not is_valid
assert len(errors) == 1
assert "Extra packages" in errors[0]
assert "kfp_components.components.nonexistent" in errors[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to verify kfp_components.components too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! added an assert statement for kfp_components.components.

import sys
import tomllib
from pathlib import Path
from typing import Set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Set import from typing isn't needed in Python 3.9+. You can use builtin set[str] directly (like you already do with list[str] on lines 90 and 102). Consider updating lines 24, 30, and 66 to use set[str] and removing this import for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed Set import and updated with set[str].

@VaniHaripriya VaniHaripriya force-pushed the package-validation-ci branch 3 times, most recently from 3f582eb to 1b515f5 Compare January 5, 2026 19:00
@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mprahl for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Comment on lines 8 to 14
sys.path.insert(0, str(Path(__file__).parent.parent))

from validate_package_entries import (
discover_packages,
read_pyproject_packages,
validate_package_entries,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're no longer using sys.path.insert(0, str(Path(__file__).parent.parent)). We're creating a __init.py__ file and using relative imports instead.
PTAL at https://github.com/kubeflow/pipelines-components/blob/main/scripts/README.md#import-conventions for more info.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use relative imports.

Comment on lines 18 to 20
def get_repo_root() -> Path:
"""Get the repository root directory."""
return Path(__file__).parent.parent.parent.resolve()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've sent a PR that includes this method as a lib for reuse.
#57
If that PR is merged before this one, please use that instead of duplicating it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to reuse get_repo_root() from common utility functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to hold this PR until #57 gets merged.

@VaniHaripriya VaniHaripriya force-pushed the package-validation-ci branch 5 times, most recently from 7809865 to 1fdbbea Compare January 7, 2026 22:12
@VaniHaripriya VaniHaripriya requested a review from hbelmiro January 7, 2026 22:13
if (repo_root / "__init__.py").exists():
packages.add("kfp_components")

def _discover_recursive(directory: Path, base_package: str) -> None:
Copy link
Contributor

@hbelmiro hbelmiro Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional:
Is this defined inside another function by purpose?
Personally, I think it's ugly. I understand though that it allows us to use packages without passing it as a parameter.
I'm fine with leaving it as it is, unless it was not intentional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated _discover_recursive as a separate function that takes packages as a parameter.

@VaniHaripriya VaniHaripriya force-pushed the package-validation-ci branch from 0da92b7 to 79cc441 Compare January 9, 2026 20:36
@VaniHaripriya VaniHaripriya requested a review from hbelmiro January 9, 2026 20:37
Copy link
Contributor

@hbelmiro hbelmiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label Jan 9, 2026
@mprahl mprahl merged commit f75900f into kubeflow:main Jan 12, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants