-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: droctothorpe <[email protected]> Co-authored-by: zazulam <[email protected]> Co-authored-by: CarterFendley <[email protected]>
- Loading branch information
1 parent
6ce09a0
commit 00fb964
Showing
11 changed files
with
406 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from subdagio import artifact | ||
from subdagio import artifact_cache | ||
from subdagio import multiple_artifacts_namedtuple | ||
from subdagio import multiple_parameters | ||
from subdagio import multiple_parameters_namedtuple | ||
from subdagio import parameter | ||
from subdagio import parameter_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
|
||
from kfp import Client | ||
from kfp import dsl | ||
|
||
|
||
@dsl.component | ||
def core_comp(dataset: dsl.Output[dsl.Dataset]): | ||
with open(dataset.path, 'w') as f: | ||
f.write('foo') | ||
|
||
|
||
@dsl.component | ||
def crust_comp(input: dsl.Dataset): | ||
with open(input.path, 'r') as f: | ||
print('input: ', f.read()) | ||
|
||
|
||
@dsl.pipeline | ||
def core() -> dsl.Dataset: | ||
task = core_comp() | ||
task.set_caching_options(False) | ||
|
||
return task.output | ||
|
||
|
||
@dsl.pipeline | ||
def mantle() -> dsl.Dataset: | ||
dag_task = core() | ||
dag_task.set_caching_options(False) | ||
|
||
return dag_task.output | ||
|
||
|
||
@dsl.pipeline(name=os.path.basename(__file__).removesuffix('.py') + '-pipeline') | ||
def crust(): | ||
dag_task = mantle() | ||
dag_task.set_caching_options(False) | ||
|
||
task = crust_comp(input=dag_task.output) | ||
task.set_caching_options(False) | ||
|
||
|
||
if __name__ == '__main__': | ||
# Compiler().compile(pipeline_func=crust, package_path=f"{__file__.removesuffix('.py')}.yaml") | ||
client = Client() | ||
client.create_run_from_pipeline_func(crust) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
|
||
from kfp import Client | ||
from kfp import dsl | ||
|
||
|
||
@dsl.component | ||
def core_comp(dataset: dsl.Output[dsl.Dataset]): | ||
with open(dataset.path, 'w') as f: | ||
f.write('foo') | ||
|
||
|
||
@dsl.component | ||
def crust_comp(input: dsl.Dataset): | ||
with open(input.path, 'r') as f: | ||
print('input: ', f.read()) | ||
|
||
|
||
@dsl.pipeline | ||
def core() -> dsl.Dataset: | ||
task = core_comp() | ||
|
||
return task.output | ||
|
||
|
||
@dsl.pipeline | ||
def mantle() -> dsl.Dataset: | ||
dag_task = core() | ||
return dag_task.output | ||
|
||
|
||
@dsl.pipeline(name=os.path.basename(__file__).removesuffix('.py') + '-pipeline') | ||
def crust(): | ||
dag_task = mantle() | ||
|
||
task = crust_comp(input=dag_task.output) | ||
|
||
|
||
if __name__ == '__main__': | ||
# Compiler().compile(pipeline_func=crust, package_path=f"{__file__.removesuffix('.py')}.yaml") | ||
client = Client() | ||
client.create_run_from_pipeline_func(crust) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import os | ||
from typing import NamedTuple | ||
|
||
from kfp import Client | ||
from kfp import dsl | ||
|
||
|
||
@dsl.component | ||
def core_comp(ds1: dsl.Output[dsl.Dataset], ds2: dsl.Output[dsl.Dataset]): | ||
with open(ds1.path, 'w') as f: | ||
f.write('foo') | ||
with open(ds2.path, 'w') as f: | ||
f.write('bar') | ||
|
||
|
||
@dsl.component | ||
def crust_comp( | ||
ds1: dsl.Dataset, | ||
ds2: dsl.Dataset, | ||
): | ||
with open(ds1.path, 'r') as f: | ||
print('ds1: ', f.read()) | ||
with open(ds2.path, 'r') as f: | ||
print('ds2: ', f.read()) | ||
|
||
|
||
@dsl.pipeline | ||
def core() -> NamedTuple( | ||
'outputs', | ||
ds1=dsl.Dataset, | ||
ds2=dsl.Dataset, | ||
): # type: ignore | ||
task = core_comp() | ||
task.set_caching_options(False) | ||
|
||
return task.outputs | ||
|
||
|
||
@dsl.pipeline | ||
def mantle() -> NamedTuple( | ||
'outputs', | ||
ds1=dsl.Dataset, | ||
ds2=dsl.Dataset, | ||
): # type: ignore | ||
dag_task = core() | ||
dag_task.set_caching_options(False) | ||
|
||
return dag_task.outputs | ||
|
||
|
||
@dsl.pipeline(name=os.path.basename(__file__).removesuffix('.py') + '-pipeline') | ||
def crust(): | ||
dag_task = mantle() | ||
dag_task.set_caching_options(False) | ||
|
||
task = crust_comp( | ||
ds1=dag_task.outputs['ds1'], | ||
ds2=dag_task.outputs['ds2'], | ||
) | ||
task.set_caching_options(False) | ||
|
||
|
||
if __name__ == '__main__': | ||
# Compiler().compile(pipeline_func=crust, package_path=f"{__file__.removesuffix('.py')}.yaml") | ||
client = Client() | ||
client.create_run_from_pipeline_func(crust) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
|
||
from kfp import Client | ||
from kfp import dsl | ||
from kfp.compiler import Compiler | ||
|
||
|
||
@dsl.component | ||
def core_comp() -> int: | ||
return 1 | ||
|
||
|
||
@dsl.component | ||
def crust_comp(x: int, y: int): | ||
print('sum :', x + y) | ||
|
||
|
||
@dsl.pipeline | ||
def core() -> int: | ||
task = core_comp() | ||
task.set_caching_options(False) | ||
|
||
return task.output | ||
|
||
|
||
@dsl.pipeline | ||
def mantle() -> int: | ||
dag_task = core() | ||
dag_task.set_caching_options(False) | ||
|
||
return dag_task.output | ||
|
||
|
||
@dsl.pipeline(name=os.path.basename(__file__).removesuffix('.py') + '-pipeline') | ||
def crust(): | ||
dag_task = mantle() | ||
dag_task.set_caching_options(False) | ||
|
||
task = crust_comp(x=2, y=dag_task.output) | ||
task.set_caching_options(False) | ||
|
||
|
||
if __name__ == '__main__': | ||
Compiler().compile( | ||
pipeline_func=crust, | ||
package_path=f"{__file__.removesuffix('.py')}.yaml") | ||
client = Client() | ||
client.create_run_from_pipeline_func(crust) |
Oops, something went wrong.