示例#1
0
def create_pipeline(ctx: Context, engine: str, pipeline_path: str,
                    package_path: Optional[str],
                    build_target_image: Optional[str],
                    build_base_image: Optional[str],
                    skaffold_cmd: Optional[str], endpoint: Optional[str],
                    iap_client_id: Optional[str], namespace: str,
                    build_image: bool) -> None:
    """Command definition to create a pipeline."""
    # TODO(b/179847638): Delete checks for deprecated flags.
    _check_deprecated_image_build_flags(build_target_image, skaffold_cmd,
                                        package_path)

    if build_base_image is not None and not build_image:
        sys.exit(
            '--build-base-image used without --build-image. You have to use '
            '--build-image flag to build a container image for the pipeline.')

    # TODO(b/142358865): Add support for container building for Airflow and Beam
    # runners when they support container executors.
    click.echo('Creating pipeline')

    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_DSL_PATH] = pipeline_path
    ctx.flags_dict[labels.BASE_IMAGE] = build_base_image
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    ctx.flags_dict[labels.BUILD_IMAGE] = build_image
    handler_factory.create_handler(ctx.flags_dict).create_pipeline()
示例#2
0
 def testCreateHandlerOther(self):
     self.flags_dict[labels.ENGINE_FLAG] = 'flink'
     with self.assertRaises(Exception) as err:
         handler_factory.create_handler(self.flags_dict)
     self.assertEqual(
         str(err.exception), 'Engine {} is not supported.'.format(
             self.flags_dict[labels.ENGINE_FLAG]))
示例#3
0
 def test_create_handler_other(self):
     self.flags_dict[labels.ENGINE_FLAG] = 'beam'
     with self.assertRaises(RuntimeError) as err:
         handler_factory.create_handler(self.flags_dict)
     self.assertEqual(
         str(err.exception), 'Engine {} is not supported.'.format(
             self.flags_dict[labels.ENGINE_FLAG]))
示例#4
0
文件: pipeline.py 项目: zvrr/tfx
def compile_pipeline(ctx: Context, engine: Text, pipeline_path: Text,
                     package_path: Text) -> None:
  """Command definition to compile a pipeline."""
  click.echo('Compiling pipeline')
  ctx.flags_dict[labels.ENGINE_FLAG] = engine
  ctx.flags_dict[labels.PIPELINE_DSL_PATH] = pipeline_path
  ctx.flags_dict[labels.PIPELINE_PACKAGE_PATH] = package_path
  handler_factory.create_handler(ctx.flags_dict).compile_pipeline()
示例#5
0
 def test_create_handler_auto(self):
     self.flags_dict[labels.ENGINE_FLAG] = 'auto'
     with self.assertRaises(Exception) as err:
         handler_factory.create_handler(self.flags_dict)
     self.assertEqual(
         str(err.exception),
         'Orchestrator {} missing in the environment.'.format(
             self.flags_dict[labels.ENGINE_FLAG]))
示例#6
0
文件: run.py 项目: anitameh/tfx-1
def get_run(ctx: Context, engine: Text, pipeline_name: Text,
            run_id: Text) -> None:
  """Command definition to stop a run."""
  click.echo('Retrieving run status.')
  ctx.flags_dict[labels.ENGINE_FLAG] = engine
  ctx.flags_dict[labels.RUN_ID] = run_id
  ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
  handler_factory.create_handler(ctx.flags_dict).get_run()
示例#7
0
文件: pipeline.py 项目: zvrr/tfx
def list_pipelines(ctx: Context, engine: Text, endpoint: Text,
                   iap_client_id: Text, namespace: Text) -> None:
  """Command definition to list pipelines."""
  click.echo('Listing all pipelines')
  ctx.flags_dict[labels.ENGINE_FLAG] = engine
  ctx.flags_dict[labels.ENDPOINT] = endpoint
  ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
  ctx.flags_dict[labels.NAMESPACE] = namespace
  handler_factory.create_handler(ctx.flags_dict).list_pipelines()
示例#8
0
def compile_pipeline(ctx: Context, engine: str, pipeline_path: str,
                     package_path: str) -> None:
    """Command definition to compile a pipeline."""
    # TODO(b/179847638): Delete checks for deprecated flags.
    _check_deprecated_image_build_flags(pipeline_package_path=package_path)

    click.echo('Compiling pipeline')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_DSL_PATH] = pipeline_path
    handler_factory.create_handler(ctx.flags_dict).compile_pipeline()
示例#9
0
def delete_pipeline(ctx: Context, engine: str, pipeline_name: str,
                    endpoint: str, iap_client_id: str, namespace: str) -> None:
    """Command definition to delete a pipeline."""
    click.echo('Deleting pipeline')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    handler_factory.create_handler(ctx.flags_dict).delete_pipeline()
