def test_get_scalars_with_pivot_table_with_missing_value(self):
    mock_api_client = mock.Mock()

    def stream_experiment_data(request, **kwargs):
        self.assertEqual(request.experiment_id, '789')
        self.assertEqual(kwargs['metadata'], grpc_util.version_metadata())
        response = export_service_pb2.StreamExperimentDataResponse()
        response.run_name = 'train'
        response.tag_name = 'batch_loss'
        response.points.steps.append(0)
        response.points.values.append(0.5)
        response.points.wall_times.add(seconds=0, nanos=0)
        response.points.steps.append(1)
        response.points.values.append(0.25)
        response.points.wall_times.add(seconds=1, nanos=0)
        (yield response)
        response = export_service_pb2.StreamExperimentDataResponse()
        response.run_name = 'train'
        response.tag_name = 'epoch_loss'
        response.points.steps.append(0)
        response.points.values.append(0.375)
        response.points.wall_times.add(seconds=2, nanos=0)
        (yield response)
    mock_api_client.StreamExperimentData = mock.Mock(wraps=stream_experiment_data)
    with mock.patch.object(experiment_from_dev, 'get_api_client', (lambda api_endpoint: mock_api_client)):
        experiment = experiment_from_dev.ExperimentFromDev('789')
        with self.assertRaisesRegexp(ValueError, 'contains missing value\\(s\\).*different sets of steps.*pivot=False'):
            experiment.get_scalars(pivot=True)
def test_get_scalars_with_pivot_table_with_missing_value(self):
    mock_api_client = mock.Mock()

    def stream_experiment_data(request, **kwargs):
        self.assertEqual(request.experiment_id, '789')
        self.assertEqual(kwargs['metadata'], grpc_util.version_metadata())
        response = export_service_pb2.StreamExperimentDataResponse()
        response.run_name = 'train'
        response.tag_name = 'batch_loss'
        response.points.steps.append(0)
        response.points.values.append(0.5)
        response.points.wall_times.add(seconds=0, nanos=0)
        response.points.steps.append(1)
        response.points.values.append(0.25)
        response.points.wall_times.add(seconds=1, nanos=0)
        (yield response)
        response = export_service_pb2.StreamExperimentDataResponse()
        response.run_name = 'train'
        response.tag_name = 'epoch_loss'
        response.points.steps.append(0)
        response.points.values.append(0.375)
        response.points.wall_times.add(seconds=2, nanos=0)
        (yield response)
    mock_api_client.StreamExperimentData = mock.Mock(wraps=stream_experiment_data)
    with mock.patch.object(experiment_from_dev, 'get_api_client', (lambda api_endpoint: mock_api_client)):
        experiment = experiment_from_dev.ExperimentFromDev('789')
        with self.assertRaisesRegexp(ValueError, 'contains missing value\\(s\\).*different sets of steps.*pivot=False'):
            experiment.get_scalars(pivot=True)