Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/test-packager-inference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,22 @@ jobs:
--build-arg name=llama-3.2-1b-instruct \
--build-arg layer_packaging=raw \
--output type=local,dest=modelpack-out
test -f modelpack-out/layout/index.json
layout_root=modelpack-out
if [ ! -f "$layout_root/index.json" ] && [ -f modelpack-out/layout/index.json ]; then
layout_root=modelpack-out/layout
fi
test -f "$layout_root/index.json"
echo 'Modelpack layout:'
find modelpack-out -maxdepth 2 -type f | head -50

- name: Push modelpack to local registry
run: |
set -euo pipefail
skopeo copy --dest-tls-verify=false oci:modelpack-out/layout docker://localhost:5000/aikit/llama-3.2-1b-instruct:modelpack
layout_root=modelpack-out
if [ ! -f "$layout_root/index.json" ] && [ -f modelpack-out/layout/index.json ]; then
layout_root=modelpack-out/layout
fi
skopeo copy --dest-tls-verify=false oci:$layout_root docker://localhost:5000/aikit/llama-3.2-1b-instruct:modelpack
skopeo inspect --tls-verify=false --raw docker://localhost:5000/aikit/llama-3.2-1b-instruct:modelpack > pushed-manifest.json
sha=sha256:$(sha256sum pushed-manifest.json | awk '{print $1}')
echo "Pushed manifest digest: $sha"
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/test-packager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,15 @@ jobs:
run: |
set -euo pipefail
dest=out-${{ matrix.case.name }}
layout_root="$dest"
if [ ! -f "$layout_root/index.json" ] && [ -f "$dest/layout/index.json" ]; then
layout_root="$dest/layout"
fi
echo "Listing produced files (truncated)"
find "$dest" -maxdepth 3 -type f | head -100
# Check expected key files exist in local output (heuristic)
if [ '${{ matrix.case.output_mode }}' != 'files' ]; then
if [ ! -f "$dest/layout/index.json" ]; then echo "layout/index.json missing (expected for packaged layout)"; exit 1; fi
if [ ! -f "$layout_root/index.json" ]; then echo "index.json missing (expected for packaged layout)"; exit 1; fi
else
# files mode: ensure at least one non-empty file present
if ! find "$dest" -type f -maxdepth 2 | head -1 | grep -q . ; then
Expand All @@ -125,8 +129,11 @@ jobs:
run: |
set -euo pipefail
dest=out-${{ matrix.case.name }}
layout_root="$dest/layout"
if [ ! -f "$layout_root/index.json" ]; then echo "layout/index.json missing; cannot treat local output as OCI layout"; ls -R "$dest" | head -200; exit 1; fi
layout_root="$dest"
if [ ! -f "$layout_root/index.json" ] && [ -f "$dest/layout/index.json" ]; then
layout_root="$dest/layout"
fi
if [ ! -f "$layout_root/index.json" ]; then echo "index.json missing; cannot treat local output as OCI layout"; ls -R "$dest" | head -200; exit 1; fi
if [ ! -f "$layout_root/oci-layout" ]; then
echo '{"imageLayoutVersion":"1.0.0"}' > "$layout_root/oci-layout"
fi
Expand All @@ -140,7 +147,11 @@ jobs:
run: |
set -euo pipefail
dest=out-${{ matrix.case.name }}
localDigest=$(jq -r '.manifests[0].digest' "$dest/layout/index.json")
layout_root="$dest"
if [ ! -f "$layout_root/index.json" ] && [ -f "$dest/layout/index.json" ]; then
layout_root="$dest/layout"
fi
localDigest=$(jq -r '.manifests[0].digest' "$layout_root/index.json")
# Fetch raw manifest (artifact) and compute digest manually (inspect --format is image-specific and fails on artifactType)
skopeo inspect --tls-verify=false --raw docker://localhost:5000/aikit/${{ matrix.case.name }}:test > remote-manifest.json
remoteDigest=sha256:$(sha256sum remote-manifest.json | awk '{print $1}')
Expand Down
22 changes: 18 additions & 4 deletions pkg/packager/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,16 @@ func BuildModelpack(ctx context.Context, c client.Client) (*client.Result, error
llb.Args([]string{"bash", "-c", script}),
llb.AddMount("/src", modelState, llb.Readonly),
)
final := llb.Scratch().File(llb.Copy(run.Root(), "/layout/", "/"))
final := llb.Scratch().File(llb.Copy(run.Root(), "/layout", "/", &llb.CopyInfo{
CopyDirContentsOnly: true,
}))

return solveAndBuildResult(ctx, c, final, "packager:modelpack")
result, err := solveAndBuildResult(ctx, c, final, "packager:modelpack")
if err != nil {
return nil, err
}
result.AddMeta("containerimage.oci-layout", []byte("true"))
return result, nil
}

// BuildGeneric builds a generic artifact layout (target packager/generic).
Expand Down Expand Up @@ -151,9 +158,16 @@ func BuildGeneric(ctx context.Context, c client.Client) (*client.Result, error)
llb.Args([]string{"bash", "-c", script}),
llb.AddMount("/src", srcState, llb.Readonly),
)
final := llb.Scratch().File(llb.Copy(run.Root(), "/layout/", "/"))
final := llb.Scratch().File(llb.Copy(run.Root(), "/layout", "/", &llb.CopyInfo{
CopyDirContentsOnly: true,
}))

return solveAndBuildResult(ctx, c, final, "packager:generic")
result, err := solveAndBuildResult(ctx, c, final, "packager:generic")
if err != nil {
return nil, err
}
result.AddMeta("containerimage.oci-layout", []byte("true"))
return result, nil
}

func getBuildArg(opts map[string]string, k string) string {
Expand Down
Loading