Esempio n. 1
0
 def _map_to_entity(self, obj: VampyPluginParams) -> PluginConfig:
     additional_params = json.dumps(obj.params, sort_keys=True)
     return PluginConfig(block_size=safe_cast(obj.block_size, int,
                                              PLUGIN_CONFIG_DEFAULT),
                         step_size=safe_cast(obj.step_size, int,
                                             PLUGIN_CONFIG_DEFAULT),
                         additional_params=additional_params)
Esempio n. 2
0
 def get_id_by_model(self,
                     model_object: VampyPluginParams) -> Optional[int]:
     additional_params = json.dumps(model_object.params, sort_keys=True)
     return safe_cast(
         self._get_id(block_size=safe_cast(model_object.block_size, int,
                                           PLUGIN_CONFIG_DEFAULT),
                      step_size=safe_cast(model_object.step_size, int,
                                          PLUGIN_CONFIG_DEFAULT),
                      additional_params=additional_params), int, None)
Esempio n. 3
0
def _mutagen_tag_to_internal(mutagen_tag: Union[EasyID3, FLAC]) -> Id3Tag:
    maybe_track_number = first_if_collection(mutagen_tag.get("tracknumber"))
    track_number = maybe_track_number.split("/")[0] if maybe_track_number else None
    return Id3Tag(artist=first_if_collection(mutagen_tag["artist"]),
                  title=first_if_collection(mutagen_tag["title"]),
                  album=first_if_collection(mutagen_tag.get("album")),
                  date=safe_cast(first_if_collection(mutagen_tag.get("date")), int, None),
                  track=safe_cast(track_number, int, None),
                  genre=safe_cast(first_if_collection(mutagen_tag.get("genre")), str, None))
Esempio n. 4
0
 def get_id_by_model(self, model_object: VampyPlugin) -> Optional[int]:
     return safe_cast(
         self.get_id_by_params(vendor=model_object.vendor,
                               name=model_object.name,
                               output=model_object.output), int, None)
Esempio n. 5
0
 def get_id_by_params(self, vendor: str, name: str,
                      output: str) -> Optional[int]:
     return safe_cast(
         super()._get_id(vendor=vendor, name=name, output=output), int,
         None)
Esempio n. 6
0
 def get_id_by_name(self, artist_name: str, album_name: str, title_name: str) -> Optional[int]:
     return safe_cast(super()._get_id(artist=artist_name, album=album_name, title=title_name), int, None)
Esempio n. 7
0
 def get_id_by_model(self, model_object: MetricValue) -> Optional[int]:
     definition_id = self.definition_repository.get_id_by_model(
         model_object.definition)
     return safe_cast(
         self._get_id(definition_id=definition_id,
                      task_id=model_object.task_id), int, None)
Esempio n. 8
0
 def get_id_by_model(self,
                     model_object: CompressedFeatureDTO) -> Optional[str]:
     return safe_cast(self._get_id(id=model_object.task_id), str, None)
Esempio n. 9
0
 def get_id_by_model(self, model_object: MetricDefObj) -> Optional[int]:
     return safe_cast(self._get_id(name=model_object.name), int, None)
Esempio n. 10
0
 def get_id_by_model(self, model_object: AnalysisRequest) -> Optional[str]:
     return safe_cast(self._query_single(id=model_object.task_id), str,
                      None)
Esempio n. 11
0
 def get_id_by_model(self, model_object: FeatureMeta) -> Optional[str]:
     return safe_cast(self._get_id(id=model_object.task_id), str, None)
Esempio n. 12
0
 def get_id_by_model(self, model_object: AnalysisStats) -> Optional[str]:
     return safe_cast(self._get_id(id=model_object.task_id), str, None)
Esempio n. 13
0
 def get_id_by_file_name(self, file_name: str) -> Optional[int]:
     return safe_cast(super()._get_id(file_name=file_name), int, None)