Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Dec 14, 2023
1 parent 0d5cb03 commit 1585d97
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
19 changes: 0 additions & 19 deletions ai_models/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

import json
import logging
import os
import pickle
Expand Down Expand Up @@ -50,24 +49,6 @@ def tidy(x):
return x


def checkpoint_metadata(path, name="ai-models.json"):
with zipfile.ZipFile(path, "r") as f:
metadata = None
for b in f.namelist():
if os.path.basename(b) == name:
if metadata is not None:
raise Exception(
f"Found two metadata.json files in {path}: {metadata} and {b}"
)
metadata = b

if metadata is not None:
with zipfile.ZipFile(path, "r") as f:
return json.load(f.open(metadata, "r"))

return None


def peek(path):
with zipfile.ZipFile(path, "r") as f:
data_pkl = None
Expand Down
5 changes: 1 addition & 4 deletions ai_models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from climetlab.utils.humanize import seconds
from multiurl import download

from .checkpoint import checkpoint_metadata, peek
from .checkpoint import peek
from .inputs import get_input
from .outputs import get_output
from .stepper import Stepper
Expand Down Expand Up @@ -396,9 +396,6 @@ def patch_retrieve_request(self, request):
def peek_into_checkpoint(self, path):
return peek(path)

def checkpoint_metadata(self, path):
return checkpoint_metadata(path)

def parse_model_args(self, args):
if args:
raise NotImplementedError(f"This model does not accept arguments {args}")
Expand Down

0 comments on commit 1585d97

Please sign in to comment.