Runtime fit return_values must contain last step produce or exception will be raised

Consider the following pipeline:

{
  "context": "TESTING",
  "created": "2019-01-28T20:35:10.241355Z",
  "digest": "041438b3e46c0d737e399686a83122547bc69931d355a339ed04f82e79ff134e",
  "id": "5b6dfa87-6738-4a08-9450-a069ac25eecf",
  "inputs": [
    {
      "name": "inputs"
    }
  ],
  "outputs": [
    {
      "data": "steps.6.produce",
      "name": "output predictions"
    }
  ],
  "schema": "https://metadata.datadrivendiscovery.org/schemas/v0/pipeline.json",
  "steps": [
    {
      "arguments": {
        "inputs": {
          "data": "inputs.0",
          "type": "CONTAINER"
        }
      },
      "outputs": [
        {
          "id": "produce"
        }
      ],
      "primitive": {
        "digest": "abbb95bdc72b7c680bdb11f53380aff86f6b59a5629ce9c03ae861494a10f8d8",
        "id": "4b42ce1e-9b98-4a25-b68e-fad13311eb65",
        "name": "Extract a DataFrame from a Dataset",
        "python_path": "d3m.primitives.data_transformation.dataset_to_dataframe.Common",
        "version": "0.3.0"
      },
      "type": "PRIMITIVE"
    },
    {
      "arguments": {
        "inputs": {
          "data": "steps.0.produce",
          "type": "CONTAINER"
        }
      },
      "outputs": [
        {
          "id": "produce"
        }
      ],
      "primitive": {
        "digest": "5663517a3826bc65938c9c7b13ec99853a5bc9076922458c99ecc40d7176bc30",
        "id": "d510cb7a-1782-4f51-b44c-58f0236e47c7",
        "name": "Parses strings into their types",
        "python_path": "d3m.primitives.data_transformation.column_parser.DataFrameCommon",
        "version": "0.5.0"
      },
      "type": "PRIMITIVE"
    },
    {
      "arguments": {
        "inputs": {
          "data": "steps.1.produce",
          "type": "CONTAINER"
        }
      },
      "hyperparams": {
        "semantic_types": {
          "data": [
            "https://metadata.datadrivendiscovery.org/types/Attribute"
          ],
          "type": "VALUE"
        }
      },
      "outputs": [
        {
          "id": "produce"
        }
      ],
      "primitive": {
        "digest": "207eb33b8f6edf9fbeac93197f226d382b7638365c0690aeaf6f16ec0d6ceb2a",
        "id": "4503a4c6-42f7-45a1-a1d4-ed69699cf5e1",
        "name": "Extracts columns by semantic type",
        "python_path": "d3m.primitives.data_transformation.extract_columns_by_semantic_types.DataFrameCommon",
        "version": "0.2.0"
      },
      "type": "PRIMITIVE"
    },
    {
      "arguments": {
        "inputs": {
          "data": "steps.0.produce",
          "type": "CONTAINER"
        }
      },
      "hyperparams": {
        "semantic_types": {
          "data": [
            "https://metadata.datadrivendiscovery.org/types/TrueTarget"
          ],
          "type": "VALUE"
        }
      },
      "outputs": [
        {
          "id": "produce"
        }
      ],
      "primitive": {
        "digest": "207eb33b8f6edf9fbeac93197f226d382b7638365c0690aeaf6f16ec0d6ceb2a",
        "id": "4503a4c6-42f7-45a1-a1d4-ed69699cf5e1",
        "name": "Extracts columns by semantic type",
        "python_path": "d3m.primitives.data_transformation.extract_columns_by_semantic_types.DataFrameCommon",
        "version": "0.2.0"
      },
      "type": "PRIMITIVE"
    },
    {
      "arguments": {
        "inputs": {
          "data": "steps.2.produce",
          "type": "CONTAINER"
        }
      },
      "hyperparams": {
        "return_result": {
          "data": "replace",
          "type": "VALUE"
        },
        "use_semantic_types": {
          "data": true,
          "type": "VALUE"
        }
      },
      "outputs": [
        {
          "id": "produce"
        }
      ],
      "primitive": {
        "digest": "7c942314896a010d6878b800240b9f0bd6f41b840c60924f428ff68c5501cdbe",
        "id": "d016df89-de62-3c53-87ed-c06bb6a23cde",
        "name": "sklearn.preprocessing.imputation.Imputer",
        "python_path": "d3m.primitives.data_cleaning.imputer.SKlearn",
        "version": "v2019.1.21"
      },
      "type": "PRIMITIVE"
    },
    {
      "arguments": {
        "inputs": {
          "data": "steps.4.produce",
          "type": "CONTAINER"
        },
        "outputs": {
          "data": "steps.3.produce",
          "type": "CONTAINER"
        }
      },
      "hyperparams": {
        "return_result": {
          "data": "replace",
          "type": "VALUE"
        },
        "use_semantic_types": {
          "data": true,
          "type": "VALUE"
        }
      },
      "outputs": [
        {
          "id": "produce"
        }
      ],
      "primitive": {
        "digest": "9f797a6f782232f33ab0668e2718030cb75a2d2e9ef7f7822450c1fc04b35d75",
        "id": "1dd82833-5692-39cb-84fb-2455683075f3",
        "name": "sklearn.ensemble.forest.RandomForestClassifier",
        "python_path": "d3m.primitives.classification.random_forest.SKlearn",
        "version": "v2019.1.21"
      },
      "type": "PRIMITIVE"
    },
    {
      "arguments": {
        "inputs": {
          "data": "steps.5.produce",
          "type": "CONTAINER"
        },
        "reference": {
          "data": "steps.1.produce",
          "type": "CONTAINER"
        }
      },
      "outputs": [
        {
          "id": "produce"
        }
      ],
      "primitive": {
        "digest": "87b0f30d660e0ecd034a6b5aa7a2938b96b03b96d048a2c07c10be928e37d0f6",
        "id": "8d38b340-f83f-4877-baaa-162f8e551736",
        "name": "Construct pipeline predictions output",
        "python_path": "d3m.primitives.data_transformation.construct_predictions.DataFrameCommon",
        "version": "0.3.0"
      },
      "type": "PRIMITIVE"
    }
  ]
}

