in eland/ml/pytorch/_pytorch_model.py [0:0]
def put_model(self, model_path: str, chunk_size: int = DEFAULT_CHUNK_SIZE) -> None:
model_size = os.stat(model_path).st_size
total_parts = math.ceil(model_size / chunk_size)
def model_file_chunk_generator() -> Iterable[str]:
with open(model_path, "rb") as f:
while True:
data = f.read(chunk_size)
if not data:
break
yield base64.b64encode(data).decode()
for i, data in tqdm(
enumerate(model_file_chunk_generator()), unit=" parts", total=total_parts
):
self._client.ml.put_trained_model_definition_part(
model_id=self.model_id,
part=i,
total_definition_length=model_size,
total_parts=total_parts,
definition=data,
)