Skip to content

Commit e1675ad

Browse files
committed
fix: Fixing models loading while testing and on prod.
1 parent 579c5fb commit e1675ad

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

lib/app/models.ex

+15-25
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,9 @@ defmodule App.Models do
8484
# Delete any cached pre-existing models
8585
File.rm_rf!(@models_folder_path)
8686

87-
with {:ok, _} <-
88-
download_model(@captioning_test_model),
89-
# Download captioning test model model
90-
{:ok, _} <-
91-
download_model(@embedding_model),
92-
# Download whisper model
93-
{:ok, _} <-
94-
download_model(@audio_test_model) do
87+
with :ok <- download_model(@captioning_test_model),
88+
:ok <- download_model(@embedding_model),
89+
:ok <- download_model(@audio_test_model) do
9590
:ok
9691
else
9792
{:error, msg} -> {:error, msg}
@@ -101,12 +96,9 @@ defmodule App.Models do
10196
# Delete any cached pre-existing models
10297
File.rm_rf!(@models_folder_path)
10398

104-
with {:ok, _} <-
105-
download_model(@captioning_prod_model),
106-
{:ok, _} <-
107-
download_model(@audio_prod_model),
108-
{:ok, _} <-
109-
download_model(@embedding_model) do
99+
with :ok <- download_model(@captioning_prod_model),
100+
:ok <- download_model(@audio_prod_model),
101+
:ok <- download_model(@embedding_model) do
110102
:ok
111103
else
112104
{:error, msg} -> {:error, msg}
@@ -116,12 +108,9 @@ defmodule App.Models do
116108
# Check if the prod model cache directory exists or if it's not empty.
117109
# If so, we download the prod models.
118110

119-
with :ok <-
120-
check_folder_and_download(@captioning_prod_model),
121-
:ok <-
122-
check_folder_and_download(@audio_prod_model),
123-
:ok <-
124-
check_folder_and_download(@embedding_model) do
111+
with :ok <- check_folder_and_download(@captioning_prod_model),
112+
:ok <- check_folder_and_download(@audio_prod_model),
113+
:ok <- check_folder_and_download(@embedding_model) do
125114
:ok
126115
else
127116
{:error, msg} -> {:error, msg}
@@ -131,10 +120,9 @@ defmodule App.Models do
131120
# Check if the test model cache directory exists or if it's not empty.
132121
# If so, we download the test models.
133122

134-
with :ok <-
135-
check_folder_and_download(@captioning_test_model),
136-
:ok <-
137-
check_folder_and_download(@audio_test_model) do
123+
with :ok <- check_folder_and_download(@captioning_test_model),
124+
:ok <- check_folder_and_download(@audio_test_model),
125+
:ok <- check_folder_and_download(@embedding_model) do
138126
:ok
139127
else
140128
{:error, msg} -> {:error, msg}
@@ -351,6 +339,8 @@ defmodule App.Models do
351339
{:ok, _} = Bumblebee.load_generation_config(downloading_settings)
352340
end
353341

342+
:ok
343+
354344
{:error, msg} ->
355345
{:error, msg}
356346
end
@@ -366,7 +356,7 @@ defmodule App.Models do
366356
if File.ls(model_location) == {:error, :enoent} or File.ls(model_location) == {:ok, []} do
367357
download_model(model)
368358
|> case do
369-
{:ok, %Bumblebee.Text.GenerationConfig{}} -> :ok
359+
:ok -> :ok
370360
{:error, msg} -> {:error, msg}
371361
end
372362
else

0 commit comments

Comments
 (0)