Registry / ai-ml / model-archiver

model-archiver

JSON →
library1.0.3pypypiunverified

Model Archiver is a Python library and command-line tool used for creating archives of trained neural network models. These archives, typically with a .mar extension, are specifically structured to be consumed by the MXNet-Model-Server for efficient inference. The PyPI package (version 1.0.3) serves as a standalone tool, although its core functionality has largely evolved into 'torch-model-archiver' for the 'TorchServe' (formerly 'Multi-Model-Server') ecosystem.

pip install model-archiver
INSTALL
IMPORT
SIG · MODEL-ARCHIVER
M
model-archiver
ai-mlpythonv1.0.3
Install
1.9s avg
Import
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.9s · import 0.000s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ModelArchiver
from model_archiver import ModelArchiver
from model_archiver import ModelArchiver

Create a model archive (.mar file) for an MXNet model. This command packages your model artifacts, a custom handler script (`my_handler.py`), and any extra files (like `requirements.txt` or configuration files) into a single archive. The generated .mar file is then placed in the specified `export-path`. Ensure your handler script correctly implements the `initialize`, `preprocess`, `inference`, and `postprocess` methods for your specific model.

model-archiver --model-name my_mxnet_model \ --version 1.0 \ --model-path ./path_to_model_artifacts/ \ --handler my_handler.py \ --extra-files requirements.txt,config.json \ --export-path ./model_store/ # Example `my_handler.py` (simplified structure): # class MXNetHandler: # def __init__(self): # self.model = None # def initialize(self, context): # properties = context.system_properties # model_dir = properties.get("model_dir") # # Load model, e.g., using MXNet's gluon.nn # # self.model = gluon.nn.load_param(os.path.join(model_dir, 'model_params.params')) # def preprocess(self, data): # # Preprocess input data # return data # def inference(self, data): # # Perform inference using self.model # return self.model(data) # def postprocess(self, data): # # Postprocess inference results # return data
model-archiver --version
Debug
Known issues
breakingThe `model-archiver` PyPI package (version 1.0.3) is primarily designed for the legacy MXNet-Model-Server. For modern deep learning model serving, particularly with PyTorch, the actively maintained and recommended tool is `torch-model-archiver`, which is part of the `TorchServe` ecosystem (evolved from Multi-Model-Server).
fix
For new projects or PyTorch models, consider using `pip install torch-model-archiver` and the associated `torch-model-archiver` CLI. This provides access to the latest features, bug fixes, and active community support.
affects: <=1.0.3
gotchaThe `model-archiver` is predominantly a command-line interface tool. While it exposes Python modules, its intended usage for creating model archives is through its CLI. Programmatic invocation of its internal functions is less common and may have limited dedicated documentation.
fix
For packaging models, rely on the `model-archiver` command-line tool. If programmatic integration is essential, consult the source code on GitHub for direct API usage patterns, focusing on the `model_archiver.mar` module.
affects: <=1.0.3
gotchaWhen packaging ONNX models, additional dependencies (`protobuf` compiler, `onnx`, `mxnet`) are not installed by default with `model-archiver`. Without these, ONNX model packaging will fail.
fix
Before archiving ONNX models, manually install the required libraries: `pip install protobuf onnx mxnet` (or the specific MXNet variant like `mxnet-cu101`). Ensure a protobuf compiler is also available in your environment.
affects: <=1.0.3
gotchaHandling complex model project structures (e.g., multiple interdependent Python files in subdirectories) within the handler can lead to import errors. The archiving process might flatten directory structures, causing Python's import mechanism to fail.
fix
For complex dependencies, either package them as a Python egg/wheel and include it via `--extra-files`, or adjust your handler to manually manage the Python path or use relative imports carefully. Alternatively, provide a `requirements.txt` with your `model-archiver` command for dependencies available on PyPI.
affects: <=1.0.3
Upgrade
Version history
1.0.3latest on PyPI · released May 16, 2019
Audit
Dependencies
numpyrequiredFundamental package for scientific computing.
PillowrequiredImage processing capabilities, common in vision models.
pyyamlrequiredUsed for configuration file parsing.
boto3optionalAWS SDK for Python, often used for S3 integration (optional).
protobufrequiredUsed for data serialization, especially with ONNX models.
requestsrequiredHTTP client for various internal communications.
grpciorequiredgRPC Python utilities for communication with model servers.
grpcio-toolsrequiredTools for gRPC, often used in conjunction with grpcio.
Agent activity
20 hits · last 30 days
node
18
Resources
model-archiver — pip install model-archiver · libregistry