def setUp(self):
     self.plugin_key_to_outputs = {
         "test_plugin_vendor:test_plugin_name": ["output1", "output2"],
         "test_plugin_vendor_2:test_plugin_name_2":
         ["output1", "output2", "output3"]
     }
     self.plugin_key_to_lib_file = {
         "test_plugin_vendor:test_plugin_name": "plugin_lib.so",
         "test_plugin_vendor_2:test_plugin_name_2": "plugin_lib_2.so"
     }
     self.vampy_plugin_1 = VampyPlugin(vendor="test_plugin_vendor",
                                       name="test_plugin_name",
                                       output="output1",
                                       library_file_name="plugin_lib.so")
     self.vampy_plugin_2 = VampyPlugin(vendor="test_plugin_vendor",
                                       name="test_plugin_name",
                                       output="output2",
                                       library_file_name="plugin_lib.so")
     self.vampy_plugin_3 = VampyPlugin(vendor="test_plugin_vendor_2",
                                       name="test_plugin_name_2",
                                       output="output1",
                                       library_file_name="plugin_lib_2.so")
     self.vampy_plugin_4 = VampyPlugin(vendor="test_plugin_vendor_2",
                                       name="test_plugin_name_2",
                                       output="output2",
                                       library_file_name="plugin_lib_2.so")
     self.vampy_plugin_5 = VampyPlugin(vendor="test_plugin_vendor_2",
                                       name="test_plugin_name_2",
                                       output="output3",
                                       library_file_name="plugin_lib_2.so")
     self.vamp_interface_mock = VampInterfaceStub(
         self.plugin_key_to_outputs)
     self.vamp_host_interface_mock = VampHostInterfaceStub(
         self.plugin_key_to_lib_file)
示例#2
0
 def setUp(self):
     self.test_plugin_provider = "test_plugin_provider"
     self.test_plugin_name = "test_plugin_name"
     self.test_plugin_output = "output1"
     self.vampy_plugin = VampyPlugin(vendor=self.test_plugin_provider,
                                     name=self.test_plugin_name,
                                     output=self.test_plugin_output,
                                     library_file_name="some_lib.so")
     self.byte_symbol = "B"
示例#3
0
 def test_should_read_plugin_details(self):
     expected_status_code = 200
     expected_plugin = VampyPlugin(
         vendor="vamp-example-plugins",
         name="amplitudefollower",
         output="amplitude",
         library_file_name="vamp-example-plugins.so")
     response = requests.get(url="{}/{}/{}/{}".format(
         self.plugin_url, self.test_plugin_vendor, self.test_plugin_name,
         self.test_plugin_output))
     assert_that(response.status_code).is_equal_to(expected_status_code)
     actual_plugin = VampyPlugin.from_serializable(response.json())
     assert_that(actual_plugin).is_equal_to(expected_plugin)
示例#4
0
    def test_should_serialize_and_deserialize_plugin(self):
        serialized = self.vampy_plugin.to_serializable()
        assert_that(serialized).is_not_none().is_not_empty()
        from_serialized = VampyPlugin.from_serializable(serialized)

        assert_that(from_serialized).is_not_none().is_equal_to(
            self.vampy_plugin)
示例#5
0
 def build_plugin_from_params(self, vendor: str, name: str,
                              output: str) -> Optional[VampyPlugin]:
     library_file_name = get_file_name(
         self.vamp_host_interface.get_library_for("{}:{}".format(
             vendor, name)))
     if self._is_plugin_available(vendor, name):
         return VampyPlugin(vendor, name, output, library_file_name)
     return None
示例#6
0
 def from_serializable(cls, serialized: Dict[str, Any]):
     audio_meta_object = CompressedAudioFileMeta.from_serializable(serialized["audio_meta"])
     id3_tag_object = Id3Tag.from_serializable(serialized["id3_tag"])
     plugin_object = VampyPlugin.from_serializable(serialized["plugin"])
     plugin_config_object = VampyPluginParams.from_serializable(serialized["plugin_config"])
     serialized.update({"audio_meta": audio_meta_object, "id3_tag": id3_tag_object,
                        "plugin": plugin_object, "plugin_config": plugin_config_object})
     return AnalysisRequest(**serialized)
