Skip to content

Commit 7ac52b7

Browse files
committed
update doc and tests
1 parent c6b5ec7 commit 7ac52b7

File tree

8 files changed

+1423
-6436
lines changed

8 files changed

+1423
-6436
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
subcategory: "inference"
3+
page_title: "Scaleway: scaleway_inference_model"
4+
---
5+
6+
# scaleway_inference_model
7+
8+
The `scaleway_inference_model` data source allows you to retrieve information about an inference model available in the Scaleway Inference API, either by providing the model's `name` or its `model_id`.
9+
10+
## Example Usage
11+
12+
### Basic
13+
14+
```hcl
15+
data "scaleway_inference_model" "my_model" {
16+
name = "meta/llama-3.1-8b-instruct:fp8"
17+
}
18+
```
19+
20+
## Argument Reference
21+
22+
You must provide either name or model_id, but not both.
23+
24+
- `name` (Optional, Conflicts with model_id) The fully qualified name of the model to look up (e.g., "meta/llama-3.1-8b-instruct:fp8"). The provider will search for a model with an exact name match in the selected region and project.
25+
- `model_id` (Optional, Conflicts with name) The ID of the model to retrieve. Must be a valid UUID with locality (i.e., Scaleway's zoned UUID format).
26+
- `project_id` (Optional) The project ID to use when listing models. If not provided, the provider default project is used.
27+
- `region` (Optional) The region where the model is hosted. If not set, the provider default region is used.
28+
29+
## Attributes Reference
30+
31+
In addition to the input arguments above, the following attributes are exported:
32+
33+
- `id` - The unique identifier of the model.
34+
- `tags` - Tags associated with the model.
35+
- `status` - The current status of the model (e.g., ready, error, etc.).
36+
- `description` - A textual description of the model (if available).
37+
- `has_eula` - Whether the model requires end-user license agreement acceptance before use.
38+
- `parameter_size_bits` - Size, in bits, of the model parameters.
39+
- `size_bytes` - Total size, in bytes, of the model archive.
40+
- `nodes_support` - List of supported node types and their quantization options. Each entry contains:
41+
- `node_type_name` - The type of node supported.
42+
- `quantization` - A list of supported quantization options, including:
43+
- `quantization_bits` - Number of bits used for quantization (e.g., 8, 16).
44+
- `allowed` - Whether this quantization is allowed.
45+
- `max_context_size` - Maximum context length supported by this quantization.
46+
47+

docs/resources/inference_deployment.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ For more information, see the [API documentation](https://www.scaleway.com/en/de
1313
### Basic
1414

1515
```terraform
16+
data "scaleway_inference_model" "my_model" {
17+
name = "meta/llama-3.1-8b-instruct:fp8"
18+
}
19+
1620
resource "scaleway_inference_deployment" "deployment" {
1721
name = "tf-inference-deployment"
1822
node_type = "L4"
19-
model_id = "d33fb5fd-75ca-4dfb-8952-8af8b8b28be5"
23+
model_id = data.scaleway_inference_model.my_model.id
2024
public_endpoint {
2125
is_enabled = true
2226
}

docs/resources/inference_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ resource "scaleway_inference_deployment" "my_deployment" {
5353

5454
In addition to all arguments above, the following attributes are exported:
5555

56-
- `id` - The unique identifier of the custom model.
56+
- `id` - The unique identifier of the model.
5757
- `tags` - Tags associated with the model.
5858
- `status` - The current status of the model (e.g., ready, error, etc.).
5959
- `description` - A textual description of the model (if available).

internal/services/inference/model_data_source_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
66
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
7+
inferencetestfuncs "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/inference/testfuncs"
78
"testing"
89
)
910

@@ -31,3 +32,46 @@ func TestAccDataSourceModel_Basic(t *testing.T) {
3132
},
3233
})
3334
}
35+
36+
func TestAccDataSourceModel_Custom(t *testing.T) {
37+
tt := acctest.NewTestTools(t)
38+
defer tt.Cleanup()
39+
40+
modelName := "TestAccDataSourceModel_Custom"
41+
42+
resource.ParallelTest(t, resource.TestCase{
43+
PreCheck: func() { acctest.PreCheck(t) },
44+
ProviderFactories: tt.ProviderFactories,
45+
CheckDestroy: inferencetestfuncs.IsModelDestroyed(tt),
46+
Steps: []resource.TestStep{
47+
{
48+
Config: fmt.Sprintf(`
49+
resource "scaleway_inference_model" "test" {
50+
name = "%s"
51+
url = "%s"
52+
}
53+
54+
`, modelName, modelURLCompatible),
55+
Check: resource.ComposeTestCheckFunc(
56+
testAccCheckModelExists(tt, "scaleway_inference_model.test"),
57+
resource.TestCheckResourceAttr("scaleway_inference_model.test", "name", modelName),
58+
),
59+
},
60+
{
61+
Config: fmt.Sprintf(`
62+
resource "scaleway_inference_model" "test" {
63+
name = "%s"
64+
url = "%s"
65+
}
66+
67+
data "scaleway_inference_model" "my-model" {
68+
name = "%s"
69+
}`, modelName, modelURLCompatible, modelName),
70+
Check: resource.ComposeTestCheckFunc(
71+
testAccCheckModelExists(tt, "data.scaleway_inference_model.my-model"),
72+
resource.TestCheckResourceAttr("data.scaleway_inference_model.my-model", "name", modelName),
73+
),
74+
},
75+
},
76+
})
77+
}

0 commit comments

Comments
 (0)