Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround solution for archiver tgz format on SageMaker #2405

Merged
merged 3 commits into from
Jun 13, 2023

Conversation

lxning
Copy link
Collaborator

@lxning lxning commented Jun 10, 2023

Description

Please read our CONTRIBUTING.md prior to creating your first pull request.

Please include a summary of the feature or issue being fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Torchserve archiver add a root dir when it generates tgz archive format. For example.

torch-model-archiver --model-name mnist_scripted_v2 --version 2.0 --serialized-file mnist_script.pt --handler  mnist_handler.py --config-file model-config.yaml --archive-format tgz
=> mnist_scripted_v2.tar.gz

tar xvzf mnist_scripted_v2.tar.gz
=> mnist_scripted_v2

tree mnist_scripted_v2
mnist_scripted_v2
├── MAR-INF
│   └── MANIFEST.json
├── __pycache__
│   └── mnist_handler.cpython-38.pyc
├── mnist_handler.py
├── mnist_script.pt
└── model-config.yam

SageMaker put dir mnist_scripted_v2 under /opt/ml/model. So the dir structure is as following.

/opt/ml/model/mnist_scripted_v2
├── MAR-INF
│   └── MANIFEST.json
├── __pycache__
│   └── mnist_handler.cpython-38.pyc
├── mnist_handler.py
├── mnist_script.pt
└── model-config.yam

However, SageMaker starts torchserve using the following command. It cause the wrong model dir passed to torchserve.

torchserve --ncs --start --model-store model_store --models model

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Feature/Issue validation/testing

Please describe the Unit or Integration tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.

  • Test
torch-model-archiver --model-name mnist_scripted_v2 --version 2.0 --serialized-file mnist_script.pt --handler  mnist_handler.py --config-file model-config.yaml --archive-format tgz
=> mnist_scripted_v2.tar.gz

tar xvzf mnist_scripted_v2.tar.gz

mkdir -p model_store/model
mv mnist_scripted_v model_store/model/

 torchserve --ncs --start --model-store model_store --models model

curl "http://localhost:8081/models"
{
  "models": [
    {
      "modelName": "mnist_scripted_v2",
      "modelUrl": "mme_mnist"
    }
  ]
}

Checklist:

  • Did you have fun?
  • Have you added tests that prove your fix is effective or that this feature works?
  • Has code been commented, particularly in hard-to-understand areas?
  • Have you made corresponding changes to the documentation?

@lxning lxning added the enhancement New feature or request label Jun 10, 2023
@lxning lxning added this to the v0.8.1 milestone Jun 10, 2023
@lxning lxning self-assigned this Jun 10, 2023
@codecov
Copy link

codecov bot commented Jun 10, 2023

Codecov Report

Merging #2405 (e00bfe1) into master (253f8a3) will increase coverage by 0.08%.
The diff coverage is n/a.

❗ Current head e00bfe1 differs from pull request most recent head 027f66e. Consider uploading reports for the commit 027f66e to get more accurate results

@@            Coverage Diff             @@
##           master    #2405      +/-   ##
==========================================
+ Coverage   71.92%   72.01%   +0.08%     
==========================================
  Files          78       78              
  Lines        3648     3648              
  Branches       58       58              
==========================================
+ Hits         2624     2627       +3     
+ Misses       1020     1017       -3     
  Partials        4        4              

see 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@lxning lxning requested a review from mreso June 13, 2023 17:27
Copy link
Collaborator

@mreso mreso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@agunapal agunapal merged commit 3917407 into master Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants