Last active
July 17, 2023 21:11
-
-
Save gregsheremeta/d0292900e62c012a3969c94980440150 to your computer and use it in GitHub Desktop.
a5 - same as a2, but with empty string in OutputPath
This file contains hidden or 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( | |
outgoingfile: kfp.components.OutputPath(), | |
): | |
import urllib.request | |
print("starting download...") | |
urllib.request.urlretrieve("http://212.183.159.230/20MB.zip", outgoingfile) | |
print("done") | |
"""Consumer""" | |
def receive_file( | |
incomingfile: kfp.components.InputPath(), | |
saveartifact: kfp.components.OutputPath(""), | |
): | |
import os | |
import shutil | |
print("reading %s, size is %s" % (incomingfile, os.path.getsize(incomingfile))) | |
with open(incomingfile, "rb") as f: | |
b = f.read(1) | |
print("read byte: %s" % b) | |
f.close() | |
print("copying in %s to out %s" % (incomingfile, saveartifact)) | |
shutil.copyfile(incomingfile, saveartifact) | |
"""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(): | |
import json | |
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