Ejemplo n.º 1
0
    def __init__(
            self,
            model: types.Channel = None,
            model_blessing: Optional[types.Channel] = None,
            infra_blessing: Optional[types.Channel] = None,
            push_destination: Optional[Union[pusher_pb2.PushDestination,
                                             Dict[Text, Any]]] = None,
            custom_config: Optional[Dict[Text, Any]] = None,
            custom_executor_spec: Optional[executor_spec.ExecutorSpec] = None,
            output: Optional[types.Channel] = None,
            model_export: Optional[types.Channel] = None,
            instance_name: Optional[Text] = None):
        """Construct a Pusher component.

    Args:
      model: A Channel of type `standard_artifacts.Model`, usually produced by
        a Trainer component.
      model_blessing: An optional Channel of type
        `standard_artifacts.ModelBlessing`, usually produced from an Evaluator
        component.
      infra_blessing: An optional Channel of type
        `standard_artifacts.InfraBlessing`, usually produced from an
        InfraValidator component.
      push_destination: A pusher_pb2.PushDestination instance, providing info
        for tensorflow serving to load models. Optional if executor_class
        doesn't require push_destination. If any field is provided as a
        RuntimeParameter, push_destination should be constructed as a dict with
        the same field names as PushDestination proto message.
      custom_config: A dict which contains the deployment job parameters to be
        passed to cloud-based training platforms. The [Kubeflow example](
          https://github.com/tensorflow/tfx/blob/6ff57e36a7b65818d4598d41e584a42584d361e6/tfx/examples/chicago_taxi_pipeline/taxi_pipeline_kubeflow_gcp.py#L278-L285)
          contains an example how this can be used by custom executors.
      custom_executor_spec: Optional custom executor spec.
      output: Optional output `standard_artifacts.PushedModel` channel with
        result of push.
      model_export: Backwards compatibility alias for the 'model' argument.
      instance_name: Optional unique instance name. Necessary if multiple Pusher
        components are declared in the same pipeline.
    """
        if model_export:
            absl.logging.warning(
                'The "model_export" argument to the Pusher component has '
                'been renamed to "model" and is deprecated. Please update your '
                'usage as support for this argument will be removed soon.')
            model = model_export
        output = output or types.Channel(type=standard_artifacts.PushedModel)
        if push_destination is None and not custom_executor_spec:
            raise ValueError(
                'push_destination is required unless a '
                'custom_executor_spec is supplied that does not require '
                'it.')
        spec = PusherSpec(model=model,
                          model_blessing=model_blessing,
                          infra_blessing=infra_blessing,
                          push_destination=push_destination,
                          custom_config=json_utils.dumps(custom_config),
                          pushed_model=output)
        super(Pusher, self).__init__(spec=spec,
                                     custom_executor_spec=custom_executor_spec,
                                     instance_name=instance_name)
