Args: fp (str): Path to save, eg. s3://opennlplab/model_weights/xxx/ddd.pt
(
handler,
bucket_name: str,
fp: str,
local_nvme_path: str, # pylint: disable=W0613
*args,
**kwargs,
)
| 205 | |
| 206 | @staticmethod |
| 207 | def load( |
| 208 | handler, |
| 209 | bucket_name: str, |
| 210 | fp: str, |
| 211 | local_nvme_path: str, # pylint: disable=W0613 |
| 212 | *args, |
| 213 | **kwargs, |
| 214 | ) -> Dict: |
| 215 | """ |
| 216 | Args: |
| 217 | fp (str): Path to save, eg. s3://opennlplab/model_weights/xxx/ddd.pt |
| 218 | """ |
| 219 | try: |
| 220 | with io.BytesIO() as f: |
| 221 | handler.client.download_fileobj(bucket_name, fp, f, Config=handler.config) |
| 222 | f.seek(0) |
| 223 | states = torch.load(f, *args, **kwargs) |
| 224 | except handler.botocore.exceptions.EndpointConnectionError as exc: |
| 225 | raise RuntimeError( |
| 226 | f"Boto3 Network Error: Please Check your Internet Connection in {socket.gethostname()}" |
| 227 | ) from exc |
| 228 | return states |
| 229 | |
| 230 | @staticmethod |
| 231 | def assert_fp_exists(handler, bucket_name: str, fp: str, local_nvme_path: str): # pylint: disable=W0613 |
no outgoing calls
no test coverage detected