Repository: kubeflow/pipelines

Issue:
[Component] AutoML Tables component should show link as an artifact
/cc @jessiezcc 
/cc @jingzhang36 
/assign @Ark-kun 

It will be helpful if components in 
https://github.com/kubeflow/pipelines/tree/b89aabbce5d48fca10817c3ed3ecc2acf6c0066a/components/gcp/automl can show related AutoML tables url as markdown artifacts.

e.g.
> We would like to be able to click on a link that would take us from the component’s page to an AutoML Tables models page


Discussion:
@Ark-kun would you have time to work on this? Shall we sync about the plan?
Is it possible to make it so that the UX visualizes all artifacts of types 'Markdown' and `Uri`?
@Ark-kun Yes, that's doable.
Do AutoML tables component already have these artifacts?
> Do AutoML tables component already have these artifacts?

No, but it would be pretty easy to add.
Yep, that sounds like a good idea.
Shall we make an one-pager design doc for this? or go right into the implementation.

It is some duplication of existing features, I think that will be my only concern.
@Bobgy I've looked at the URLs and I now I wonder whether hard-coding the URL format in the code is a good idea. The UX and URLs can change, breaking the existing outputs of components.

Here is the model_id artifact that's already returned by the component: `projects/140626129697/locations/us-central1/models/TBL6224612401770135552`

The model page URL is currently `https://XXX.YYY.google.com/automl-tables/locations/us-central1/datasets/TBL5661697632720912384;modelId=TBL6224612401770135552;task=basic/train?project=140626129697`

Do you want me to add the transformation to the component code?

The URL for external users is probably different.
@Ark-kun I understand the concerns, but I don't see a better place to add the transformation.

It wouldn't be a scalable solution if each component needs some UI code change for integration, nor would it be suitable for visualization server I think.

We can only rely on AutoML team to make url backward compatible e.g. when they change url format, they should have auto redirect from old location to the new one.
OK. I'll add the transformation to the code.
The funny thing is that I cannot really check what the real URL should be since I'll need a non-Google account for that. But I am pretty confident that I know what it should be.

In the future I think that visualizations might be a good place for the transformation. They could even embed some model vis/view in the node details page and they can update when AutoML web pages update.

Resolving patch:
diff --git a/components/gcp/automl/create_dataset_for_tables/component.py b/components/gcp/automl/create_dataset_for_tables/component.py
--- a/components/gcp/automl/create_dataset_for_tables/component.py
+++ b/components/gcp/automl/create_dataset_for_tables/component.py
@@ -24,13 +24,9 @@ def automl_create_dataset_for_tables(
     retry=None, #=google.api_core.gapic_v1.method.DEFAULT,
     timeout: float = None, #=google.api_core.gapic_v1.method.DEFAULT,
     metadata: dict = None,
-) -> NamedTuple('Outputs', [('dataset_path', str), ('create_time', str), ('dataset_id', str)]):
+) -> NamedTuple('Outputs', [('dataset_path', str), ('create_time', str), ('dataset_id', str), ('dataset_url', 'URI')]):
     '''automl_create_dataset_for_tables creates an empty Dataset for AutoML tables
     '''
-    import sys
-    import subprocess
-    subprocess.run([sys.executable, '-m', 'pip', 'install', 'google-cloud-automl==0.4.0', '--quiet', '--no-warn-script-location'], env={'PIP_DISABLE_PIP_VERSION_CHECK': '1'}, check=True)
-
     import google
     from google.cloud import automl
     client = automl.AutoMlClient()
@@ -50,9 +46,19 @@ def automl_create_dataset_for_tables(
     )
     print(dataset)
     dataset_id = dataset.name.rsplit('/', 1)[-1]
-    return (dataset.name, dataset.create_time, dataset_id)
+    dataset_url = 'https://console.cloud.google.com/automl-tables/locations/{region}/datasets/{dataset_id}/schemav2?project={project_id}'.format(
+        project_id=gcp_project_id,
+        region=gcp_region,
+        dataset_id=dataset_id,
+    )
+    return (dataset.name, dataset.create_time, dataset_id, dataset_url)
 
 
 if __name__ == '__main__':
     import kfp
-    kfp.components.func_to_container_op(automl_create_dataset_for_tables, output_component_file='component.yaml', base_image='python:3.7')
+    kfp.components.func_to_container_op(
+        automl_create_dataset_for_tables,
+        output_component_file='component.yaml',
+        base_image='python:3.7',
+        packages_to_install=['google-cloud-automl==0.4.0']
+    )
diff --git a/components/gcp/automl/create_model_for_tables/component.py b/components/gcp/automl/create_model_for_tables/component.py
--- a/components/gcp/automl/create_model_for_tables/component.py
+++ b/components/gcp/automl/create_model_for_tables/component.py
@@ -24,11 +24,7 @@ def automl_create_model_for_tables(
     input_feature_column_paths: list = None,
     optimization_objective: str = 'MAXIMIZE_AU_PRC',
     train_budget_milli_node_hours: int = 1000,
-) -> NamedTuple('Outputs', [('model_path', str), ('model_id', str)]):
-    import sys
-    import subprocess
-    subprocess.run([sys.executable, '-m', 'pip', 'install', 'google-cloud-automl==0.4.0', '--quiet', '--no-warn-script-location'], env={'PIP_DISABLE_PIP_VERSION_CHECK': '1'}, check=True)
-
+) -> NamedTuple('Outputs', [('model_path', str), ('model_id', str), ('model_page_url', 'URI'),]):
     from google.cloud import automl
     client = automl.AutoMlClient()
 
@@ -50,9 +46,21 @@ def automl_create_model_for_tables(
     print(result)
     model_name = result.name
     model_id = model_name.rsplit('/', 1)[-1]
-    return (model_name, model_id)
+    model_url = 'https://console.cloud.google.com/automl-tables/locations/{region}/datasets/{dataset_id};modelId={model_id};task=basic/train?project={project_id}'.format(
+        project_id=gcp_project_id,
+        region=gcp_region,
+        dataset_id=dataset_id,
+        model_id=model_id,
+    )
+
+    return (model_name, model_id, model_url)
 
 
 if __name__ == '__main__':
     import kfp
-    kfp.components.func_to_container_op(automl_create_model_for_tables, output_component_file='component.yaml', base_image='python:3.7')
+    kfp.components.func_to_container_op(
+        automl_create_model_for_tables,
+        output_component_file='component.yaml',
+        base_image='python:3.7',
+        packages_to_install=['google-cloud-automl==0.4.0']
+    )


Test patch: