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

[djl-import] Includes requires version when importing model #3431

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def importer_args():
" repository. This option should only be set for repositories you trust and in which"
" you have read the code, as it will execute on your local machine arbitrary code"
" present in the model repository.")
parser.add_argument(
"--min-version",
help="Requires a specific version of DJL to load the model.")

args = parser.parse_args()
if args.output_dir is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import logging
import os
from argparse import Namespace
from typing import List
from typing import List, Optional

from huggingface_hub import HfApi
from huggingface_hub import hf_hub_download
Expand Down Expand Up @@ -150,7 +150,8 @@ def list_models(self, args: Namespace) -> List[dict]:
return ret

def update_progress(self, model_info: ModelInfo, application: str,
result: bool, reason: str, size: int, cpu_only: bool):
result: bool, reason: str, size: int, cpu_only: bool,
min_version: Optional[str]):
status = {
"result": "success" if result else "failed",
"application": application,
Expand All @@ -162,6 +163,8 @@ def update_progress(self, model_info: ModelInfo, application: str,
status["reason"] = reason
if cpu_only:
status["cpu_only"] = True
if result and min_version:
status["requires"] = min_version

self.processed_models[model_info.modelId] = status

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def main():
size = -1

huggingface_models.update_progress(model_info, converter.application,
result, reason, size, args.cpu_only)
result, reason, size, args.cpu_only,
args.min_version)
if os.path.exists(temp_dir):
shutil.rmtree(temp_dir)

Expand Down
Loading