Created
July 10, 2023 22:18
-
-
Save gregsheremeta/311887e78fe7309904ec1e9d1f31fe17 to your computer and use it in GitHub Desktop.
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
"""Test pipeline to exercise various data flow mechanisms.""" | |
import kfp | |
"""Producer""" | |
def send_file( | |
outgoing_file: kfp.components.OutputPath(), | |
): | |
def create_test_file(path, size): | |
with open(path, 'wb') as file: | |
file.seek(size) | |
file.write(b'0') | |
create_test_file(outgoing_file, 1024 * 1024 * 50) # 50MB file, this causes error | |
# create_test_file(outgoing_file, 50) # 50 byte file, this works fine | |
"""Consumer""" | |
def receive_file( | |
incoming_file: kfp.components.InputPath(), | |
save_artifact: kfp.components.OutputPath("MyArtifact"), | |
): | |
import os | |
import shutil | |
print("reading %s, size is %s" % (incoming_file, os.path.getsize(incoming_file))) | |
print("copying in %s to out %s" % (incoming_file, save_artifact)) | |
shutil.copyfile(incoming_file, save_artifact) | |
"""Build the producer component""" | |
send_file_op = kfp.components.create_component_from_func( | |
send_file, | |
base_image="registry.access.redhat.com/ubi8/python-38", | |
) | |
"""Build the consumer component""" | |
receive_file_op = kfp.components.create_component_from_func( | |
receive_file, | |
base_image="registry.access.redhat.com/ubi8/python-38", | |
) | |
"""Wire up the pipeline""" | |
@kfp.dsl.pipeline( | |
name="Test Data Passing Pipeline 1", | |
) | |
def wire_up_pipeline(): | |
send_file_task = send_file_op() | |
receive_file_task = receive_file_op( | |
send_file_task.output, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment