[GitHub] [airflow] joeyfreund commented on a change in pull request #7400: [AIRFLOW-6759] Added MLEngine operator/hook to cancel MLEngine jobs

2020-02-11 Thread GitBox
joeyfreund commented on a change in pull request #7400: [AIRFLOW-6759] Added 
MLEngine operator/hook to cancel MLEngine jobs
URL: https://github.com/apache/airflow/pull/7400#discussion_r377743755
 
 

 ##
 File path: airflow/providers/google/cloud/operators/mlengine.py
 ##
 @@ -1015,3 +1015,58 @@ def check_existing_job(existing_job):
 if finished_training_job['state'] != 'SUCCEEDED':
 self.log.error('MLEngine training job failed: %s', 
str(finished_training_job))
 raise RuntimeError(finished_training_job['errorMessage'])
+
+
+class MLEngineTrainingJobFailureOperator(BaseOperator):
+
+"""
+Operator for cleaning up failed MLEngine training job.
+
+:param job_id: A unique templated id for the submitted Google MLEngine
+training job. (templated)
+:type job_id: str
+:param project_id: The Google Cloud project name within which MLEngine 
training job should run.
+If set to None or missing, the default project_id from the GCP 
connection is used. (templated)
 
 Review comment:
   Same as the comment above, it seems like the code raises an error if 
`project_id` is none/missing.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [airflow] joeyfreund commented on a change in pull request #7400: [AIRFLOW-6759] Added MLEngine operator/hook to cancel MLEngine jobs

2020-02-11 Thread GitBox
joeyfreund commented on a change in pull request #7400: [AIRFLOW-6759] Added 
MLEngine operator/hook to cancel MLEngine jobs
URL: https://github.com/apache/airflow/pull/7400#discussion_r377742121
 
 

 ##
 File path: airflow/providers/google/cloud/hooks/mlengine.py
 ##
 @@ -148,6 +148,51 @@ def create_job(
 
 return self._wait_for_job_done(project_id, job_id)
 
+@CloudBaseHook.fallback_to_default_project_id
+def cancel_job(
+self,
+job_id,
+project_id: Optional[str] = None
+) -> Dict:
+
+"""
+Cancels a MLEngine job.
+
+:param project_id: The Google Cloud project id within which MLEngine
+job will be launched. If set to None or missing, the default 
project_id from the GCP
 
 Review comment:
   This comment (describing the behaviour when `project_id` is `None`) is 
inconsistent with the code below.


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:
us...@infra.apache.org


With regards,
Apache Git Services