-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add list * list models works, passes tests * add to readme * update version * add model create to readme * add create behavior * add create model func * fix test * notify is param is missing * hardware list and tests * encode json * fix json encode/decode state * add create model to cheatsheet * update changelog * update version * update version
- Loading branch information
Showing
11 changed files
with
224 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
Nothing to see here, yet! | ||
## [2023-11-06] | ||
|
||
- Added `Replicate.Models.create/4` function to create a model for a user or organization with a given name, visibility, and hardware SKU. | ||
- Added `Replicate.Hardware.list/0` function to list available hardware SKUs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
defmodule Replicate.Hardware do | ||
@moduledoc """ | ||
Documentation for `Hardware`. | ||
""" | ||
@behaviour Replicate.Hardware.Behaviour | ||
@replicate_client Application.compile_env(:replicate, :replicate_client, Replicate.Client) | ||
alias Replicate.Hardware | ||
alias Replicate.Hardware.Hardware | ||
|
||
@doc """ | ||
Lists all hardware. | ||
Returns [Hardware.t()]. | ||
## Examples | ||
``` | ||
iex> Replicate.Hardware.list() | ||
[%Hardware{ | ||
name: "CPU", | ||
sku: "cpu" | ||
}, | ||
%Hardware{ | ||
name: "Nvidia T4 GPU", | ||
sku: "gpu-t4" | ||
}, | ||
%Hardware{ | ||
name: "Nvidia A40 GPU", | ||
sku: "gpu-a40-small" | ||
}, | ||
%Hardware{ | ||
name: "Nvidia A40 (Large) GPU", | ||
sku: "gpu-a40-large" | ||
} | ||
] | ||
``` | ||
""" | ||
def list() do | ||
{:ok, results} = @replicate_client.request(:get, "/v1/hardware") | ||
|
||
results | ||
|> Jason.decode!() | ||
|> Enum.map(fn h -> | ||
atom_map = string_to_atom(h) | ||
struct!(Hardware, atom_map) | ||
end) | ||
end | ||
|
||
defp string_to_atom(body) do | ||
for {k, v} <- body, into: %{}, do: {String.to_atom(k), v} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule Replicate.Hardware.Behaviour do | ||
@moduledoc """ | ||
Documentation for the Hardware Behaviour | ||
""" | ||
alias Replicate.Hardware.Hardware | ||
@callback list :: list(Hardware.t()) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule Replicate.Hardware.Hardware do | ||
@doc """ | ||
Documentation for `Hardware`. | ||
""" | ||
@enforce_keys [:sku, :name] | ||
defstruct [:sku, :name] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters