diff --git a/.github/workflows/test-packager-inference.yaml b/.github/workflows/test-packager-inference.yaml index c4281a31..b5a6393b 100644 --- a/.github/workflows/test-packager-inference.yaml +++ b/.github/workflows/test-packager-inference.yaml @@ -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" diff --git a/.github/workflows/test-packager.yaml b/.github/workflows/test-packager.yaml index 76e87b1e..30db5a6f 100644 --- a/.github/workflows/test-packager.yaml +++ b/.github/workflows/test-packager.yaml @@ -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 @@ -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 @@ -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}') diff --git a/pkg/packager/build.go b/pkg/packager/build.go index ba7c2a6b..55876be1 100644 --- a/pkg/packager/build.go +++ b/pkg/packager/build.go @@ -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). @@ -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 {