Skip to content

Commit ac1f654

Browse files
committed
Migrate serialize_v0 to new API.
This is the middle layer of the API design work (sigstore#172). We add a manifest abstract class to represent various manifests (sigstore#111 sigstore#112) and also ways to serialize a model directory into manifests and ways to verify the manifests. For now, this only does what was formerly known as `serialize_v0`. The v1 and the manifest versions will come soon. Note: This has a lot of inspiration from sigstore#112, but makes the API work with all the usecases we need to consider right now. Signed-off-by: Mihai Maruseac <[email protected]>
1 parent 220d5c7 commit ac1f654

File tree

8 files changed

+484
-1210
lines changed

8 files changed

+484
-1210
lines changed

model_signing/manifest/__init__.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2024 The Sigstore Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.

model_signing/manifest/manifest.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2024 The Sigstore Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Machinery for representing a serialized representation of an ML model.
16+
17+
Currently, we only support a manifest that wraps around a digest. But, to
18+
support incremental updates and partial signature verification, we need a
19+
manifest that lists files and their digests. That will come in a future change,
20+
soon.
21+
"""
22+
23+
from abc import ABCMeta
24+
from dataclasses import dataclass
25+
26+
from model_signing.hashing import hashing
27+
28+
29+
class Manifest(metaclass=ABCMeta):
30+
"""Generic manifest file to represent a model."""
31+
32+
pass
33+
34+
35+
@dataclass
36+
class DigestManifest(Manifest):
37+
"""A manifest that is just a hash."""
38+
39+
digest: hashing.Digest

0 commit comments

Comments
 (0)