When doing:

def run(pipeline_path, input_data_path, problem_path):
    datasets = runtime_module.get_dataset(input_data_path)

    with d3m_utils.silence():
        pipeline = runtime_module.get_pipeline(pipeline_path=pipeline_path)
    problem = problem_module.parse_problem_description(problem_path)
    with d3m_utils.silence():
        runtime = runtime_module.Runtime(pipeline=pipeline, problem_description=problem, context=Context.TESTING)
    fit_result = runtime.fit(inputs=[datasets], return_values=['steps.1.produce'])

An error will occur:

File "pipeline_generator.py", line 112, in <module>
    problem_path='datasets/38/38_sick_problem/problemDoc.json')
  File "pipeline_generator.py", line 103, in run
    fit_result = runtime.fit(inputs=[datasets], return_values=['steps.1.produce'])
  File ".../anaconda3/envs/d3m/lib/python3.6/site-packages/d3m/runtime.py", line 946, in fit
    return self._run(inputs, metadata_base.PipelineRunPhase.FIT, return_values)
  File ".../anaconda3/envs/d3m/lib/python3.6/site-packages/d3m/runtime.py", line 867, in _run
    self._populate_output_values()
  File ".../anaconda3/envs/d3m/lib/python3.6/site-packages/d3m/runtime.py", line 970, in _populate_output_values
    self.data_values['outputs.{i}'.format(i=i)] = self.data_values[output_description['data']]
KeyError: 'steps.6.produce'

However, when change fit_result = runtime.fit(inputs=[datasets], return_values=['steps.1.produce']) to fit_result = runtime.fit(inputs=[datasets], return_values=['steps.1.produce', 'steps.6.produce']), runtime will work normally.

Edited by linyang