# Buggy code
def _get_transform_args(self, desc, inputs, name, volume_kms_key):
    """Format training args to pass in sagemaker_session.train.

    Args:
        desc (dict): the response from DescribeTrainingJob API.
        inputs (str): an S3 uri where new input dataset is stored.
        name (str): the name of the step job.
        volume_kms_key (str): The KMS key id to encrypt data on the storage volume attached to
            the ML compute instance(s).

    Returns (dcit): a dictionary that can be used as args of
        sagemaker_session.transform method.
    """
    transform_args = {}
    transform_args["job_name"] = name
    transform_args["model_name"] = desc["ModelName"]
    transform_args["output_config"] = desc["TransformOutput"]
    transform_args["resource_config"] = desc["TransformResources"]
    transform_args["data_processing"] = desc["DataProcessing"]
    transform_args["tags"] = []
    transform_args["strategy"] = None
    transform_args["max_concurrent_transforms"] = None
    transform_args["max_payload"] = None
    transform_args["env"] = None

    input_config = desc["TransformInput"]
    input_config["DataSource"]["S3DataSource"]["S3Uri"] = inputs
    transform_args["input_config"] = input_config

    if volume_kms_key is not None:
        transform_args["resource_config"]["VolumeKmsKeyId"] = volume_kms_key
    if "BatchStrategy" in desc:
        transform_args["strategy"] = desc["BatchStrategy"]
    if "MaxConcurrentTransforms" in desc:
        transform_args["max_concurrent_transforms"] = desc["MaxConcurrentTransforms"]
    if "MaxPayloadInMB" in desc:
        transform_args["max_payload"] = desc["MaxPayloadInMB"]
    if "Environment" in desc:
        transform_args["env"] = desc["Environment"]

    return transform_args


# Traceback (FileNotFoundError)
2018-07-05 11:30:31,569 INFO - root - running container entrypoint
2018-07-05 11:30:31,570 INFO - root - starting train task
2018-07-05 11:30:31,573 INFO - container_support.training - Training starting
2018-07-05 11:30:31,575 INFO - container_support.environment - starting metrics service
2018-07-05 11:30:31,578 ERROR - container_support.training - uncaught exception during training: [Errno 2] No such file or directory: 'telegraf'
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/container_support/training.py", line 32, in start
env.start_metrics_if_enabled()
File "/usr/local/lib/python3.5/dist-packages/container_support/environment.py", line 124, in start_metrics_if_enabled
subprocess.Popen(['telegraf', '--config', telegraf_conf])
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'telegraf'

# Fixed code
def _get_transform_args(self, desc, inputs, name, volume_kms_key):
    """Format training args to pass in sagemaker_session.train.

    Args:
        desc (dict): the response from DescribeTrainingJob API.
        inputs (str): an S3 uri where new input dataset is stored.
        name (str): the name of the step job.
        volume_kms_key (str): The KMS key id to encrypt data on the storage volume attached to
            the ML compute instance(s).

    Returns (dcit): a dictionary that can be used as args of
        sagemaker_session.transform method.
    """
    transform_args = {}
    transform_args["job_name"] = name
    transform_args["model_name"] = desc["ModelName"]
    transform_args["output_config"] = desc["TransformOutput"]
    transform_args["resource_config"] = desc["TransformResources"]
    transform_args["data_processing"] = desc["DataProcessing"]
    transform_args["tags"] = []
    transform_args["strategy"] = None
    transform_args["max_concurrent_transforms"] = None
    transform_args["max_payload"] = None
    transform_args["env"] = None
    transform_args["experiment_config"] = None

    input_config = desc["TransformInput"]
    input_config["DataSource"]["S3DataSource"]["S3Uri"] = inputs
    transform_args["input_config"] = input_config

    if volume_kms_key is not None:
        transform_args["resource_config"]["VolumeKmsKeyId"] = volume_kms_key
    if "BatchStrategy" in desc:
        transform_args["strategy"] = desc["BatchStrategy"]
    if "MaxConcurrentTransforms" in desc:
        transform_args["max_concurrent_transforms"] = desc["MaxConcurrentTransforms"]
    if "MaxPayloadInMB" in desc:
        transform_args["max_payload"] = desc["MaxPayloadInMB"]
    if "Environment" in desc:
        transform_args["env"] = desc["Environment"]

    return transform_args