aws / aws/sagemaker-scikit-learn-container

Container unable to find inference.py

Open
#77 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
188
Forks
121
PR merge metrics
No merged PRs in 30d

Description

Below is my file structure:
```
name_of_model
-->model
--> code
--> __init__.py
--> inference.py
-->requirements.txt
-->utils.py (imported by inference.py
-->data
--> __init__.py
-->scikit_learn_classifier.pkl (loaded by inference.py)
-->model_endpoint.py
```

I tar the model directory and upload to S3, and i checked that it is there.
Below is my deploy script, which I used:
```
from sagemaker.sklearn.model import SKLearnModel
...
def deploy(
s3_model_tar_path,
endpoint_name_prefix="model-endpoint",
instance_type="ml.t2.medium"
):
endpoint_name = f"{endpoint_name_prefix}-{int(time.time())}"
git_config = f"{endpoint_name_prefix}-{int(time.time())}"
model = SKLearnModel(
model_data=s3_model_tar_path,
py_version="py3",
framework_version="0.20.0",
role="AmazonSageMakerAndS3-FullAccess",
entry_point="inference.py"
)
predictor = model.deploy(
instance_type=instance_type,
initial_instance_count=1,
endpoint_name=endpoint_name
)
```

I have tried both specifying a source_dir and not specifying a source_dir. **Note:** I have tried a flat directory structure for model where inference.py is in the root. I have tried inserting /opt/ml/code in inference.py(as recommended https://github.com/aws/sagemaker-python-sdk/issues/648)

I believe there is something wrong with the scikit learn container as I always see the error: FileNotFoundError: [Errno 2] No such file or directory: 'inference.py'

When I specify source_dir I see that it gets an ImportError can't find inference.py. I think the scikit container has a problem finding the inference.py

![image](https://user-images.githubusercontent.com/5139539/114096060-13749300-9873-11eb-9671-7af11f337a41.png)

Contributor guide

Open the contributing guide

Research direction

Start with the deploy function and the model package layout described in model_endpoint.py, checking how inference.py is placed in the tar archive and where source_dir puts it. Reproduce the deployment with both the flat and nested layouts, then verify that the container can load inference.py without FileNotFoundError or ImportError.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, docker, python, scikit-learn
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.