# 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.

name: 'Train Spark Model - IBM Cloud'
description: |
  Train a Spark Model using IBM Cloud Spark Service
metadata:
  annotations: {platform: 'IBM Cloud Spark Service'}
inputs:
  - {name: bucket_name,      description: 'Required. Object storage bucket name'}
  - {name: data_filename,    description: 'Required. Name of the data binary'}
  - {name: model_filename,   description: 'Required. Name of the training model file'}
  - {name: spark_entrypoint, description: 'Required. Entrypoint command for training the spark model'}
outputs:
  - {name: model_filepath,           description: 'Spark Model binary filepath'}
  - {name: train_data_filepath,      description: 'Spark training data filepath'}
implementation:
  container:
    image: docker.io/aipipeline/train_spark:latest
    command: ['python']
    args: [
      -u, train_spark.py,
      --bucket_name, {inputValue: bucket_name},
      --data_filename, {inputValue: data_filename},
      --model_filename, {inputValue: model_filename},
      --spark_entrypoint, {inputValue: spark_entrypoint},
      --output_model_file_path, {outputPath: model_filepath},
      --output_train_data_file_path, {outputPath: train_data_filepath}
    ]