Ejemplo n.º 2
0
    def __init__(
            self,
            model: Optional[types.Channel] = None,
            model_blessing: Optional[types.Channel] = None,
            infra_blessing: Optional[types.Channel] = None,
            push_destination: Optional[Union[pusher_pb2.PushDestination,
                                             Dict[Text, Any]]] = None,
            custom_config: Optional[Dict[Text, Any]] = None,
            custom_executor_spec: Optional[executor_spec.ExecutorSpec] = None,
            pushed_model: Optional[types.Channel] = None):
        """Construct a Pusher component.

    Args:
      model: An optional Channel of type `standard_artifacts.Model`, usually
        produced by a Trainer component.
      model_blessing: An optional Channel of type
        `standard_artifacts.ModelBlessing`, usually produced from an Evaluator
        component.
      infra_blessing: An optional Channel of type
        `standard_artifacts.InfraBlessing`, usually produced from an
        InfraValidator component.
      push_destination: A pusher_pb2.PushDestination instance, providing info
        for tensorflow serving to load models. Optional if executor_class
        doesn't require push_destination. If any field is provided as a
        RuntimeParameter, push_destination should be constructed as a dict with
        the same field names as PushDestination proto message.
      custom_config: A dict which contains the deployment job parameters to be
        passed to cloud-based training platforms. The [Kubeflow example](
          https://github.com/tensorflow/tfx/blob/6ff57e36a7b65818d4598d41e584a42584d361e6/tfx/examples/chicago_taxi_pipeline/taxi_pipeline_kubeflow_gcp.py#L278-L285)
          contains an example how this can be used by custom executors.
      custom_executor_spec: Optional custom executor spec. This is experimental
        and is subject to change in the future.
      pushed_model: Optional output `standard_artifacts.PushedModel` channel
        with result of push.
    """
        pushed_model = pushed_model or types.Channel(
            type=standard_artifacts.PushedModel)
        if push_destination is None and not custom_executor_spec:
            raise ValueError(
                'push_destination is required unless a '
                'custom_executor_spec is supplied that does not require '
                'it.')
        if model is None and infra_blessing is None:
            raise ValueError(
                'Either one of model or infra_blessing channel should be given. '
                'If infra_blessing is used in place of model, it must have been '
                'created with InfraValidator with RequestSpec.make_warmup = True. '
                'This cannot be checked during pipeline construction time but will '
                'raise runtime error if infra_blessing does not contain a model.'
            )
        spec = PusherSpec(model=model,
                          model_blessing=model_blessing,
                          infra_blessing=infra_blessing,
                          push_destination=push_destination,
                          custom_config=json_utils.dumps(custom_config),
                          pushed_model=pushed_model)
        super(Pusher, self).__init__(spec=spec,
                                     custom_executor_spec=custom_executor_spec)
Ejemplo n.º 3
0
    def __init__(
            self,
            model: Optional[types.Channel] = None,
            model_blessing: Optional[types.Channel] = None,
            infra_blessing: Optional[types.Channel] = None,
            push_destination: Optional[Union[pusher_pb2.PushDestination,
                                             Dict[Text, Any]]] = None,
            custom_config: Optional[Dict[Text, Any]] = None,
            custom_executor_spec: Optional[executor_spec.ExecutorSpec] = None):
        """Construct a Pusher component.

    Args:
      model: An optional Channel of type `standard_artifacts.Model`, usually
        produced by a Trainer component.
      model_blessing: An optional Channel of type
        `standard_artifacts.ModelBlessing`, usually produced from an Evaluator
        component.
      infra_blessing: An optional Channel of type
        `standard_artifacts.InfraBlessing`, usually produced from an
        InfraValidator component.
      push_destination: A pusher_pb2.PushDestination instance, providing info
        for tensorflow serving to load models. Optional if executor_class
        doesn't require push_destination. If any field is provided as a
        RuntimeParameter, push_destination should be constructed as a dict with
        the same field names as PushDestination proto message.
      custom_config: A dict which contains the deployment job parameters to be
        passed to Cloud platforms.
      custom_executor_spec: Optional custom executor spec. This is experimental
        and is subject to change in the future.
    """
        pushed_model = types.Channel(type=standard_artifacts.PushedModel)
        if (push_destination is None and not custom_executor_spec
                and self.EXECUTOR_SPEC.executor_class == executor.Executor):
            raise ValueError(
                'push_destination is required unless a '
                'custom_executor_spec is supplied that does not require '
                'it.')
        if custom_executor_spec:
            logging.warning(
                '`custom_executor_spec` is going to be deprecated.')
        if model is None and infra_blessing is None:
            raise ValueError(
                'Either one of model or infra_blessing channel should be given. '
                'If infra_blessing is used in place of model, it must have been '
                'created with InfraValidator with RequestSpec.make_warmup = True. '
                'This cannot be checked during pipeline construction time but will '
                'raise runtime error if infra_blessing does not contain a model.'
            )
        spec = PusherSpec(model=model,
                          model_blessing=model_blessing,
                          infra_blessing=infra_blessing,
                          push_destination=push_destination,
                          custom_config=json_utils.dumps(custom_config),
                          pushed_model=pushed_model)
        super(Pusher, self).__init__(spec=spec,
                                     custom_executor_spec=custom_executor_spec)
