Skip to content

Commit 6bc2f6a

Browse files
committed
Update model to be a single object on kitfile
Updates the build and export to adjust to single object.
1 parent f9d38ea commit 6bc2f6a

File tree

7 files changed

+90
-27
lines changed

7 files changed

+90
-27
lines changed

pkg/artifact/jozu_file.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import (
1010

1111
type (
1212
JozuFile struct {
13-
ManifestVersion string `json:"manifestVersion"`
14-
Package Package `json:"package,omitempty"`
15-
Code []Code `json:"code,omitempty"`
16-
DataSets []DataSet `json:"datasets,omitempty"`
17-
Models []TrainedModel `json:"models,omitempty"`
13+
ManifestVersion string `json:"manifestVersion"`
14+
Kit ModelKit `json:"modelkit,omitempty"`
15+
Code []Code `json:"code,omitempty"`
16+
DataSets []DataSet `json:"datasets,omitempty"`
17+
Model TrainedModel `json:"model,omitempty"`
1818
}
1919

20-
Package struct {
20+
ModelKit struct {
2121
Name string `json:"name,omitempty"`
2222
Version string `json:"version,omitempty"`
2323
Description string `json:"description,omitempty"`

pkg/cmd/build/build.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,16 @@ func (options *BuildOptions) RunBuild() error {
134134
}
135135

136136
// 4. package the TrainedModels
137-
for _, trainedModel := range jozufile.Models {
138-
modelPath, err := filesystem.VerifySubpath(options.ContextDir, trainedModel.Path)
139-
if err != nil {
140-
return err
141-
}
142-
layer := &artifact.ModelLayer{
143-
BaseDir: modelPath,
144-
MediaType: constants.ModelLayerMediaType,
145-
}
146-
model.Layers = append(model.Layers, *layer)
137+
138+
modelPath, err := filesystem.VerifySubpath(options.ContextDir, jozufile.Model.Path)
139+
if err != nil {
140+
return err
141+
}
142+
layer := &artifact.ModelLayer{
143+
BaseDir: modelPath,
144+
MediaType: constants.ModelLayerMediaType,
147145
}
146+
model.Layers = append(model.Layers, *layer)
148147

149148
modelStorePath := options.storageHome
150149
repo := ""

pkg/cmd/build/jozu-file.md pkg/cmd/build/kit-file.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# Jozu AI/ML Packaging Manifest Format Reference
1+
# Kitfile AI/ML Packaging Manifest Format Reference
22

3-
The Jozu manifest for AI/ML is a YAML file designed to encapsulate all the necessary information about the package, including code, datasets, models, and their metadata. This reference documentation outlines the structure and specifications of the manifest format.
3+
The Kitfile manifest for AI/ML is a YAML file designed to encapsulate all the necessary information about the package, including code, datasets, model, and their metadata. This reference documentation outlines the structure and specifications of the manifest format.
44

55
## Overview
66

7-
The manifest is structured into several key sections: `version`, `package`,`code`, `datasets` and `models`. Each section serves a specific purpose in describing the AI/ML package components and requirements.
7+
The manifest is structured into several key sections: `version`, `package`,`code`, `datasets` and `model`. Each section serves a specific purpose in describing the AI/ML package components and requirements.
88

99
### `ManifestVersion`
1010

1111
- **Description**: Specifies the manifest format version.
1212
- **Type**: String
1313
- **Example**: `1.0`
1414

15-
### `package`
15+
### `modelkit`
1616

1717
This section provides general information about the AI/ML project.
1818

@@ -56,10 +56,10 @@ This section provides general information about the AI/ML project.
5656
- `license`: SPDX license identifier for the dataset.
5757
- `preprocessing`: Reference to preprocessing steps.
5858

59-
#### `models`
59+
#### `model`
6060

6161
- **Description**: Details of the trained models included in the package.
62-
- **Type**: Object Array
62+
- **Type**: Object
6363
- `name`: Name of the model
6464
- `path`: Location of the model file or directory relative to the context
6565
- `framework`: AI/ML framework

pkg/cmd/dev/cmd.go

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package dev
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
const (
10+
shortDesc = `Start development server`
11+
longDesc = `Start development server TODO`
12+
)
13+
14+
var (
15+
flags *DevFlags
16+
opts *DevOptions
17+
)
18+
19+
type DevFlags struct {
20+
Port int
21+
}
22+
23+
type DevOptions struct {
24+
port int
25+
}
26+
27+
func (opts *DevOptions) complete(args []string) error {
28+
opts.port = flags.Port
29+
return nil
30+
}
31+
func (opts *DevOptions) validate() error {
32+
return nil
33+
}
34+
35+
func DevCommand() *cobra.Command {
36+
opts = &DevOptions{}
37+
flags = &DevFlags{}
38+
cmd := &cobra.Command{
39+
Use: "dev",
40+
Short: shortDesc,
41+
Long: longDesc,
42+
RunE: runCommand(opts),
43+
}
44+
cmd.Flags().IntVar(&flags.Port, "port", 8080, "Port for development server to listen on")
45+
return cmd
46+
}
47+
48+
func runCommand(opts *DevOptions) func(cmd *cobra.Command, args []string) error {
49+
return func(cmd *cobra.Command, args []string) error {
50+
if err := opts.complete(args); err != nil {
51+
return fmt.Errorf("failed to complete options: %w", err)
52+
}
53+
if err := opts.validate(); err != nil {
54+
return fmt.Errorf("failed to validate options: %w", err)
55+
}
56+
return nil
57+
}
58+
}

pkg/cmd/export/export.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,17 @@ func ExportModel(ctx context.Context, store oras.Target, ref *registry.Reference
3939

4040
// Since there might be multiple models, etc. we need to synchronously iterate
4141
// through the config's relevant field to get the correct path for exporting
42-
var modelIdx, codeIdx, datasetIdx int
42+
var codeIdx, datasetIdx int
4343
for _, layerDesc := range manifest.Layers {
4444
layerDir := ""
4545
switch layerDesc.MediaType {
4646
case constants.ModelLayerMediaType:
4747
if !options.exportConf.ExportModels {
4848
continue
4949
}
50-
modelEntry := config.Models[modelIdx]
50+
modelEntry := config.Model
5151
layerDir = filepath.Join(options.exportDir, modelEntry.Path)
5252
fmt.Printf("Exporting model %s to %s\n", modelEntry.Name, layerDir)
53-
modelIdx += 1
5453

5554
case constants.CodeLayerMediaType:
5655
if !options.exportConf.ExportCode {

pkg/cmd/models/models.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ func getManifestInfoLine(repo string, desc ocispec.Descriptor, manifest *ocispec
111111
}
112112
sizeStr := formatBytes(size)
113113

114-
info := fmt.Sprintf(ModelsTableFmt, repo, ref, config.Package.Authors[0], config.Package.Name, sizeStr, desc.Digest)
114+
var author string
115+
if len(config.Kit.Authors) > 0 {
116+
author = config.Kit.Authors[0]
117+
} else {
118+
author = "<none>"
119+
}
120+
121+
info := fmt.Sprintf(ModelsTableFmt, repo, ref, author, config.Kit.Name, sizeStr, desc.Digest)
115122
return info
116123
}
117124

pkg/cmd/models/models_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func Manifest(configDigest string, layerDigests ...string) ocispec.Manifest {
224224

225225
func Config(maintainer, name string) artifact.JozuFile {
226226
config := artifact.JozuFile{
227-
Package: artifact.Package{Authors: []string{maintainer}, Name: name},
227+
Kit: artifact.ModelKit{Authors: []string{maintainer}, Name: name},
228228
}
229229

230230
return config

0 commit comments

Comments
 (0)