title: How to export metrics from a containerized component in kubeflow pipelines 0.2.5
body: <p>I have a pipeline made up out of 3 containerized components. In the last component I write the metrics I want to a file named <code>/mlpipeline-metrics.json</code>, just like it's explained <a href="https://www.kubeflow.org/docs/pipelines/sdk/pipelines-metrics/" rel="nofollow noreferrer">here</a>.
  This is the Python code I used.</p>
  
  <pre class="lang-py prettyprint-override"><code>metrics = {
      'metrics': [
          {
              'name': 'accuracy',
              'numberValue':  accuracy,
              'format': 'PERCENTAGE',
          },
          {
              'name': 'average-f1-score',
              'numberValue': average_f1_score,
              'format': 'PERCENTAGE'
          },
      ]
  }
  
  with open('/mlpipeline-metrics.json', 'w') as f:
      json.dump(metrics, f)
  </code></pre>
  
  <p>I also tried writing the file with the following code, just like in the example linked above.</p>
  
  <pre class="lang-py prettyprint-override"><code>with file_io.FileIO('/mlpipeline-metrics.json', 'w') as f:
      json.dump(metrics, f)
  </code></pre>
  
  <p>The pipeline runs just fine without any errors. But it won't show the metrics in the front-end UI.</p>
  
  <p>I'm thinking it has something to do with the following codeblock.</p>
  
  <pre class="lang-py prettyprint-override"><code>def metric_op(accuracy, f1_scores):
      return dsl.ContainerOp(
          name='visualize_metrics',
          image='gcr.io/mgcp-1190085-asml-lpd-dev/kfp/jonas/container_tests/image_metric_comp',
          arguments=[
              '--accuracy', accuracy,
              '--f1_scores', f1_scores,
          ]
      )
  </code></pre>
  
  <p>This is the code I use to create a <code>ContainerOp</code> from the containerized component. Notice I have not specified any <code>file_outputs</code>.
  In other <code>ContainerOp</code> I have to specify <code>file_outputs</code> to be able to pass variables to the next steps in the pipeline. Should I do something similar here to map the <code>/mlpipeline-metrics.json</code> onto something so that kubeflow pipelines detects it?</p>
  
  <p>I'm using a managed AI platform pipelines deployment running Kubeflow Pipelines 0.2.5 with Python 3.6.8.</p>
  
  <p>Any help is appreciated.</p>