Skip to content

Commit

Permalink
Merge pull request #124 from kerthcet/cleanup/add-log
Browse files Browse the repository at this point in the history
Add verbose log to modelLoader
  • Loading branch information
InftyAI-Agent authored Sep 4, 2024
2 parents 26229b7 + 1accdcd commit 24ee839
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 13 deletions.
10 changes: 2 additions & 8 deletions llmaz/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@
"""

import os
import logging
from datetime import datetime

from llmaz.model_loader.objstore.objstore import model_download
from llmaz.model_loader.model_hub.hub_factory import HubFactory
from llmaz.model_loader.model_hub.huggingface import HUGGING_FACE

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
logger = logging.getLogger(__name__)
from llmaz.util.logger import Logger


if __name__ == "__main__":
Expand Down Expand Up @@ -54,6 +48,6 @@
else:
raise EnvironmentError(f"unknown model source type {model_source_type}")

logger.info(
Logger.info(
f"loading models from {model_source_type} takes {datetime.now() - start_time}s"
)
7 changes: 5 additions & 2 deletions llmaz/model_loader/model_hub/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
MAX_WORKERS,
ModelHub,
)
from llmaz.util.logger import Logger

from typing import Optional

Expand All @@ -38,7 +39,9 @@ def name(cls) -> str:
def load_model(
cls, model_id: str, filename: Optional[str], revision: Optional[str]
) -> None:
print(f"Start to download model {model_id}")
Logger.info(
f"Start to download, model_id: {model_id}, filename: {filename}, revision: {revision}"
)

if filename:
hf_hub_download(
Expand Down Expand Up @@ -71,4 +74,4 @@ def load_model(

def handle_completion(future):
filename = future.result()
print(f"Download completed for {filename}")
Logger.info(f"Download completed for {filename}")
7 changes: 5 additions & 2 deletions llmaz/model_loader/model_hub/modelscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
MODEL_SCOPE,
ModelHub,
)
from llmaz.util.logger import Logger


class ModelScope(ModelHub):
Expand All @@ -38,7 +39,9 @@ def name(cls) -> str:
def load_model(
cls, model_id: str, filename: Optional[str], revision: Optional[str]
) -> None:
print(f"Start to download model {model_id}")
Logger.info(
f"Start to download, model_id: {model_id}, filename: {filename}, revision: {revision}"
)

with concurrent.futures.ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
futures = []
Expand All @@ -57,4 +60,4 @@ def load_model(

def handle_completion(future):
filename = future.result()
print(f"Download completed for {filename}")
Logger.info(f"Download completed for {filename}")
Empty file added llmaz/util/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions llmaz/util/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import logging

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
Logger = logging.getLogger("llmaz")
2 changes: 1 addition & 1 deletion pkg/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ limitations under the License.
package pkg

const (
LOADER_IMAGE = "inftyai/model-loader:v0.0.6"
LOADER_IMAGE = "inftyai/model-loader:v0.0.7"
)

0 comments on commit 24ee839

Please sign in to comment.