Skip to content

Commit

Permalink
updating iris to support executing from a tekton pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
strangiato committed May 14, 2024
1 parent 51fc689 commit 6a6c5ce
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pipelines/11_iris_training_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
load_dotenv(override=True)

kubeflow_endpoint = os.environ["KUBEFLOW_ENDPOINT"]
bearer_token = os.environ["BEARER_TOKEN"]


@dsl.component(
Expand Down Expand Up @@ -204,9 +203,27 @@ def iris_pipeline(model_obc: str = "iris-model"):

if __name__ == "__main__":
print(f"Connecting to kfp: {kubeflow_endpoint}")

sa_token_path = "/run/secrets/kubernetes.io/serviceaccount/token" # noqa: S105
if os.path.isfile(sa_token_path):
with open(sa_token_path) as f:
token = f.read().rstrip()
else:
token = os.environ["BEARER_TOKEN"]

# Check if the script is running in a k8s pod
# Get the CA from the service account if it is
# Skip the CA if it is not
sa_ca_cert = "/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
if os.path.isfile(sa_ca_cert):
ssl_ca_cert = sa_ca_cert
else:
ssl_ca_cert = None

client = kfp.Client(
host=kubeflow_endpoint,
existing_token=bearer_token,
ssl_ca_cert=ssl_ca_cert,
)
result = client.create_run_from_pipeline_func(iris_pipeline, arguments={}, experiment_name="iris")
print(f"Starting pipeline run with run_id: {result.run_id}")

0 comments on commit 6a6c5ce

Please sign in to comment.