Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions backend/test/resources/enhanced_artifact_pipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import kfp
from kfp import dsl
from kfp.components import create_component_from_func, OutputPath, InputPath

# Component 1: Data Processing
def process_data(input_text: str, processed_data: OutputPath()):
"""Process input data and create training dataset"""
# Simulate data processing
processed_content = f"PROCESSED: {input_text.upper()}"

with open(processed_data, 'w') as f:
f.write(processed_content)

print(f"Processed data saved to: {processed_data}")

# Component 2: Training (consumes processed data)
def train_model(training_data: InputPath(), model_path: OutputPath()):
"""Train a simple model using processed data"""
# Read processed data
with open(training_data, 'r') as f:
data = f.read()

# Simulate model training
model_content = f"MODEL_TRAINED_ON: {data}"

with open(model_path, 'w') as f:
f.write(model_content)

print(f"Model trained and saved to: {model_path}")

# Component 3: Evaluation
def evaluate_model(model: InputPath(), training_data: InputPath(), results: OutputPath()):
"""Evaluate model and produce results"""
# Read inputs
with open(model, 'r') as f:
model_data = f.read()

with open(training_data, 'r') as f:
train_data = f.read()

# Simulate evaluation
evaluation_results = f"EVALUATION: Model '{model_data}' trained on '{train_data}' - Score: 95%"

with open(results, 'w') as f:
f.write(evaluation_results)

print(f"Evaluation results saved to: {results}")
return evaluation_results

# Create components
process_data_op = create_component_from_func(process_data)
train_model_op = create_component_from_func(train_model)
evaluate_model_op = create_component_from_func(evaluate_model)

@dsl.pipeline(name="enhanced-ml-workflow-test")
def enhanced_artifact_pipeline(input_text: str = "kubeflow pipelines"):
"""Enhanced pipeline with realistic ML workflow: Data → Train → Evaluate"""

# Data processing task
process_task = process_data_op(input_text)
process_task.set_display_name("Process Training Data")

# Model training task (depends on processed data)
train_task = train_model_op(process_task.outputs['processed_data'])
train_task.set_display_name("Train ML Model")

# Model evaluation task (depends on both model and training data)
eval_task = evaluate_model_op(
train_task.outputs['model_path'],
process_task.outputs['processed_data']
)
eval_task.set_display_name("Evaluate Model")

# Return final results
return eval_task.outputs

if __name__ == "__main__":
kfp.compiler.Compiler().compile(
pipeline_func=enhanced_artifact_pipeline,
package_path="enhanced_artifact_pipeline.yaml"
)
print("Enhanced pipeline compiled!")
78 changes: 78 additions & 0 deletions sdk/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[build-system]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "kfp"
dynamic = ["version"]
description = "Kubeflow Pipelines SDK"
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.9.0"
license = {text = "Apache-2.0"}
authors = [
{name = "The Kubeflow Authors"}
]
keywords = ["kubeflow", "pipelines", "machine-learning", "mlops"]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"click>=8.1.8",
"click-option-group==0.5.7",
"docstring-parser>=0.7.3,<1",
"google-api-core>=1.31.5,<3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0",
"google-auth>=1.6.1,<3",
"google-cloud-storage>=2.2.1,<4",
"kfp-pipeline-spec>=2.14.3,<3",
"kfp-server-api>=2.14.3,<3",
"kubernetes>=8.0.0,<31",
"protobuf>=6.31.1,<7.0",
"PyYAML>=5.3,<7",
"requests-toolbelt>=0.8.0,<2",
"tabulate>=0.8.6,<1",
"urllib3<3.0.0",
'typing-extensions>=3.7.4,<5; python_version<"3.9"'
]


[project.optional-dependencies]
all = [
"docker",
"kfp-kubernetes",
"nbclient>=0.10,<1",
"ipykernel>=6,<7",
"jupyter_client>=7,<9"
]
kubernetes = ["kfp-kubernetes"]
notebooks = [
"nbclient>=0.10,<1",
"ipykernel>=6,<7",
"jupyter_client>=7,<9"
]

[project.urls]
Documentation = "https://kubeflow-pipelines.readthedocs.io/en/stable/"
Bug-Tracker = "https://github.com/kubeflow/pipelines/issues"
Source = "https://github.com/kubeflow/pipelines/tree/master/sdk"
Changelog = "https://github.com/kubeflow/pipelines/blob/master/sdk/RELEASE.md"

[project.scripts]
dsl-compile = "kfp.cli.compile_:main"
kfp = "kfp.cli.__main__:main"

[tool.setuptools.dynamic]
version = {attr = "kfp.version.__version__"}
Loading