-
Notifications
You must be signed in to change notification settings - Fork 863
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
Model archiver api #2751
Model archiver api #2751
Conversation
Very nice change, wanna create a new page something like |
Codecov Report
@@ Coverage Diff @@
## master #2751 +/- ##
==========================================
+ Coverage 72.44% 72.66% +0.22%
==========================================
Files 85 87 +2
Lines 3963 3995 +32
Branches 58 60 +2
==========================================
+ Hits 2871 2903 +32
Misses 1088 1088
Partials 4 4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
patches.export_utils.validate_inputs.assert_called() | ||
patches.export_utils.archive.assert_called() | ||
|
||
def test_export_model_method_tar(self, patches): | ||
self.args.update(archive_format="tar") | ||
self.config.archive_format = "tar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value "tar" doesn't align with the list of choices
originally accepted in the CLI https://github.com/pytorch/serve/blob/master/model-archiver/model_archiver/arg_parser.py#L102. Should we add "tar" to the literal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes let's add
convert=False, | ||
version=version, | ||
source_vocab=source_vocab, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neither convert
nor source_vocab
are unsed in model archiver. Not here anyway, could this break a behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep them for now, this might be breaking something we're not testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its okay to remove them. They are not part of the namespace created in argparse and only show up in this test. Presumably a relicts from before extra_files.
(serve) ubuntu@ip-172-31-55-226:~/serve$ grep -r convert model-archiver/
model-archiver/model_archiver/model_packaging_utils.py: logging.error("Failed to convert %s to the model-archive.", model_name)
Binary file model-archiver/model_archiver/tests/unit_tests/__pycache__/test_model_packaging.cpython-310-pytest-7.3.1.pyc matches
model-archiver/model_archiver/tests/unit_tests/test_model_packaging.py: convert=False,
model-archiver/build/lib/model_archiver/model_packaging_utils.py: logging.error("Failed to convert %s to the model-archive.", model_name)
(serve) ubuntu@ip-172-31-55-226:~/serve$ grep -r source_vocab model-archiver/
Binary file model-archiver/model_archiver/tests/integ_tests/__pycache__/test_integration_model_archiver.cpython-310-pytest-7.3.1.pyc matches
model-archiver/model_archiver/tests/integ_tests/test_integration_model_archiver.py: assert os.path.join(prefix, "source_vocab.pt") in file_list
model-archiver/model_archiver/tests/integ_tests/default_handler_configuration.json: "extra-files": "model_archiver/tests/integ_tests/resources/regular_model/test_index_to_name.json,model_archiver/tests/integ_tests/resources/regular_model/source_vocab.pt",
Binary file model-archiver/model_archiver/tests/unit_tests/__pycache__/test_model_packaging.cpython-310-pytest-7.3.1.pyc matches
model-archiver/model_archiver/tests/unit_tests/test_model_packaging.py: source_vocab = None
model-archiver/model_archiver/tests/unit_tests/test_model_packaging.py: source_vocab=source_vocab,
Just missing docs but nice to see CI green |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some minor comments. LGTM otherwise
@staticmethod | ||
def from_args(args: Namespace) -> "ModelArchiverConfig": | ||
config = ModelArchiverConfig( | ||
model_name=args.model_name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters and fields between args and config should always be aligned. Would be good to make the argument transfer automatic to remove one point that we need to touch in case we alter the parameters. Something like this:
from dataclasses import fields
# ...
@classmethod
def from_args(cls, args: Namespace) -> "ModelArchiverConfig":
params = {field.name: getattr(args, field.name) for field in fields(cls)}
config = cls(**params)
return config
) | ||
config = ModelArchiverConfig.from_args(args) | ||
|
||
config == self.config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to ass assert here so the test fails if unequal
convert=False, | ||
version=version, | ||
source_vocab=source_vocab, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its okay to remove them. They are not part of the namespace created in argparse and only show up in this test. Presumably a relicts from before extra_files.
(serve) ubuntu@ip-172-31-55-226:~/serve$ grep -r convert model-archiver/
model-archiver/model_archiver/model_packaging_utils.py: logging.error("Failed to convert %s to the model-archive.", model_name)
Binary file model-archiver/model_archiver/tests/unit_tests/__pycache__/test_model_packaging.cpython-310-pytest-7.3.1.pyc matches
model-archiver/model_archiver/tests/unit_tests/test_model_packaging.py: convert=False,
model-archiver/build/lib/model_archiver/model_packaging_utils.py: logging.error("Failed to convert %s to the model-archive.", model_name)
(serve) ubuntu@ip-172-31-55-226:~/serve$ grep -r source_vocab model-archiver/
Binary file model-archiver/model_archiver/tests/integ_tests/__pycache__/test_integration_model_archiver.cpython-310-pytest-7.3.1.pyc matches
model-archiver/model_archiver/tests/integ_tests/test_integration_model_archiver.py: assert os.path.join(prefix, "source_vocab.pt") in file_list
model-archiver/model_archiver/tests/integ_tests/default_handler_configuration.json: "extra-files": "model_archiver/tests/integ_tests/resources/regular_model/test_index_to_name.json,model_archiver/tests/integ_tests/resources/regular_model/source_vocab.pt",
Binary file model-archiver/model_archiver/tests/unit_tests/__pycache__/test_model_packaging.cpython-310-pytest-7.3.1.pyc matches
model-archiver/model_archiver/tests/unit_tests/test_model_packaging.py: source_vocab = None
model-archiver/model_archiver/tests/unit_tests/test_model_packaging.py: source_vocab=source_vocab,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quickly addressed the comments myself as I want to use this feature in master :-) ; thanks for contributing @Chichilele!
Happy this is useful. I’m on holiday with limited access to a laptop so wouldn’t have been able to address this until next week. |
No worries! Enjoy your holidays!
…On Fri, Nov 3, 2023 at 23:50 G ***@***.***> wrote:
Happy this is useful. I’m on holiday with limited access to a laptop so
wouldn’t have been able to address this until next week.
—
Reply to this email directly, view it on GitHub
<#2751 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADFYED747CBHQLZ54KHNATDYCXQTBAVCNFSM6AAAAAA6WZKBSKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTGM3DGMBZHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Description
Adds a model archiver interface to archive models programmatically with a config class
ModelArchiverConfig
and an archiver classModelArchiver
. Simply wraps the existing CLI feature.Fixes #2695
Type of change
Please delete options that are not relevant.
Feature/Issue validation/testing
As it's only wrapping the actual feature there's only a unit test very similar to the existing packaging test.
Checklist: