Skip to content

Commit 8a7b0e5

Browse files
committed
feat(sdk+api) Implement Semaphores and Mutexes Pipeline Configuration
Signed-off-by: ddalvi <[email protected]>
1 parent cac3739 commit 8a7b0e5

File tree

4 files changed

+59
-14
lines changed

4 files changed

+59
-14
lines changed

api/v2alpha1/go/pipelinespec/pipeline_spec.pb.go

Lines changed: 30 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v2alpha1/pipeline_spec.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,5 +1103,9 @@ message PlatformDeploymentConfig {
11031103

11041104
// Spec for pipeline-level config options. See PipelineConfig DSL class.
11051105
message PipelineConfig {
1106-
// TODO add pipeline-level configs
1106+
// Name of the semaphore key to control pipeline concurrency
1107+
string semaphore_key = 1;
1108+
1109+
// Name of the mutex to ensure mutual exclusion
1110+
string mutex_name = 2;
11071111
}

sdk/python/kfp/compiler/pipeline_spec_builder.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,11 +2011,13 @@ def write_pipeline_spec_to_file(
20112011

20122012
def _merge_pipeline_config(pipelineConfig: pipeline_config.PipelineConfig,
20132013
platformSpec: pipeline_spec_pb2.PlatformSpec):
2014-
# TODO: add pipeline config options (ttl, semaphore, etc.) to the dict
2015-
# json_format.ParseDict(
2016-
# {'pipelineConfig': {
2017-
# '<some pipeline config option>': pipelineConfig.<get that value>,
2018-
# }}, platformSpec.platforms['kubernetes'])
2014+
json_format.ParseDict(
2015+
{
2016+
'pipelineConfig': {
2017+
'semaphoreName': pipelineConfig.semaphore_key,
2018+
'mutexName': pipelineConfig.mutex_name,
2019+
}
2020+
}, platformSpec.platforms['kubernetes'])
20192021

20202022
return platformSpec
20212023

sdk/python/kfp/dsl/pipeline_config.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ class PipelineConfig:
1818
"""PipelineConfig contains pipeline-level config options."""
1919

2020
def __init__(self):
21-
pass
21+
self.semaphore_key = None
22+
self.mutex_name = None
2223

23-
# TODO add pipeline level configs
24+
def set_semaphore_key(self, semaphore_key: str):
25+
"""Set the name of the semaphore to control pipeline concurrency.
26+
27+
Args:
28+
semaphore_key (str): Name of the semaphore.
29+
"""
30+
self.semaphore_key = semaphore_key.strip()
31+
32+
def set_mutex_name(self, mutex_name: str):
33+
"""Set the name of the mutex to ensure mutual exclusion.
34+
35+
Args:
36+
mutex_name (str): Name of the mutex.
37+
"""
38+
self.mutex_name = mutex_name.strip()

0 commit comments

Comments
 (0)