-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyour_pipeline.py
More file actions
56 lines (43 loc) · 1.97 KB
/
Copy pathyour_pipeline.py
File metadata and controls
56 lines (43 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from kfp import dsl
import kfp
def delete_pipeline_by_name(client:kfp.Client, pipeline_name: str):
# List all pipelines
pipelines = client.list_pipelines().pipelines
# Find the pipeline with the given name
for pipeline in pipelines:
# print(f"Found pipeline: {pipeline.display_name} (ID: {pipeline.pipeline_id})")
if pipeline.display_name == pipeline_name:
# List versions of the pipeline
versions = client.list_pipeline_versions(pipeline.pipeline_id).pipeline_versions
# Delete all versions first
for version in versions:
print(version)
print(f"Deleting pipeline version: {version.display_name} (ID: {version.pipeline_version_id})")
client.delete_pipeline_version(pipeline.pipeline_id, version.pipeline_version_id)
# Now delete the pipeline itself
print(f"Deleting pipeline: {pipeline.display_name} (ID: {pipeline.pipeline_id})")
client.delete_pipeline(pipeline.pipeline_id)
return f"Pipeline {pipeline_name} and all its versions deleted successfully."
return f"Pipeline {pipeline_name} not found."
@dsl.component(base_image='localhost:5000/pynuclio_base_3.8')
def hello_world_op():
print('HEELOO WORLD!!')
@dsl.pipeline(
name="Simple pipeline",
description="A simple example of a Kubeflow pipeline"
)
def my_pipeline():
hello_world_op()
if __name__ == "__main__":
from kfp import compiler
pipeline_file = 'simple_pipeline.yaml'
name = 'test'
compiler.Compiler().compile(my_pipeline, pipeline_file)
client = kfp.Client()
delete_pipeline_by_name(client, name)
print('----------------- DELETED!!')
client.pipeline_uploads.upload_pipeline(pipeline_file, name='test', )
print('----------------- CREATED!!')
for i in range(2):
client.create_run_from_pipeline_func(my_pipeline, arguments={})
print('----------------- RAN!!')