|
13 | 13 | """Placeholder docstring"""
|
14 | 14 | from __future__ import absolute_import
|
15 | 15 |
|
| 16 | +import abc |
16 | 17 | import contextlib
|
17 | 18 | import copy
|
18 | 19 | import errno
|
19 | 20 | import inspect
|
| 21 | +import json |
20 | 22 | import logging
|
21 | 23 | import os
|
22 | 24 | import random
|
|
25 | 27 | import tarfile
|
26 | 28 | import tempfile
|
27 | 29 | import time
|
28 |
| -from functools import lru_cache |
29 |
| -from typing import Union, Any, List, Optional, Dict |
30 |
| -import json |
31 |
| -import abc |
32 | 30 | import uuid
|
33 | 31 | from datetime import datetime
|
34 |
| -from os.path import abspath, realpath, dirname, normpath, join as joinpath |
35 |
| - |
| 32 | +from functools import lru_cache |
36 | 33 | from importlib import import_module
|
| 34 | +from os.path import abspath, dirname |
| 35 | +from os.path import join as joinpath |
| 36 | +from os.path import normpath, realpath |
| 37 | +from typing import Any, Dict, List, Optional, Union |
37 | 38 |
|
38 | 39 | import boto3
|
39 | 40 | import botocore
|
40 | 41 | from botocore.utils import merge_dicts
|
41 |
| -from six.moves.urllib import parse |
42 | 42 | from six import viewitems
|
| 43 | +from six.moves.urllib import parse |
43 | 44 |
|
44 | 45 | from sagemaker import deprecations
|
45 | 46 | from sagemaker.config import validate_sagemaker_config
|
46 | 47 | from sagemaker.config.config_utils import (
|
47 |
| - _log_sagemaker_config_single_substitution, |
48 | 48 | _log_sagemaker_config_merge,
|
| 49 | + _log_sagemaker_config_single_substitution, |
49 | 50 | )
|
50 | 51 | from sagemaker.enums import RoutingStrategy
|
51 | 52 | from sagemaker.session_settings import SessionSettings
|
52 |
| -from sagemaker.workflow import is_pipeline_variable, is_pipeline_parameter_string |
| 53 | +from sagemaker.workflow import is_pipeline_parameter_string, is_pipeline_variable |
53 | 54 | from sagemaker.workflow.entities import PipelineVariable
|
54 | 55 |
|
55 | 56 | ALTERNATE_DOMAINS = {
|
@@ -624,7 +625,24 @@ def _create_or_update_code_dir(
|
624 | 625 | if os.path.exists(os.path.join(code_dir, inference_script)):
|
625 | 626 | pass
|
626 | 627 | else:
|
627 |
| - raise |
| 628 | + raise FileNotFoundError( |
| 629 | + f"Could not find '{inference_script}'. Common solutions:\n" |
| 630 | + "1. Make sure inference.py exists in the code/ directory\n" |
| 631 | + "2. Package your model correctly:\n" |
| 632 | + " - ✅ DO: Navigate to the directory containing model files and run:\n" |
| 633 | + " cd /path/to/model_files\n" |
| 634 | + " tar czvf ../model.tar.gz *\n" |
| 635 | + " - ❌ DON'T: Create from parent directory:\n" |
| 636 | + " tar czvf model.tar.gz model/\n" |
| 637 | + "\nExpected structure in model.tar.gz:\n" |
| 638 | + " ├── model.pth (or your model file)\n" |
| 639 | + " └── code/\n" |
| 640 | + " ├── inference.py\n" |
| 641 | + " └── requirements.txt\n" |
| 642 | + "\nFor more details, see the documentation:\n" |
| 643 | + + "https://sagemaker.readthedocs.io/en/stable/" |
| 644 | + + "frameworks/pytorch/using_pytorch.html#bring-your-own-model" |
| 645 | + ) |
628 | 646 |
|
629 | 647 | for dependency in dependencies:
|
630 | 648 | lib_dir = os.path.join(code_dir, "lib")
|
|
0 commit comments