damavis / airflow-pentaho-plugin

Pentaho plugin for Apache Airflow - Orquestate pentaho transformations and jobs from Airflow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parameters format in command line

sberbanker opened this issue · comments

Hello.

Using airflow-pentaho-plugin version 1.0.4 I see that parameters are not passing to transformation because they look like "-param1=param_value". But as it described in Pentaho 9.1 docs they should look like "-param:param1=param_value".

So I changed PanOperator class like this

def execute(self, context):  # pylint: disable=unused-argument
        conn = self._get_pentaho_client()

        arguments = {
            'dir': self.dir,
            'trans': self.trans,
            'level': self.level,
            'logfile': self.logfile,
            'safemode': 'true' if self.safemode else 'false',
            'maxloglines': str(self.maxloglines),
            'maxlogtimeout': str(self.maxlogtimeout)
        }
        # arguments.update(self.params)
        if self.file:
            arguments.update({'file': self.file})
            arguments.update({'norep': 'true'})

        self.command_line = conn.build_command('pan', arguments, self.params)
        output = self._run_command()

        if self.xcom_push_flag:
            return output

And PentahoClient class

        def build_command(self, command, arguments, params):
            line = [self._build_tool_command(command),
                    self._build_connection_arguments()]
            for k, val in arguments.items():
                line.append(self._build_argument(k, val))
            for k, val in params.items():
                line.append(self._build_argument(f'param:{k}', val))

            command_line = ' '.join(line)
            return command_line

And everything got to work.
My task definition in Dag

    trans1 = PanOperator(
        dag=dag,
        task_id='trans1',
        xcom_push=True,
        file='/home/airflow/repo/upload.ktr',
        trans="",
        params={"version_id": "102"})

My environment: Kubuntu 20.10, Python 3.8.6, apache airflow 2.0.1, pdi 9.1.0.0-324.

Hi @sberbanker

You're right. I'll fix it on the next relase, 1.0.5.

Hi @sberbanker

I've just release the fixed version 1.0.5 -> https://pypi.org/project/airflow-pentaho-plugin/.
I'll wait for any feedback before closing the issue.

Thank you.

Hi @piffall
Checked PanOperator. Works good. Thanks!