Beispiel #1
0
    def _delete_pipeline_metadata(self, pipeline_name: Text):
        """Drops the database containing metadata produced by the pipeline.

    Args:
      pipeline_name: The name of the pipeline owning the database.
    """
        pod_name = self._get_mysql_pod_name()
        db_name = self._get_mlmd_db_name(pipeline_name)

        command = [
            'kubectl',
            '-n',
            'kubeflow',
            'exec',
            '-it',
            pod_name,
            '--',
            'mysql',
            '--user',
            'root',
            '--execute',
            'drop database if exists {};'.format(db_name),
        ]
        logging.info('Dropping MLMD DB with name: %s', db_name)

        with test_utils.Timer('DeletingMLMDDatabase'):
            subprocess.run(command, check=True)
Beispiel #2
0
    def _run_workflow(self,
                      workflow_file: Text,
                      workflow_name: Text,
                      parameter: Dict[Text, Text] = None):
        """Runs the specified workflow with Argo.

    Blocks until the workflow has run (successfully or not) to completion.

    Args:
      workflow_file: YAML file with Argo workflow spec for the pipeline.
      workflow_name: Name to use for the workflow.
      parameter: mapping from pipeline parameter name to its runtime value.
    """

        # TODO(ajaygopinathan): Consider using KFP cli instead.
        def _format_parameter(parameter: Dict[Text, Any]) -> List[Text]:
            """Format the pipeline parameter section of argo workflow."""
            if parameter:
                result = []
                for k, v in parameter.items():
                    result.append('-p')
                    result.append('{}={}'.format(k, v))
                return result
            else:
                return []

        run_command = [
            'argo',
            'submit',
            '--name',
            workflow_name,
            '--namespace',
            'kubeflow',
            '--serviceaccount',
            'pipeline-runner',
            workflow_file,
        ]
        run_command += _format_parameter(parameter)
        logging.info('Launching workflow %s with parameter %s', workflow_name,
                     _format_parameter(parameter))
        with test_utils.Timer('RunningPipelineToCompletion'):
            subprocess.run(run_command, check=True)
            # Wait in the loop while pipeline is pending or running state.
            status = 'Pending'
            while status in ('Pending', 'Running'):
                time.sleep(self._POLLING_INTERVAL_IN_SECONDS)
                status = self._get_argo_pipeline_status(workflow_name)