# 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 Model - Watson Machine Learning'
description: |
  Train Machine Learning and Deep Learning Models in the Cloud using Watson Machine Learning
metadata:
  annotations: {platform: 'IBM Watson Machine Learning'}
inputs:
  - {name: train_code,        description: 'Required. Code for training ML/DL models'}
  - {name: execution_command, description: 'Required. Execution command to start the model training.'}
  - {name: config,            description: 'Credential configfile is properly created.', default: 'secret_name'}
  - {name: framework,         description: 'ML/DL Model Framework', default: 'tensorflow'}
  - {name: framework_version, description: 'Model Framework version', default: '1.15'}
  - {name: runtime,           description: 'Model Code runtime language', default: 'python'}
  - {name: runtime_version,   description: 'Model Code runtime version', default: '3.6'}
  - {name: run_definition,    description: 'Name for the Watson Machine Learning training definition', default: 'python-tensorflow-definition'}
  - {name: run_name,          description: 'Name for the Watson Machine Learning training-runs', default: 'python-tensorflow-run'}
  - {name: author_name,       description: 'Name of this training job author', default: 'default-author'}
  - {name: compute_name,      description: 'Name of the compute tiers, in WML is the gpu count', default: 'k80'}
  - {name: compute_nodes,     description: 'Number of compute machine', default: '1'}
outputs:
  - {name: run_uid,           description: 'UID for the Watson Machine Learning training-runs'}
  - {name: training_uid,      description: 'Training Location UID for the Watson Machine Learning training-runs'}
implementation:
  container:
    image: docker.io/aipipeline/wml-train:latest
    command: ['python3']
    args: [
      -u, /app/wml-train.py,
      --config, {inputValue: config},
      --train-code, {inputValue: train_code},
      --execution-command, {inputValue: execution_command},
      --framework, {inputValue: framework},
      --framework-version, {inputValue: framework_version},
      --runtime, {inputValue: runtime},
      --runtime-version, {inputValue: runtime_version},
      --run-definition, {inputValue: run_definition},
      --run-name, {inputValue: run_name},
      --author-name, {inputValue: author_name},
      --compute-name, {inputValue: compute_name},
      --compute-nodes,{inputValue: compute_nodes},
      --output-run-uid-path, {outputPath: run_uid},
      --output-training-uid-path, {outputPath: training_uid}
    ]
