ashb commented on a change in pull request #3115: [AIRFLOW-2193] Add ROperator for using R URL: https://github.com/apache/airflow/pull/3115#discussion_r256339600
########## File path: airflow/contrib/operators/r_operator.py ########## @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- +# +# Licensed 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. + +from builtins import bytes +import os +from tempfile import NamedTemporaryFile + +from airflow.models import BaseOperator +from airflow.utils.decorators import apply_defaults +from airflow.utils.file import TemporaryDirectory + +import rpy2.robjects as robjects +from rpy2.rinterface import RRuntimeError + + +class ROperator(BaseOperator): + """ + Execute an R script or command + + :param r_command: The command or a reference to an R script (must have + '.r' extension) to be executed (templated) + :type r_command: string + :param xcom_push: If xcom_push is True (default: False), the last line + written to stdout will also be pushed to an XCom (key 'return_value') + when the R command completes. + :type xcom_push: bool + :param output_encoding: encoding output from R (default: 'utf-8') + :type output_encoding: string + + """ + + template_fields = ('r_command',) + template_ext = ('.r', '.R') + ui_color = '#C8D5E6' + + @apply_defaults + def __init__( + self, + r_command, + xcom_push=False, Review comment: We recently unified this - there is (I think) a `do_xcom_push` flag on BaseOperrator, so this line, L57 should be removed, and the field checked on 82 should be `self.do_xcom_push` ```suggestion ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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
