Skip to content

Commit fc74e95

Browse files
authored
revert: switch back to the legacy mediatype for v0.1.0 (#287)
Signed-off-by: chlins <[email protected]>
1 parent 00d982a commit fc74e95

File tree

14 files changed

+36
-27
lines changed

14 files changed

+36
-27
lines changed

pkg/backend/attach.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ const (
5252
var (
5353
// mediaTypePriorityMap defines the priority for layer sorting by group.
5454
mediaTypePriorityMap = map[string]int{
55-
modelspec.MediaTypeModelWeightConfig: modelWeightConfigPriority,
56-
modelspec.MediaTypeModelWeight: modelWeightPriority,
57-
modelspec.MediaTypeModelCode: modelCodePriority,
58-
modelspec.MediaTypeModelDoc: modelDocPriority,
55+
legacymodelspec.MediaTypeModelWeightConfig: modelWeightConfigPriority,
56+
legacymodelspec.MediaTypeModelWeight: modelWeightPriority,
57+
legacymodelspec.MediaTypeModelCode: modelCodePriority,
58+
legacymodelspec.MediaTypeModelDoc: modelDocPriority,
5959
}
6060
)
6161

@@ -137,7 +137,7 @@ func (b *backend) Attach(ctx context.Context, filepath string, cfg *config.Attac
137137
}
138138
}
139139

140-
var config modelspec.Model
140+
var config legacymodelspec.Model
141141
if !cfg.Config {
142142
var reasoning bool
143143
if srcModelConfig.Config.Capabilities != nil && srcModelConfig.Config.Capabilities.Reasoning != nil {
@@ -301,33 +301,33 @@ func (b *backend) getModelConfig(ctx context.Context, reference string, desc oci
301301

302302
func (b *backend) getProcessor(filepath string, rawMediaType bool) processor.Processor {
303303
if modelfile.IsFileType(filepath, modelfile.ConfigFilePatterns) {
304-
mediaType := modelspec.MediaTypeModelWeightConfig
304+
mediaType := legacymodelspec.MediaTypeModelWeightConfig
305305
if rawMediaType {
306-
mediaType = modelspec.MediaTypeModelWeightConfigRaw
306+
mediaType = legacymodelspec.MediaTypeModelWeightConfigRaw
307307
}
308308
return processor.NewModelConfigProcessor(b.store, mediaType, []string{filepath})
309309
}
310310

311311
if modelfile.IsFileType(filepath, modelfile.ModelFilePatterns) {
312-
mediaType := modelspec.MediaTypeModelWeight
312+
mediaType := legacymodelspec.MediaTypeModelWeight
313313
if rawMediaType {
314-
mediaType = modelspec.MediaTypeModelWeightRaw
314+
mediaType = legacymodelspec.MediaTypeModelWeightRaw
315315
}
316316
return processor.NewModelProcessor(b.store, mediaType, []string{filepath})
317317
}
318318

319319
if modelfile.IsFileType(filepath, modelfile.CodeFilePatterns) {
320-
mediaType := modelspec.MediaTypeModelCode
320+
mediaType := legacymodelspec.MediaTypeModelCode
321321
if rawMediaType {
322-
mediaType = modelspec.MediaTypeModelCodeRaw
322+
mediaType = legacymodelspec.MediaTypeModelCodeRaw
323323
}
324324
return processor.NewCodeProcessor(b.store, mediaType, []string{filepath})
325325
}
326326

327327
if modelfile.IsFileType(filepath, modelfile.DocFilePatterns) {
328-
mediaType := modelspec.MediaTypeModelDoc
328+
mediaType := legacymodelspec.MediaTypeModelDoc
329329
if rawMediaType {
330-
mediaType = modelspec.MediaTypeModelDocRaw
330+
mediaType = legacymodelspec.MediaTypeModelDocRaw
331331
}
332332
return processor.NewDocProcessor(b.store, mediaType, []string{filepath})
333333
}

pkg/backend/attach_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"reflect"
2424
"testing"
2525

26-
modelspec "github.com/modelpack/model-spec/specs-go/v1"
26+
modelspec "github.com/dragonflyoss/model-spec/specs-go/v1"
2727
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2828
"github.com/stretchr/testify/assert"
2929

pkg/backend/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"path/filepath"
2525

2626
retry "github.com/avast/retry-go/v4"
27-
modelspec "github.com/modelpack/model-spec/specs-go/v1"
27+
modelspec "github.com/dragonflyoss/model-spec/specs-go/v1"
2828
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2929
"github.com/sirupsen/logrus"
3030

pkg/backend/build/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
"syscall"
3131
"time"
3232

33+
modelspec "github.com/dragonflyoss/model-spec/specs-go/v1"
3334
sha256 "github.com/minio/sha256-simd"
34-
modelspec "github.com/modelpack/model-spec/specs-go/v1"
3535
godigest "github.com/opencontainers/go-digest"
3636
spec "github.com/opencontainers/image-spec/specs-go"
3737
ocispec "github.com/opencontainers/image-spec/specs-go/v1"

pkg/backend/build/builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"testing"
3030
"time"
3131

32-
modelspec "github.com/modelpack/model-spec/specs-go/v1"
32+
modelspec "github.com/dragonflyoss/model-spec/specs-go/v1"
3333
godigest "github.com/opencontainers/go-digest"
3434
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3535
"github.com/stretchr/testify/assert"

pkg/backend/build/local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"fmt"
2222
"io"
2323

24-
modelspec "github.com/modelpack/model-spec/specs-go/v1"
24+
modelspec "github.com/dragonflyoss/model-spec/specs-go/v1"
2525
godigest "github.com/opencontainers/go-digest"
2626
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2727

pkg/backend/build/local_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"strings"
2424
"testing"
2525

26-
modelspec "github.com/modelpack/model-spec/specs-go/v1"
26+
modelspec "github.com/dragonflyoss/model-spec/specs-go/v1"
2727
godigest "github.com/opencontainers/go-digest"
2828
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2929
"github.com/stretchr/testify/mock"

pkg/backend/build/remote.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"fmt"
2222
"io"
2323

24-
modelspec "github.com/modelpack/model-spec/specs-go/v1"
24+
modelspec "github.com/dragonflyoss/model-spec/specs-go/v1"
2525
godigest "github.com/opencontainers/go-digest"
2626
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2727

pkg/backend/processor/base.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"sync"
2828

2929
"github.com/avast/retry-go/v4"
30+
legacymodelspec "github.com/dragonflyoss/model-spec/specs-go/v1"
3031
modelspec "github.com/modelpack/model-spec/specs-go/v1"
3132
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3233
"github.com/sirupsen/logrus"
@@ -171,11 +172,19 @@ func (b *base) Process(ctx context.Context, builder build.Builder, workDir strin
171172
// Sort by filepath by default.
172173
var pathI, pathJ string
173174
if descriptors[i].Annotations != nil {
174-
pathI = descriptors[i].Annotations[modelspec.AnnotationFilepath]
175+
if descriptors[i].Annotations[modelspec.AnnotationFilepath] != "" {
176+
pathI = descriptors[i].Annotations[modelspec.AnnotationFilepath]
177+
} else {
178+
pathI = descriptors[i].Annotations[legacymodelspec.AnnotationFilepath]
179+
}
175180
}
176181

177182
if descriptors[j].Annotations != nil {
178-
pathJ = descriptors[j].Annotations[modelspec.AnnotationFilepath]
183+
if descriptors[i].Annotations[modelspec.AnnotationFilepath] != "" {
184+
pathJ = descriptors[i].Annotations[modelspec.AnnotationFilepath]
185+
} else {
186+
pathJ = descriptors[i].Annotations[legacymodelspec.AnnotationFilepath]
187+
}
179188
}
180189

181190
return pathI < pathJ

pkg/backend/processor/code_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"path/filepath"
2323
"testing"
2424

25-
modelspec "github.com/modelpack/model-spec/specs-go/v1"
25+
modelspec "github.com/dragonflyoss/model-spec/specs-go/v1"
2626
godigest "github.com/opencontainers/go-digest"
2727
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2828
"github.com/stretchr/testify/assert"

0 commit comments

Comments
 (0)