Ejemplo n.º 4
0
    def __init__(
            self,
            model: types.Channel = None,
            model_blessing: types.Channel = None,
            push_destination: Optional[Union[pusher_pb2.PushDestination,
                                             Dict[Text, Any]]] = None,
            custom_config: Optional[Dict[Text, Any]] = None,
            custom_executor_spec: Optional[executor_spec.ExecutorSpec] = None,
            model_push: Optional[types.Channel] = None,
            model_export: Optional[types.Channel] = None,
            instance_name: Optional[Text] = None):
        """Construct a Pusher component.

    Args:
      model: A Channel of type `standard_artifacts.Model`, usually produced by
        a Trainer component.
      model_blessing: A Channel of type `standard_artifacts.ModelBlessing`,
        usually produced by a ModelValidator component. _required_
      push_destination: A pusher_pb2.PushDestination instance, providing info
        for tensorflow serving to load models. Optional if executor_class
        doesn't require push_destination. If any field is provided as a
        RuntimeParameter, push_destination should be constructed as a dict with
        the same field names as PushDestination proto message.
      custom_config: A dict which contains the deployment job parameters to be
        passed to cloud-based training platforms.  The [Kubeflow
          example](https://github.com/tensorflow/tfx/blob/master/tfx/examples/chicago_taxi_pipeline/taxi_pipeline_kubeflow.py#L211)
            contains an example how this can be used by custom executors.
      custom_executor_spec: Optional custom executor spec.
      model_push: Optional output 'ModelPushPath' channel with result of push.
      model_export: Backwards compatibility alias for the 'model' argument.
      instance_name: Optional unique instance name. Necessary if multiple Pusher
        components are declared in the same pipeline.
    """
        model = model or model_export
        model_push = model_push or types.Channel(
            type=standard_artifacts.PushedModel,
            artifacts=[standard_artifacts.PushedModel()])
        if push_destination is None and not custom_executor_spec:
            raise ValueError(
                'push_destination is required unless a '
                'custom_executor_spec is supplied that does not require '
                'it.')
        spec = PusherSpec(model_export=model,
                          model_blessing=model_blessing,
                          push_destination=push_destination,
                          custom_config=custom_config,
                          model_push=model_push)
        super(Pusher, self).__init__(spec=spec,
                                     custom_executor_spec=custom_executor_spec,
                                     instance_name=instance_name)
Ejemplo n.º 5
0
    def __init__(
            self,
            model_export: types.Channel = None,
            model_blessing: types.Channel = None,
            push_destination: Optional[pusher_pb2.PushDestination] = None,
            custom_config: Optional[Dict[Text, Any]] = None,
            executor_class: Optional[Type[base_executor.BaseExecutor]] = None,
            model_push: Optional[types.Channel] = None,
            model: Optional[types.Channel] = None,
            name: Optional[Text] = None):
        """Construct a Pusher component.

    Args:
      model_export: A Channel of 'ModelExportPath' type, usually produced by
        Trainer component (required).
      model_blessing: A Channel of 'ModelBlessingPath' type, usually produced by
        ModelValidator component (required).
      push_destination: A pusher_pb2.PushDestination instance, providing
        info for tensorflow serving to load models. Optional if executor_class
        doesn't require push_destination.
      custom_config: A dict which contains the deployment job parameters to be
        passed to Google Cloud ML Engine.  For the full set of parameters
        supported by Google Cloud ML Engine, refer to
        https://cloud.google.com/ml-engine/reference/rest/v1/projects.models
      executor_class: Optional custom python executor class.
      model_push: Optional output 'ModelPushPath' channel with result of push.
      model: Forwards compatibility alias for the 'model_exports' argument.
      name: Optional unique name. Necessary if multiple Pusher components are
        declared in the same pipeline.
    """
        model_export = model_export or model
        model_push = model_push or types.Channel(
            type=standard_artifacts.PushedModel,
            artifacts=[standard_artifacts.PushedModel()])
        if push_destination is None and not executor_class:
            raise ValueError(
                'push_destination is required unless a custom '
                'executor_class is supplied that does not require '
                'it.')
        spec = PusherSpec(model_export=model_export,
                          model_blessing=model_blessing,
                          push_destination=push_destination,
                          custom_config=custom_config,
                          model_push=model_push)
        super(Pusher, self).__init__(spec=spec,
                                     custom_executor_class=executor_class,
                                     name=name)