示例#10
0
def create_run(ctx: Context, engine: Text, pipeline_name: Text, endpoint: Text,
               iap_client_id: Text, namespace: Text) -> None:
    """Command definition to create a pipeline run."""
    click.echo('Creating a run for pipeline: ' + pipeline_name)
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    handler_factory.create_handler(ctx.flags_dict).create_run()
示例#11
0
文件: run.py 项目: htahir1/tfx
def delete_run(ctx: Context, engine: Text, run_id: Text, endpoint: Text,
               iap_client_id: Text, namespace: Text) -> None:
    """Command definition to delete a run."""
    click.echo('Deleting run.')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.RUN_ID] = run_id
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    handler_factory.create_handler(ctx.flags_dict).delete_run()
示例#12
0
def list_runs(ctx: Context, engine: str, pipeline_name: str, endpoint: str,
              iap_client_id: str, namespace: str) -> None:
    """Command definition to list all runs of a pipeline."""
    click.echo('Listing all runs of pipeline: ' + pipeline_name)
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    handler_factory.create_handler(ctx.flags_dict).list_runs()
示例#13
0
def terminate_run(ctx: Context, engine: str, run_id: str, endpoint: str,
                  iap_client_id: str, namespace: str) -> None:
    """Command definition to stop a run."""
    click.echo('Terminating run.')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.RUN_ID] = run_id
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    handler_factory.create_handler(ctx.flags_dict).terminate_run()
示例#14
0
def get_schema(ctx: Context, engine: Text, pipeline_name: Text, endpoint: Text,
               iap_client_id: Text, namespace: Text) -> None:
  """Command definition to infer latest schema."""
  click.echo('Getting latest schema.')
  ctx.flags_dict[labels.ENGINE_FLAG] = engine
  ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
  ctx.flags_dict[labels.ENDPOINT] = endpoint
  ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
  ctx.flags_dict[labels.NAMESPACE] = namespace
  handler_factory.create_handler(ctx.flags_dict).get_schema()
示例#15
0
def get_run(ctx: Context, engine: Text, pipeline_name: Text, run_id: Text,
            endpoint: Text, iap_client_id: Text, namespace: Text) -> None:
    """Command definition to stop a run."""
    click.echo('Retrieving run status.')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.RUN_ID] = run_id
    ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    handler_factory.create_handler(ctx.flags_dict).get_run()
示例#16
0
    def testCreateHandlerAirflow(self):
        try:
            from tfx.tools.cli.handler import airflow_handler  # pylint: disable=g-import-not-at-top
        except ImportError:
            self.skipTest('Airflow is not available.')

        self.flags_dict[labels.ENGINE_FLAG] = 'airflow'
        with mock.patch.object(airflow_handler,
                               'AirflowHandler',
                               autospec=True) as mock_airflow_handler:
            handler_factory.create_handler(self.flags_dict)
            mock_airflow_handler.assert_called_once_with(self.flags_dict)
示例#17
0
def create_pipeline(ctx: Context, engine: Text, pipeline_path: Text,
                    package_path: Text, endpoint: Text, iap_client_id: Text,
                    namespace: Text) -> None:
    """Command definition to create a pipeline."""
    click.echo('Creating pipeline')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_DSL_PATH] = pipeline_path
    ctx.flags_dict[labels.PIPELINE_PACKAGE_PATH] = package_path
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    handler_factory.create_handler(ctx.flags_dict).create_pipeline()
示例#18
0
文件: run.py 项目: htahir1/tfx
def create_run(ctx: Context, engine: str, pipeline_name: str, endpoint: str,
               iap_client_id: str, namespace: str, project: str,
               region: str) -> None:
    """Command definition to create a pipeline run."""
    click.echo('Creating a run for pipeline: ' + pipeline_name)
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    ctx.flags_dict[labels.GCP_PROJECT_ID] = project
    ctx.flags_dict[labels.GCP_REGION] = region
    handler_factory.create_handler(ctx.flags_dict).create_run()
示例#19
0
def update_pipeline(ctx: Context, engine: str, pipeline_path: str,
                    package_path: Optional[str], skaffold_cmd: Optional[str],
                    endpoint: Optional[str], iap_client_id: Optional[str],
                    namespace: str, build_image: bool) -> None:
    """Command definition to update a pipeline."""
    # TODO(b/179847638): Delete checks for deprecated flags.
    _check_deprecated_image_build_flags(None, skaffold_cmd, package_path)

    click.echo('Updating pipeline')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_DSL_PATH] = pipeline_path
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    ctx.flags_dict[labels.BUILD_IMAGE] = build_image
    handler_factory.create_handler(ctx.flags_dict).update_pipeline()
