#!/usr/bin/env/python3
# Copyright (c) Facebook, Inc. and its affiliates.
# 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: Training
description: |
  Pytorch training

inputs:
  - {name: input_data, description: 'Input dataset path'}
  - {name: script_args, description: 'Arguments to the cifar script'}
  - {name: ptl_arguments, description: 'Arguments to pytorch lightning Trainer'}
  - {name: trial_id, type: Integer, description: 'Trial Id'}
  - {name: model_parameters, type: JsonObject, description: 'Model parameters for trainer'}
  - {name: results, type: String, description: 'Path to write training results'}
outputs:
  - {name: tensorboard_root, description: 'Tensorboard output path'}
  - {name: checkpoint_dir, description: 'Model checkpoint output'}
  - {name: MLPipeline UI Metadata, description: 'MLPipeline UI Metadata output'}
  - {name: MLPipeline Metrics, description: 'MLPipeline Metrics output'}


implementation:
  container:
    # For GPU use
    # image: public.ecr.aws/pytorch-samples/kfp_samples:latest-gpu
    image: "docker image name" # Ex: public.ecr.aws/pytorch-samples/kfp_samples:latest
    command: ["command to execute"] # Ex: ['python3', 'cifar10/cifar10_pytorch.py']
    args:
    - --dataset_path
    - {inputPath: input_data}
    - --tensorboard_root
    - {outputPath: tensorboard_root}
    - --checkpoint_dir
    - {outputPath: checkpoint_dir}
    - --mlpipeline_ui_metadata
    - {outputPath: MLPipeline UI Metadata}
    - --mlpipeline_metrics
    - { outputPath: MLPipeline Metrics}
    - --script_args
    - { inputValue: script_args }
    - --ptl_args
    - { inputValue: ptl_arguments }
    - --trial_id
    - { inputValue: trial_id }
    - --model_params
    - { inputValue: model_parameters }
    - --results
    - { inputValue: results }
