<reponame>ishrat2003/aws-nlp-experiments
from __future__ import print_function

import os
import json
import pickle
import sys
import traceback

import pandas as pd

# These are the paths to where SageMaker mounts interesting things in your container.

prefix = '/opt/ml/'

input_path = prefix + 'input/data'
output_path = os.path.join(prefix, 'output')
model_path = os.path.join(prefix, 'model')

# The function to execute the training.
def train():
    print('Starting the training.')
    try:
        with open(os.path.join(output_path, 'sample_output'), 'w') as s:
            s.write('training out')
            
        print('Training complete.')
    except Exception as e:
        # Write out an error file. This will be returned as the failureReason in the
        # DescribeTrainingJob result.
        trc = traceback.format_exc()
        with open(os.path.join(output_path, 'failure'), 'w') as s:
            s.write('Exception during training: ' + str(e) + '\n' + trc)
        # Printing this causes the exception to be in the training job logs, as well.
        print('Exception during training: ' + str(e) + '\n' + trc, file=sys.stderr)
        # A non-zero exit code causes the training job to be marked as Failed.
        sys.exit(255)

if __name__ == '__main__':
    train()

    # A zero exit code causes the job to be marked a Succeeded.
    sys.exit(0)


from __future__ import print_function

import os
import json
import pickle
import sys
import traceback

import pandas as pd

# These are the paths to where SageMaker mounts interesting things in your container.

prefix = '/opt/ml/'

input_path = prefix + 'input/data'
output_path = os.path.join(prefix, 'output')
model_path = os.path.join(prefix, 'model')

# The function to execute the training.
def train():
    print('Starting the training.')
    try:
        with open(os.path.join(output_path, 'sample_output'), 'w') as s:
            s.write('training out')
            
        print('Training complete.')
    except Exception as e:
        # Write out an error file. This will be returned as the failureReason in the
        # DescribeTrainingJob result.
        trc = traceback.format_exc()
        with open(os.path.join(output_path, 'failure'), 'w') as s:
            s.write('Exception during training: ' + str(e) + '\n' + trc)
        # Printing this causes the exception to be in the training job logs, as well.
        print('Exception during training: ' + str(e) + '\n' + trc, file=sys.stderr)
        # A non-zero exit code causes the training job to be marked as Failed.
        sys.exit(255)

if __name__ == '__main__':
    train()

    # A zero exit code causes the job to be marked a Succeeded.
    sys.exit(0)
# These are the paths to where SageMaker mounts interesting things in your container. # The function to execute the training. # Write out an error file. This will be returned as the failureReason in the # DescribeTrainingJob result. # Printing this causes the exception to be in the training job logs, as well. # A non-zero exit code causes the training job to be marked as Failed. # A zero exit code causes the job to be marked a Succeeded.