31 lines
687 B
Python
31 lines
687 B
Python
"""Definition of get_model function."""
|
|
|
|
import logging
|
|
from collections import OrderedDict
|
|
|
|
import torch
|
|
from minio import Minio
|
|
|
|
from .get import get
|
|
|
|
|
|
def get_model(
|
|
client: Minio,
|
|
object_name: str,
|
|
) -> OrderedDict:
|
|
"""Get model from model subfolder in bucket in Minio."""
|
|
assert isinstance(client, Minio)
|
|
assert isinstance(object_name, str)
|
|
subfolder = 'models'
|
|
object_name = f'{subfolder}/{object_name}'
|
|
# get buffer
|
|
buffer = get(
|
|
client=client,
|
|
object_name=object_name,
|
|
)
|
|
# convert data to model checkpoint
|
|
buffer.seek(0)
|
|
model_content = torch.load(buffer)
|
|
logging.debug('finished')
|
|
return model_content
|