updated classes
This commit is contained in:
@@ -1,14 +1,31 @@
|
|||||||
"""Definition of get_model function."""
|
"""Definition of get_model function."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
import torch
|
||||||
from minio import Minio
|
from minio import Minio
|
||||||
from torch.nn import Module
|
|
||||||
|
from .get import get
|
||||||
|
|
||||||
|
|
||||||
def get_model(
|
def get_model(
|
||||||
client: Minio,
|
client: Minio,
|
||||||
object_name: str,
|
object_name: str,
|
||||||
) -> Module:
|
) -> OrderedDict:
|
||||||
"""Get model from model subfolder in bucket in Minio."""
|
"""Get model from model subfolder in bucket in Minio."""
|
||||||
assert isinstance(client, Minio)
|
assert isinstance(client, Minio)
|
||||||
assert isinstance(object_name, str)
|
assert isinstance(object_name, str)
|
||||||
raise NotImplementedError()
|
subfolder = 'models'
|
||||||
|
object_name = f'{subfolder}/{object_name}'
|
||||||
|
# get buffer
|
||||||
|
buffer = get(
|
||||||
|
client=client,
|
||||||
|
object_name=object_name,
|
||||||
|
)
|
||||||
|
logging.debug('buffer size: %s', buffer.getbuffer().nbytes)
|
||||||
|
# convert data to model checkpoint
|
||||||
|
buffer.seek(0)
|
||||||
|
model_content = torch.load(buffer)
|
||||||
|
logging.debug('finished')
|
||||||
|
return model_content
|
||||||
|
|||||||
Reference in New Issue
Block a user