Skip to content

Commit 1f93d2e

Browse files
committed
fix linter
1 parent 7ac52b7 commit 1f93d2e

File tree

5 files changed

+842
-187
lines changed

5 files changed

+842
-187
lines changed

docs/data-sources/inference_model.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ In addition to the input arguments above, the following attributes are exported:
3838
- `parameter_size_bits` - Size, in bits, of the model parameters.
3939
- `size_bytes` - Total size, in bytes, of the model archive.
4040
- `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-
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.

internal/services/inference/deployment_test.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
)
1414

1515
const (
16-
modelID = "ca90eec6-c8b2-4814-8b00-8bb3bc803879"
17-
nodeType = "L4"
16+
modelNameMeta = "meta/llama-3.1-8b-instruct:bf16"
17+
nodeType = "L4"
1818
)
1919

2020
func TestAccDeployment_Basic(t *testing.T) {
@@ -28,16 +28,21 @@ func TestAccDeployment_Basic(t *testing.T) {
2828
Steps: []resource.TestStep{
2929
{
3030
Config: fmt.Sprintf(`
31+
data "scaleway_inference_model" "my-model" {
32+
name = "%s"
33+
}
34+
3135
resource "scaleway_inference_deployment" "main" {
3236
name = "test-inference-deployment-basic"
3337
node_type = "%s"
34-
model_id = "%s"
38+
model_id = data.scaleway_inference_model.my-model.id
3539
public_endpoint {
3640
is_enabled = true
3741
}
3842
accept_eula = true
3943
}
40-
`, nodeType, modelID),
44+
45+
`, modelNameMeta, nodeType),
4146
Check: resource.ComposeTestCheckFunc(
4247
testAccCheckDeploymentExists(tt, "scaleway_inference_deployment.main"),
4348
resource.TestCheckResourceAttr("scaleway_inference_deployment.main", "name", "test-inference-deployment-basic"),
@@ -58,19 +63,24 @@ func TestAccDeployment_Endpoint(t *testing.T) {
5863
Steps: []resource.TestStep{
5964
{
6065
Config: fmt.Sprintf(`
66+
data "scaleway_inference_model" "my-model" {
67+
name = "%s"
68+
}
69+
6170
resource "scaleway_vpc_private_network" "pn01" {
6271
name = "private-network-test-inference"
6372
}
73+
6474
resource "scaleway_inference_deployment" "main" {
6575
name = "test-inference-deployment-endpoint-private"
6676
node_type = "%s"
67-
model_id = "%s"
77+
model_id = data.scaleway_inference_model.my-model.id
6878
private_endpoint {
6979
private_network_id = "${scaleway_vpc_private_network.pn01.id}"
7080
}
7181
accept_eula = true
7282
}
73-
`, nodeType, modelID),
83+
`, modelNameMeta, nodeType),
7484
Check: resource.ComposeTestCheckFunc(
7585
testAccCheckDeploymentExists(tt, "scaleway_inference_deployment.main"),
7686
resource.TestCheckResourceAttr("scaleway_inference_deployment.main", "name", "test-inference-deployment-endpoint-private"),
@@ -80,13 +90,18 @@ func TestAccDeployment_Endpoint(t *testing.T) {
8090
},
8191
{
8292
Config: fmt.Sprintf(`
93+
data "scaleway_inference_model" "my-model" {
94+
name = "%s"
95+
}
96+
8397
resource "scaleway_vpc_private_network" "pn01" {
8498
name = "private-network-test-inference-public"
8599
}
100+
86101
resource "scaleway_inference_deployment" "main" {
87102
name = "test-inference-deployment-basic-endpoints-private-public"
88103
node_type = "%s"
89-
model_id = "%s"
104+
model_id = data.scaleway_inference_model.my-model.id
90105
private_endpoint {
91106
private_network_id = "${scaleway_vpc_private_network.pn01.id}"
92107
}
@@ -95,7 +110,7 @@ func TestAccDeployment_Endpoint(t *testing.T) {
95110
}
96111
accept_eula = true
97112
}
98-
`, nodeType, modelID),
113+
`, modelNameMeta, nodeType),
99114
Check: resource.ComposeTestCheckFunc(
100115
testAccCheckDeploymentExists(tt, "scaleway_inference_deployment.main"),
101116
resource.TestCheckResourceAttr("scaleway_inference_deployment.main", "name", "test-inference-deployment-basic-endpoints-private-public"),

internal/services/inference/model_data_source.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package inference
22

33
import (
44
"context"
5-
"fmt"
5+
"errors"
6+
67
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
89
"github.com/scaleway/scaleway-sdk-go/api/inference/v1"
@@ -41,6 +42,7 @@ func DataSourceModelRead(ctx context.Context, d *schema.ResourceData, m interfac
4142
pageSize := uint32(1000)
4243
if !ok {
4344
modelName := d.Get("name").(string)
45+
4446
modelList, err := api.ListModels(&inference.ListModelsRequest{
4547
Region: region,
4648
ProjectID: types.ExpandStringPtr(d.Get("project_id")),
@@ -63,8 +65,10 @@ func DataSourceModelRead(ctx context.Context, d *schema.ResourceData, m interfac
6365

6466
modelID = foundModel.ID
6567
}
68+
6669
regionalID := datasource.NewRegionalID(modelID, region)
6770
d.SetId(regionalID)
71+
6872
err = d.Set("model_id", regionalID)
6973
if err != nil {
7074
return diag.FromErr(err)
@@ -76,7 +80,7 @@ func DataSourceModelRead(ctx context.Context, d *schema.ResourceData, m interfac
7680
}
7781

7882
if d.Id() == "" {
79-
return diag.FromErr(fmt.Errorf("model_id is empty"))
83+
return diag.FromErr(errors.New("model_id is empty"))
8084
}
8185

8286
return nil

internal/services/inference/model_data_source_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package inference_test
22

33
import (
44
"fmt"
5+
"testing"
6+
57
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
68
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
79
inferencetestfuncs "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/inference/testfuncs"
8-
"testing"
910
)
1011

1112
func TestAccDataSourceModel_Basic(t *testing.T) {

internal/services/inference/testdata/deployment-basic.cassette.yaml

Lines changed: 806 additions & 169 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)