Skip to content

Commit

Permalink
Add argo UI urls to gubernator metadata (kubeflow#29)
Browse files Browse the repository at this point in the history
Would like to provide a link to workflow URLs in gubernator.

Changes made:

Pass ui_urls into create_finished to use in the metadata.
  • Loading branch information
jose5918 authored and jlewi committed Feb 14, 2018
1 parent d80d85c commit 475e426
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions py/kubeflow/testing/prow_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def create_started():
# TODO(jlewi): Replace create_finished in tensorflow/k8s/py/prow.py with this
# version. We should do that when we switch tensorflow/k8s to use Argo instead
# of Airflow.
def create_finished(success):
def create_finished(success, ui_urls):
"""Create a string containing the contents for finished.json.
Args:
Expand All @@ -62,7 +62,9 @@ def create_finished(success):
# Dictionary of extra key value pairs to display to the user.
# TODO(jlewi): Perhaps we should add the GCR path of the Docker image
# we are running in. We'd have to plumb this in from bootstrap.
"metadata": {},
"metadata": {
"ui-urls": ui_urls
},
}

return json.dumps(finished)
Expand Down
8 changes: 5 additions & 3 deletions py/kubeflow/testing/prow_artifacts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ def testCreateStartedPresubmit(self, mock_time): # pylint: disable=no-self-use
def testCreateFinished(self, mock_time): # pylint: disable=no-self-use
"""Test create finished job."""
mock_time.return_value = 1000

test_urls = "https://example.com"
expected = {
"timestamp": 1000,
"result": "FAILED",
"metadata": {},
"metadata": {
"ui-urls": "https://example.com"
},
}

actual = prow_artifacts.create_finished(False)
actual = prow_artifacts.create_finished(False, test_urls)

self.assertEquals(expected, json.loads(actual))

Expand Down
8 changes: 5 additions & 3 deletions py/kubeflow/testing/run_e2e_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def create_started_file(bucket):
target = os.path.join(prow_artifacts.get_gcs_dir(bucket), "started.json")
upload_to_gcs(contents, target)

def create_finished_file(bucket, success):
def create_finished_file(bucket, success, ui_urls):
"""Create the started file in gcs for gubernator."""
contents = prow_artifacts.create_finished(success)
contents = prow_artifacts.create_finished(success, ui_urls)

target = os.path.join(prow_artifacts.get_gcs_dir(bucket), "finished.json")
upload_to_gcs(contents, target)
Expand Down Expand Up @@ -115,6 +115,7 @@ def run(args, file_handler):

api_client = k8s_client.ApiClient()
workflow_names = []
ui_urls = []
for w in workflows:
app_dir = w.app_dir
# Create the name for the workflow
Expand Down Expand Up @@ -173,6 +174,7 @@ def run(args, file_handler):

ui_url = ("http://testing-argo.kubeflow.io/timeline/kubeflow-test-infra/{0}"
";tab=workflow".format(workflow_name))
ui_urls.append(ui_url)
logging.info("URL for workflow: %s", ui_url)

success = True
Expand All @@ -190,7 +192,7 @@ def run(args, file_handler):
success = False
logging.error("Time out waiting for Workflows %s to finish", ",".join(workflow_names))
finally:
create_finished_file(args.bucket, success)
create_finished_file(args.bucket, success, ",".join(ui_urls))

# Upload logs to GCS. No logs after this point will appear in the
# file in gcs
Expand Down

0 comments on commit 475e426

Please sign in to comment.