コード例 #1
0
def get_scalars():
    """Get scalar data for given train_ids and tags."""
    train_ids = request.args.getlist('train_id')
    tags = request.args.getlist('tag')

    processor = ScalarsProcessor(DATA_MANAGER)
    scalars = processor.get_scalars(train_ids, tags)
    return jsonify({'scalars': scalars})
コード例 #2
0
    def test_get_scalars(self):
        """Get scalars success."""
        scalar_processor = ScalarsProcessor(self._mock_data_manager)
        scalars = scalar_processor.get_scalars([self._train_id], [self._complete_tag_name])
        scalar = scalars[0]

        assert scalar['train_id'] == self._train_id
        assert scalar['tag'] == self._complete_tag_name

        for recv_values, expected_values in zip(scalar['values'], self._scalars_metadata):
            assert recv_values.get('wall_time') == expected_values.get('wall_time')
            assert recv_values.get('step') == expected_values.get('step')
            assert abs(recv_values.get('value') - expected_values.get('value')) < 1e-6