Add support for decorated pipeline steps (#1154)

This commit is contained in:
allegroai
2024-01-03 22:18:39 +02:00
parent cf39029cb2
commit 4bd6b20a62
4 changed files with 185 additions and 21 deletions

View File

@@ -0,0 +1,24 @@
from clearml import PipelineDecorator
def our_decorator(func):
def function_wrapper(*args, **kwargs):
return func(*args, **kwargs) + 1
return function_wrapper
@PipelineDecorator.component()
@our_decorator
def step():
return 1
@PipelineDecorator.pipeline(name="test_decorated", project="test_decorated")
def pipeline():
result = step()
assert result == 2
if __name__ == "__main__":
PipelineDecorator.run_locally()
pipeline()

View File

@@ -0,0 +1,27 @@
from clearml import PipelineController
def our_decorator(func):
def function_wrapper(*args, **kwargs):
return func(*args, **kwargs) + 1
return function_wrapper
@our_decorator
def step():
return 1
def evaluate(step_return):
assert step_return == 2
if __name__ == "__main__":
pipeline = PipelineController(name="test_decorated", project="test_decorated")
pipeline.add_function_step(name="step", function=step, function_return=["step_return"])
pipeline.add_function_step(
name="evaluate",
function=evaluate,
function_kwargs=dict(step_return='${step.step_return}')
)
pipeline.start_locally(run_pipeline_steps_locally=True)