示例#7
0
 def setUp(self):
     self.audio_meta_example = CompressedAudioFileMeta("some_file.mp3", 1024 * 1024 * 2, 1, 44100, 45., 128.)
     self.id3_tag_example = Id3Tag(artist="Unknown Artist", title="Unknown Title", album="Unknown Album",
                                   date=2017, track=1, genre="Unknown Genre")
     self.example_vampy_plugin = VampyPlugin("vamp-example-plugins", "amplitudefollower", "amplitude",
                                             library_file_name="/root/vamp/vamp-example-plugins.so")
     self.task_id = "fa3b5d8c-b760-49e0-b8b5-7ce0737621d8"
     self.plugin_config_example = VampyPluginParams(block_size=2048, step_size=512)
     self.analysis_request_example = AnalysisRequest(self.task_id, self.audio_meta_example, self.id3_tag_example,
                                                     self.example_vampy_plugin, self.plugin_config_example)
示例#8
0
 def setUp(self):
     self.plugin_url = "http://{}:{}/plugin".format(get_api_host(),
                                                    get_api_port())
     self.test_plugin_vendor = "vamp-example-plugins"
     self.test_plugin_name = "amplitudefollower"
     self.test_plugin_output = "amplitude"
     self.test_plugin_lib_name = "vamp-example-plugins.so"
     self.test_plugin = VampyPlugin(
         vendor=self.test_plugin_vendor,
         name=self.test_plugin_name,
         output=self.test_plugin_output,
         library_file_name=self.test_plugin_lib_name)
示例#9
0
 def build_plugins_from_key(self, vampy_key: str) -> List[VampyPlugin]:
     vendor, name = self._split_vampy_key_into_vendor_and_name(vampy_key)
     plugin_outputs = self.vamp_interface.get_outputs_of(vampy_key)
     library_file_name = get_file_name(
         self.vamp_host_interface.get_library_for(vampy_key))
     all_plugins = [
         VampyPlugin(vendor, name, o, library_file_name)
         for o in plugin_outputs
     ]
     return [
         p for p in all_plugins
         if p.full_key not in self.black_list_plugin_key
     ]
 def setUp(self):
     self.task_id = "0f961f20-b036-5740-b526-013523dd88c7"
     self.audio_meta_example_1 = CompressedAudioFileMeta(
         "some_file.mp3", 1024 * 1024 * 2, 1, 44100, 45., 128.)
     self.audio_meta_example_2 = CompressedAudioFileMeta(
         "some_file_2.mp3", 1024 * 1024 * 2, 1, 44100, 45., 128.)
     self.tag_example_1 = Id3Tag(artist="Pink Floyd",
                                 title="Have a cigar",
                                 album="Wish you were here",
                                 date=1975,
                                 track=3,
                                 genre="Progressive rock")
     self.tag_example_2 = Id3Tag(artist="Floyd",
                                 title="Cigar",
                                 album="Wish you were here",
                                 date=1981,
                                 track=2,
                                 genre="Rock")
     self.plugin_example_1 = VampyPlugin("my_vendor", "my_name", "outputs",
                                         "my_file.so")
     self.plugin_example_2 = VampyPlugin("my_vendor", "my_name_2",
                                         "outputs", "my_file_2.so")
     self.plugin_config_example_1 = VampyPluginParams(block_size=2048,
                                                      step_size=1024)
     self.the_request = AnalysisRequest(
         task_id=self.task_id,
         audio_meta=self.audio_meta_example_1,
         id3_tag=self.tag_example_1,
         plugin=self.plugin_example_1,
         plugin_config=self.plugin_config_example_1)
     self.plugin_repo = VampyPluginRepository(self.session_provider)
     self.audio_repo = AudioFileRepository(self.session_provider)
     self.audio_tag_repo = AudioTagRepository(self.session_provider)
     self.plugin_config_repo = PluginConfigRepository(self.session_provider)
     self.request_repo = RequestRepository(self.session_provider,
                                           self.audio_repo,
                                           self.audio_tag_repo,
                                           self.plugin_repo,
                                           self.plugin_config_repo)
