Skip to content

Commit 3437759

Browse files
committed
change model_id format
1 parent 54a527a commit 3437759

File tree

3 files changed

+12
-36
lines changed

3 files changed

+12
-36
lines changed

docs/resources/inference_custom_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ In addition to all arguments above, the following attributes are exported:
5959
- `description` - A textual description of the model (if available).
6060
- `has_eula` - Whether the model requires end-user license agreement acceptance before use.
6161
- `parameter_size_bits` - Size, in bits, of the model parameters.
62-
- `size_bits` - Total size, in bytes, of the model archive.
62+
- `size_bytes` - Total size, in bytes, of the model archive.
6363
- `nodes_support` - List of supported node types and their quantization options. Each entry contains:
6464
- `node_type_name` - The type of node supported.
6565
- `quantization` - A list of supported quantization options, including:

internal/services/inference/custom_model.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func ResourceCustomModel() *schema.Resource {
124124
Computed: true,
125125
Description: "Size, in bits, of the model parameters",
126126
},
127-
"size_bits": {
127+
"size_bytes": {
128128
Type: schema.TypeInt,
129129
Computed: true,
130130
Description: "Total size, in bytes, of the model files",
@@ -161,7 +161,7 @@ func ResourceCustomModelCreate(ctx context.Context, d *schema.ResourceData, m in
161161
return diag.FromErr(err)
162162
}
163163

164-
d.SetId(regional.NewIDString(region, model.ID))
164+
d.SetId(model.ID)
165165

166166
model, err = waitForModel(ctx, api, region, model.ID, d.Timeout(schema.TimeoutCreate))
167167
if err != nil {
@@ -178,12 +178,12 @@ func ResourceCustomModelCreate(ctx context.Context, d *schema.ResourceData, m in
178178
}
179179

180180
func ResourceCustomModelRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
181-
api, region, id, err := NewAPIWithRegionAndID(m, d.Id())
181+
api, region, err := NewAPIWithRegion(d, m)
182182
if err != nil {
183183
return diag.FromErr(err)
184184
}
185185

186-
model, err := waitForModel(ctx, api, region, id, d.Timeout(schema.TimeoutRead))
186+
model, err := waitForModel(ctx, api, region, d.Id(), d.Timeout(schema.TimeoutRead))
187187
if err != nil {
188188
if httperrors.Is404(err) {
189189
d.SetId("")
@@ -195,7 +195,7 @@ func ResourceCustomModelRead(ctx context.Context, d *schema.ResourceData, m inte
195195
}
196196

197197
_ = d.Set("parameter_size_bits", int32(model.ParameterSizeBits))
198-
_ = d.Set("size_bits", int64(model.SizeBytes))
198+
_ = d.Set("size_bytes", int64(model.SizeBytes))
199199
_ = d.Set("name", model.Name)
200200
_ = d.Set("status", model.Status)
201201
_ = d.Set("description", model.Description)
@@ -209,23 +209,18 @@ func ResourceCustomModelRead(ctx context.Context, d *schema.ResourceData, m inte
209209
}
210210

211211
func ResourceCustomModelDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
212-
api, region, id, err := NewAPIWithRegionAndID(m, d.Id())
212+
api, region, err := NewAPIWithRegion(d, m)
213213
if err != nil {
214214
return diag.FromErr(err)
215215
}
216216

217-
_, err = waitForModel(ctx, api, region, id, d.Timeout(schema.TimeoutDelete))
217+
_, err = waitForModel(ctx, api, region, d.Id(), d.Timeout(schema.TimeoutDelete))
218218
if err != nil {
219219
return diag.FromErr(err)
220220
}
221221

222-
err = api.DeleteModel(&inference.DeleteModelRequest{
222+
return diag.FromErr(api.DeleteModel(&inference.DeleteModelRequest{
223223
Region: region,
224-
ModelID: id,
225-
}, scw.WithContext(ctx))
226-
if err != nil {
227-
return diag.FromErr(err)
228-
}
229-
230-
return nil
224+
ModelID: d.Id(),
225+
}, scw.WithContext(ctx)))
231226
}

internal/services/inference/deployment.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
99
"github.com/scaleway/scaleway-sdk-go/api/inference/v1"
1010
"github.com/scaleway/scaleway-sdk-go/scw"
11-
scwvalidation "github.com/scaleway/scaleway-sdk-go/validation"
1211
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
1312
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional"
1413
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/account"
@@ -56,18 +55,6 @@ func ResourceDeployment() *schema.Resource {
5655
Required: true,
5756
Description: "The model id used for the deployment",
5857
ForceNew: true,
59-
DiffSuppressFunc: func(k, old, newValue string, d *schema.ResourceData) bool {
60-
if old == "" || newValue == "" {
61-
return false
62-
}
63-
if !scwvalidation.IsUUID(newValue) {
64-
newID := regional.ExpandID(newValue).ID
65-
66-
return old == newID
67-
}
68-
69-
return old == newValue
70-
},
7158
},
7259
"accept_eula": {
7360
Type: schema.TypeBool,
@@ -196,18 +183,12 @@ func ResourceDeploymentCreate(ctx context.Context, d *schema.ResourceData, m int
196183
return diag.FromErr(err)
197184
}
198185

199-
modelID := d.Get("model_id")
200-
201-
if !scwvalidation.IsUUID(modelID.(string)) {
202-
modelID = regional.ExpandID(modelID).ID
203-
}
204-
205186
req := &inference.CreateDeploymentRequest{
206187
Region: region,
207188
ProjectID: d.Get("project_id").(string),
208189
Name: d.Get("name").(string),
209190
NodeTypeName: d.Get("node_type").(string),
210-
ModelID: modelID.(string),
191+
ModelID: d.Get("model_id").(string),
211192
Tags: types.ExpandStrings(d.Get("tags")),
212193
Endpoints: buildEndpoints(d),
213194
}

0 commit comments

Comments
 (0)