JonnyIncognito commented on a change in pull request #6210: [AIRFLOW-5567] 
BaseAsyncOperator
URL: https://github.com/apache/airflow/pull/6210#discussion_r335271755
 
 

 ##########
 File path: airflow/models/base_async_operator.py
 ##########
 @@ -0,0 +1,96 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Base Asynchronous Operator for kicking off a long running
+operations and polling for completion with reschedule mode.
+"""
+from functools import wraps
+from airflow.sensors.base_sensor_operator import BaseSensorOperator
+from airflow.exceptions import AirflowException
+from airflow.models.xcom import XCOM_EXTERNAL_RESOURCE_ID_KEY
+
+class BaseAsyncOperator(BaseSensorOperator, SkipMixin):
 
 Review comment:
   Ref. the name, I agree that it's important for people to consider this as 
something that takes action and that's implied by the Operator suffix. That's 
why I consider BaseSensorOperator in its current form to have a misleading 
name: it implies that it's both for taking action and sensing. Luckily the 
actual derived sensor implementations are all suffixed with Sensor - e.g. 
EmrStepSensor - which doesn't mislead.
   
   I feel like having "Async" in your new class highlights the wrong thing. 
It's not that it is async in the sense of non-synchronous or rescheduled 
(Airflow terminology) that makes this class unique, since all sensors derived 
from BaseSensorOperator *can* operate as async/rescheduled: it implies not 
occupying a task slot. What differentiates your class is that it combines 
action and sensing. That's why I tend to think that the already used 
BaseSensorOperator would actually be a great name to describe what your new 
class does; so why not enhance the existing class to optionally do the action 
part?
   
   There might be technical reasons to have a separate class - e.g. code is 
easier to read or to reduce risk by extending rather than modifying (SOLID) - 
but I can't think of a better alternative to "Async": BaseDoThenWaitOperator 
(hah); BaseActionSensor; eventually back to BaseSensorOperator.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to