示例#20
0
文件: pipeline.py 项目: zzhmtxxhh/tfx
def create_pipeline(ctx: Context, engine: Text, pipeline_path: Text,
                    package_path: Text, build_target_image: Text,
                    skaffold_cmd: Text, endpoint: Text, iap_client_id: Text,
                    namespace: Text) -> None:
  """Command definition to create a pipeline."""
  # TODO(b/142358865): Add support for container building for Airflow and Beam
  # runners when they support container executors.
  click.echo('Creating pipeline')
  ctx.flags_dict[labels.ENGINE_FLAG] = engine
  ctx.flags_dict[labels.PIPELINE_DSL_PATH] = pipeline_path
  ctx.flags_dict[labels.PIPELINE_PACKAGE_PATH] = package_path
  ctx.flags_dict[labels.TARGET_IMAGE] = build_target_image
  ctx.flags_dict[labels.SKAFFOLD_CMD] = skaffold_cmd
  ctx.flags_dict[labels.ENDPOINT] = endpoint
  ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
  ctx.flags_dict[labels.NAMESPACE] = namespace
  handler_factory.create_handler(ctx.flags_dict).create_pipeline()
示例#21
0
 def testCreateHandlerKubeflow(self):
     flags_dict = {
         labels.ENGINE_FLAG: 'kubeflow',
         labels.ENDPOINT: 'dummyEndpoint',
         labels.IAP_CLIENT_ID: 'dummyID',
         labels.NAMESPACE: 'kubeflow',
     }
     from tfx.tools.cli.handler import kubeflow_handler  # pylint: disable=g-import-not-at-top
     self.assertIsInstance(handler_factory.create_handler(flags_dict),
                           kubeflow_handler.KubeflowHandler)
示例#22
0
def create_run(ctx: Context, engine: str, pipeline_name: str, endpoint: str,
               iap_client_id: str, namespace: str, project: str, region: str,
               runtime_parameter: Iterable[str]) -> None:
    """Command definition to create a pipeline run."""
    click.echo('Creating a run for pipeline: ' + pipeline_name)
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
    ctx.flags_dict[labels.ENDPOINT] = endpoint
    ctx.flags_dict[labels.IAP_CLIENT_ID] = iap_client_id
    ctx.flags_dict[labels.NAMESPACE] = namespace
    ctx.flags_dict[labels.GCP_PROJECT_ID] = project
    ctx.flags_dict[labels.GCP_REGION] = region
    ctx.flags_dict[labels.RUNTIME_PARAMETER] = _parse_runtime_parameters(
        runtime_parameter)

    handler = handler_factory.create_handler(ctx.flags_dict)
    if (ctx.flags_dict[labels.ENGINE_FLAG]
            not in (labels.KUBEFLOW_ENGINE, labels.AIRFLOW_ENGINE,
                    labels.VERTEX_ENGINE)) and runtime_parameter:
        raise NotImplementedError(
            'Currently runtime parameter is only supported in kubeflow, vertex, '
            'and airflow.')
    handler.create_run()
示例#23
0
文件: pipeline.py 项目: zvrr/tfx
def get_schema(ctx: Context, engine: Text, pipeline_name: Text) -> None:
  """Command definition to infer latest schema."""
  click.echo('Getting latest schema.')
  ctx.flags_dict[labels.ENGINE_FLAG] = engine
  ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
  handler_factory.create_handler(ctx.flags_dict).get_schema()
示例#24
0
def update_pipeline(ctx: Context, engine: Text, pipeline_path: Text) -> None:
    """Command definition to update a pipeline."""
    click.echo('Updating pipeline')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_DSL_PATH] = pipeline_path
    handler_factory.create_handler(ctx.flags_dict).update_pipeline()
示例#25
0
def delete_pipeline(ctx: Context, pipeline_name: Text, engine: Text) -> None:
    """Command definition to delete a pipeline."""
    click.echo('Deleting pipeline')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    ctx.flags_dict[labels.PIPELINE_NAME] = pipeline_name
    handler_factory.create_handler(ctx.flags_dict).delete_pipeline()
示例#26
0
def list_pipelines(ctx: Context, engine: Text) -> None:
    """Command definition to list pipelines."""
    click.echo('Listing all pipelines')
    ctx.flags_dict[labels.ENGINE_FLAG] = engine
    handler_factory.create_handler(ctx.flags_dict).list_pipelines()
示例#27
0
 def test_create_handler_kubeflow(self):
   self.flags_dict[labels.ENGINE_FLAG] = 'kubeflow'
   self.assertIsInstance(
       handler_factory.create_handler(self.flags_dict),
       kubeflow_handler.KubeflowHandler)
示例#28
0
 def testCreateHandlerBeam(self):
     self.flags_dict[labels.ENGINE_FLAG] = 'beam'
     self.assertIsInstance(handler_factory.create_handler(self.flags_dict),
                           beam_handler.BeamHandler)
示例#29
0
    def testCreateHandlerAirflow(self, mock_airflow_handler):
        self.flags_dict[labels.ENGINE_FLAG] = 'airflow'

        handler_factory.create_handler(self.flags_dict)
        mock_airflow_handler.assert_called_once_with(self.flags_dict)
示例#30
0
 def testCreateHandlerAirflow(self):
     self.flags_dict[labels.ENGINE_FLAG] = 'airflow'
     self.assertIsInstance(handler_factory.create_handler(self.flags_dict),
                           airflow_handler.AirflowHandler)