def test_get_metadata_list_with_not_exist_id(self):
        """Test getting metadata list with not exist id."""
        test_train_id = 'not_exist_id'
        image_processor = ImageProcessor(self._mock_data_manager)
        with pytest.raises(TrainJobNotExistError) as exc_info:
            image_processor.get_metadata_list(test_train_id, self._tag_name)

        assert exc_info.value.error_code == '50545005'
        assert exc_info.value.message == "Train job is not exist. Detail: Can not find the given train job in cache."
Example #2
0
    def test_get_metadata_list_with_not_exist_id(self, load_image_record):
        """Test getting metadata list with not exist id."""
        test_train_id = 'not_exist_id'
        image_processor = ImageProcessor(self._mock_data_manager)
        with pytest.raises(ParamValueError) as exc_info:
            image_processor.get_metadata_list(test_train_id, self._tag_name)

        assert exc_info.value.error_code == '50540002'
        assert "Can not find any data in loader pool about the train job." in exc_info.value.message
Example #3
0
    def test_get_metadata_list_with_not_exist_tag(self, load_image_record):
        """Test get metadata list with not exist tag."""
        test_tag_name = 'not_exist_tag_name'

        image_processor = ImageProcessor(self._mock_data_manager)

        with pytest.raises(ParamValueError) as exc_info:
            image_processor.get_metadata_list(self._train_id, test_tag_name)

        assert exc_info.value.error_code == '50540002'
        assert "Can not find any data in this train job by given tag." in exc_info.value.message
Example #4
0
    def test_get_metadata_list_success(self, load_image_record):
        """Test getting metadata list success."""
        test_tag_name = self._complete_tag_name

        image_processor = ImageProcessor(self._mock_data_manager)
        results = image_processor.get_metadata_list(self._train_id, test_tag_name).get('metadatas')

        assert results == self._images_metadata
Example #5
0
def image_metadata():
    """
    Interface to fetch metadata about the images for the particular run,tag, and zero-indexed sample.

    Returns:
        Response, which contains a list in JSON containing image events, each
            one of which is an object containing items wall_time, step, width,
            height, and query.
    """
    tag = request.args.get("tag")
    train_id = get_train_id(request)

    processor = ImageProcessor(DATA_MANAGER)
    response = processor.get_metadata_list(train_id, tag)
    return jsonify(response)