def get_available_models(self, workspace_path: str) -> List[str]: """Get list of available models in workspace.""" available_models = [] all_models = self.get_models() for filename in os.listdir(workspace_path): name = os.path.splitext(filename)[0] if (os.path.isfile(os.path.join(workspace_path, filename)) and name in all_models and is_model_file(filename)): available_models.append(filename) return available_models
def is_model_or_directory_entry(entry: Dict) -> bool: """Return if given entry should be shown on model list.""" return is_model_file(entry["name"]) or is_directory_entry(entry)
def test_ckpt_is_model_file(self) -> None: """Test if ckpt file is recognized correctly.""" path = "/home/user/model.onnx.ckpt" result = is_model_file(path) self.assertEqual(result, False)
def test_mp3_is_model_file(self) -> None: """Test if mp3 file is recognized correctly.""" path = "/home/user/favourite_song.mp3" result = is_model_file(path) self.assertEqual(result, False)
def test_onnx_is_model_file(self) -> None: """Test if onnx file is recognized correctly.""" path = "/home/user/model.onnx" result = is_model_file(path) self.assertEqual(result, True)