Skip to content

Commit

Permalink
Merge branch 'release/0.3.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jan 28, 2025
2 parents 22971fb + f3cd140 commit fba0410
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
40 changes: 23 additions & 17 deletions lib/mix/tasks/opsmo.embed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,42 @@ defmodule Mix.Tasks.Opsmo.Embed do
## Usage
$ mix opsmo.embed MODEL_NAME [MODEL_NAME...] [--branch BRANCH_NAME]
$ mix opsmo.embed MODEL_NAME[:VERSION] [MODEL_NAME[:VERSION]...]
Examples:
$ mix opsmo.embed crpm
$ mix opsmo.embed crpm --branch dev
$ mix opsmo.embed crpm llm classifier
$ mix opsmo.embed crpm:v1.0.0
$ mix opsmo.embed crpm:main llm:dev classifier
"""

@impl Mix.Task
def run(args) do
{opts, model_names} = OptionParser.parse!(args, strict: [branch: :string])
def run([]) do
Mix.raise("""
No model names provided.
if model_names == [] do
Mix.raise("""
No model names provided.
Usage:
mix opsmo.embed MODEL_NAME [MODEL_NAME...] [--branch BRANCH_NAME]
""")
end
Usage:
mix opsmo.embed MODEL_NAME[:VERSION] [MODEL_NAME[:VERSION]...]
""")
end

def run(model_specs) do
Mix.Task.run("app.start")

model_names
|> Enum.each(fn model_name ->
IO.puts("\nDownloading model: #{model_name}")
model_specs
|> Enum.each(fn spec ->
{model_name, branch} = parse_model_spec(spec)
IO.puts("\nDownloading model: #{model_name} (#{branch})")

HF.download!(model_name, branch: opts[:branch])
HF.download!(model_name, branch: branch)

IO.puts("✓ #{model_name} downloaded successfully")
end)
end

defp parse_model_spec(spec) do
case String.split(spec, ":", parts: 2) do
[model_name, branch] -> {model_name, branch}
[model_name] -> {model_name, "main"}
end
end
end
4 changes: 3 additions & 1 deletion lib/opsmo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ defmodule Opsmo do

def load(name) do
mode = Application.get_env(:opsmo, :mode, :inference)
branch = Application.get_env(:opsmo, :branch, "main")
models_config = Application.get_env(:opsmo, :models, %{})

branch = Map.get(models_config, name, "main")

path = models_path(mode) <> String.downcase(name)

Expand Down
12 changes: 7 additions & 5 deletions lib/opsmo/hf.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ defmodule Opsmo.HF do
# Get file list from HF API
files = list_model_files(full_name, branch)

IO.puts("\nDownloading #{model_name} (#{branch})")

# Download all files
Opsmo.TaskSupervisor
|> Task.Supervisor.async_stream_nolink(files, __MODULE__, :download_file, [
full_name,
model_path,
branch
])
|> Task.Supervisor.async_stream_nolink(files, fn file ->
IO.puts("Downloading #{file}...")
download_file(file, full_name, model_path, branch)
end)
|> Enum.map(fn
{:ok, %{body: body}} ->
IO.puts("✓ Downloaded #{Path.basename(body.path)}")
body.path

{:error, reason} ->
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Opsmo.MixProject do
def project do
[
app: :opsmo,
version: "0.3.7",
version: "0.3.8",
elixir: "~> 1.15",
description: description(),
license: "Apache-2.0",
Expand Down
6 changes: 6 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
%{
"axon": {:hex, :axon, "0.7.0", "2e2c6d93b4afcfa812566b8922204fa022b60081e86ebd411df4db7ea30f5457", [:mix], [{:kino, "~> 0.7", [hex: :kino, repo: "hexpm", optional: true]}, {:kino_vega_lite, "~> 0.1.7", [hex: :kino_vega_lite, repo: "hexpm", optional: true]}, {:nx, "~> 0.9", [hex: :nx, repo: "hexpm", optional: false]}, {:polaris, "~> 0.1", [hex: :polaris, repo: "hexpm", optional: false]}, {:table_rex, "~> 3.1.1", [hex: :table_rex, repo: "hexpm", optional: true]}], "hexpm", "ee9857a143c9486597ceff434e6ca833dc1241be6158b01025b8217757ed1036"},
"complex": {:hex, :complex, "0.6.0", "b0130086a7a8c33574d293b2e0e250f4685580418eac52a5658a4bd148f3ccf1", [:mix], [], "hexpm", "0a5fa95580dcaf30fcd60fe1aaf24327c0fe401e98c24d892e172e79498269f9"},
"earmark_parser": {:hex, :earmark_parser, "1.4.43", "34b2f401fe473080e39ff2b90feb8ddfeef7639f8ee0bbf71bb41911831d77c5", [:mix], [], "hexpm", "970a3cd19503f5e8e527a190662be2cee5d98eed1ff72ed9b3d1a3d466692de8"},
"elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"},
"emlx": {:git, "https://github.com/elixir-nx/emlx.git", "907f5951b2c4e0b5c73fc215b56241842ff1e00f", []},
"ex_doc": {:hex, :ex_doc, "0.36.1", "4197d034f93e0b89ec79fac56e226107824adcce8d2dd0a26f5ed3a95efc36b1", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d7d26a7cf965dacadcd48f9fa7b5953d7d0cfa3b44fa7a65514427da44eafd89"},
"finch": {:hex, :finch, "0.19.0", "c644641491ea854fc5c1bbaef36bfc764e3f08e7185e1f084e35e0672241b76d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "fc5324ce209125d1e2fa0fcd2634601c52a787aff1cd33ee833664a5af4ea2b6"},
"hpax": {:hex, :hpax, "1.0.2", "762df951b0c399ff67cc57c3995ec3cf46d696e41f0bba17da0518d94acd4aac", [:mix], [], "hexpm", "2f09b4c1074e0abd846747329eaa26d535be0eb3d189fa69d812bfb8bfefd32f"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
"makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"},
"mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"},
"mint": {:hex, :mint, "1.6.2", "af6d97a4051eee4f05b5500671d47c3a67dac7386045d87a904126fd4bbcea2e", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "5ee441dffc1892f1ae59127f74afe8fd82fda6587794278d924e4d90ea3d63f9"},
"nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
"nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
"nx": {:hex, :nx, "0.9.2", "17563029c01bf749aad3c31234326d7665abd0acc33ee2acbe531a4759f29a8a", [:mix], [{:complex, "~> 0.5", [hex: :complex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "914d74741617d8103de8ab1f8c880353e555263e1c397b8a1109f79a3716557f"},
"polaris": {:hex, :polaris, "0.1.0", "dca61b18e3e801ecdae6ac9f0eca5f19792b44a5cb4b8d63db50fc40fc038d22", [:mix], [{:nx, "~> 0.5", [hex: :nx, repo: "hexpm", optional: false]}], "hexpm", "13ef2b166650e533cb24b10e2f3b8ab4f2f449ba4d63156e8c569527f206e2c2"},
Expand Down

0 comments on commit fba0410

Please sign in to comment.