示例#11
0
 def setUp(self):
     self.metric_definition_1 = MetricDefinition(
         name="first_metric",
         plugin_key="vamp-example-plugins:amplitudefollower:amplitude",
         function="select_row",
         kwargs={"row_index": 3})
     self.metric_definition_2 = MetricDefinition(
         name="second_metric",
         plugin_key="vamp-example-plugins:amplitudefollower:amplitude",
         function="none",
         kwargs={})
     self.metric_definition_3 = MetricDefinition(
         name="first_metric",
         plugin_key="vamp-example-plugins:amplitudefollower:amplitude2",
         function="none",
         kwargs={})
     self.plugin_1 = VampyPlugin("vamp-example-plugins",
                                 "amplitudefollower", "amplitude", "")
     self.plugin_2 = VampyPlugin("vamp-example-plugins",
                                 "amplitudefollower", "amplitude2", "")
     self.plugin_repo_mock = Mock(VampyPluginRepository)
     self.definition_repo = MetricDefinitionRepository(
         self.session_provider, self.plugin_repo_mock)
示例#12
0
class AudioPluginModelTest(unittest.TestCase):
    def setUp(self):
        self.test_plugin_provider = "test_plugin_provider"
        self.test_plugin_name = "test_plugin_name"
        self.test_plugin_output = "output1"
        self.vampy_plugin = VampyPlugin(vendor=self.test_plugin_provider,
                                        name=self.test_plugin_name,
                                        output=self.test_plugin_output,
                                        library_file_name="some_lib.so")
        self.byte_symbol = "B"

    def test_model_properties(self):
        assert_that(self.vampy_plugin.name).is_equal_to(self.test_plugin_name)
        assert_that(self.vampy_plugin.vendor).is_equal_to(
            self.test_plugin_provider)

    def test_should_serialize_and_deserialize_plugin(self):
        serialized = self.vampy_plugin.to_serializable()
        assert_that(serialized).is_not_none().is_not_empty()
        from_serialized = VampyPlugin.from_serializable(serialized)

        assert_that(from_serialized).is_not_none().is_equal_to(
            self.vampy_plugin)

    def test_should_serialize_plugin_to_json(self):
        plugin_as_json = json.dumps(self.vampy_plugin.to_serializable())
        assert_that(plugin_as_json).is_not_none().is_not_empty()

    def test_should_have_size_defined(self):
        size_bytes = self.vampy_plugin.size_bytes()
        assert_that(size_bytes).is_between(1, 10000)

        size_bytes_humanized = self.vampy_plugin.size_humanized()
        assert_that(
            size_bytes_humanized).is_not_none().is_not_empty().contains(
                self.byte_symbol)
示例#13
0
 def setUp(self):
     self.metric_definition_example = MetricDefinition(
         name="first_metric",
         plugin_key="vamp-example-plugins:amplitudefollower:amplitude",
         function="select_row",
         kwargs={"row_index": 3})
     self.metric_value_1 = MetricValue(
         "0f961f20-b036-5740-b526-013523dd88c7",
         self.metric_definition_example,
         DataStats(minimum=0.03276,
                   maximum=0.44241,
                   median=0.22399,
                   mean=0.21448,
                   standard_deviation=0.12923,
                   variance=0.01670,
                   sum=10.1,
                   count=8))
     self.plugin_example = VampyPlugin("vamp-example-plugins",
                                       "amplitudefollower", "amplitude", "")
     self.plugin_repo_mock = Mock(VampyPluginRepository)
     self.definition_repo_mock = Mock(MetricDefinitionRepository)
     self.metric_value_repo = MetricValueRepository(
         self.session_provider, self.definition_repo_mock)
示例#14
0
 def _map_to_object(self, entity: VampyPluginEntity) -> VampyPlugin:
     return VampyPlugin(vendor=entity.vendor,
                        name=entity.name,
                        output=entity.output,
                        library_file_name=entity.library_file_name)
示例#15
0
 def setUp(self):
     self.example_vampy_plugin = VampyPlugin("vamp-example-plugins", "amplitudefollower", "amplitude",
                                             library_file_name="/root/vamp/vamp-example-plugins.so")
     self.result_data_example = FeatureMeta("0f961f20-b036-5740-b526-013523dd88c7", FeatureType.ConstantStepFeature,
                                            1024, (1, 10, 0))