You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/02/25 20:25:33 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #7535: [AIRFLOW-6915] Adds AI Platform Console link for MLEngineStartTrainingOperator

kaxil commented on a change in pull request #7535: [AIRFLOW-6915] Adds AI Platform Console link for MLEngineStartTrainingOperator
URL: https://github.com/apache/airflow/pull/7535#discussion_r384106760
 
 

 ##########
 File path: tests/providers/google/cloud/operators/test_mlengine.py
 ##########
 @@ -404,6 +405,34 @@ def test_failed_job_error(self, mock_hook):
             project_id='test-project', job=self.TRAINING_INPUT, use_existing_job_fn=ANY)
         self.assertEqual('A failure message', str(context.exception))
 
+    @patch('airflow.providers.google.cloud.operators.mlengine.MLEngineHook')
+    def test_console_extra_link(self, mock_hook):
+        training_op = MLEngineStartTrainingJobOperator(
+            **self.TRAINING_DEFAULT_ARGS)
+
+        ti = TaskInstance(
+            task=training_op,
+            execution_date=DEFAULT_DATE,
+        )
+
+        job_id = self.TRAINING_DEFAULT_ARGS['job_id']
+        project_id = self.TRAINING_DEFAULT_ARGS['project_id']
+        gcp_metadata = {
+            "job_id": job_id,
+            "project_id": project_id,
+        }
+        ti.xcom_push(key='gcp_metadata', value=gcp_metadata)
+
+        self.assertEqual(
+            f"https://console.cloud.google.com/ai-platform/jobs/{job_id}?project={project_id}",
+            training_op.get_extra_links(DEFAULT_DATE, AIPlatformConsoleLink.name),
+        )
+
+        self.assertEqual(
+            '',
+            training_op.get_extra_links(datetime.datetime(2019, 1, 1), AIPlatformConsoleLink.name),
+        )
+
 
 Review comment:
   We need to add a test to check this Operator link works well with Serialization like:
   
   https://github.com/apache/airflow/blob/746d8de2fcaa9554b4ce7dbf261e4ab148233222/tests/providers/google/cloud/operators/test_bigquery.py#L503-L538

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services