Skip to content

Commit

Permalink
feat(core): Read and save system information to tracer (#670)
Browse files Browse the repository at this point in the history
**Others**
- Fix the problem of repeated startup of start ModelWorker in cluster
deploying.
- Docker image use `Asia/Shanghai` as timezone when LANGUAGE is "zh"
  • Loading branch information
Aries-ckt authored Oct 13, 2023
2 parents a9241e1 + 16542bf commit f1bb53f
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
models/
plugins/
pilot/data
pilot/message
logs/
12 changes: 6 additions & 6 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG BASE_IMAGE="nvidia/cuda:11.8.0-runtime-ubuntu22.04"
FROM ${BASE_IMAGE}
ARG BASE_IMAGE

RUN apt-get update && apt-get install -y git python3 pip wget sqlite3 \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y git python3 pip wget sqlite3 tzdata \
&& apt-get clean

ARG BUILD_LOCAL_CODE="false"
Expand Down Expand Up @@ -44,11 +44,6 @@ ARG BUILD_LOCAL_CODE="false"
# COPY the rest of the app
COPY . /app

# TODO:Need to find a better way to determine whether to build docker image with local code.
RUN (if [ "${BUILD_LOCAL_CODE}" = "true" ]; \
then rm -rf /app/logs && rm -rf /app/pilot/data && rm -rf /app/pilot/message; \
fi;)

ARG LOAD_EXAMPLES="true"

RUN (if [ "${LOAD_EXAMPLES}" = "true" ]; \
Expand All @@ -57,6 +52,11 @@ RUN (if [ "${LOAD_EXAMPLES}" = "true" ]; \
&& sqlite3 /app/pilot/data/default_sqlite.db < /app/docker/examples/sqls/test_case_info_sqlite.sql; \
fi;)

RUN (if [ "${LANGUAGE}" = "zh" ]; \
then ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone; \
fi;)

ENV PYTHONPATH "/app:$PYTHONPATH"
EXPOSE 5000

Expand Down
2 changes: 2 additions & 0 deletions pilot/model/cluster/embedding/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pilot.model.parameter import BaseEmbeddingModelParameters
from pilot.utils.parameter_utils import _get_dict_from_obj
from pilot.utils.tracer import root_tracer, SpanType, SpanTypeRunName
from pilot.utils.system_utils import get_system_info

if TYPE_CHECKING:
from langchain.embeddings.base import Embeddings
Expand All @@ -21,6 +22,7 @@ def load(
"model_name": model_name,
"run_service": SpanTypeRunName.EMBEDDING_MODEL.value,
"params": _get_dict_from_obj(param),
"sys_infos": _get_dict_from_obj(get_system_info()),
}
with root_tracer.start_span(
"EmbeddingLoader.load", span_type=SpanType.RUN, metadata=metadata
Expand Down
2 changes: 2 additions & 0 deletions pilot/model/cluster/worker/default_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pilot.utils.model_utils import _clear_model_cache
from pilot.utils.parameter_utils import EnvArgumentParser, _get_dict_from_obj
from pilot.utils.tracer import root_tracer, SpanType, SpanTypeRunName
from pilot.utils.system_utils import get_system_info

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -102,6 +103,7 @@ def start(
"llm_adapter": str(self.llm_adapter),
"run_service": SpanTypeRunName.MODEL_WORKER,
"params": _get_dict_from_obj(model_params),
"sys_infos": _get_dict_from_obj(get_system_info()),
}
with root_tracer.start_span(
"DefaultModelWorker.start", span_type=SpanType.RUN, metadata=metadata
Expand Down
9 changes: 7 additions & 2 deletions pilot/model/cluster/worker/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
)
from pilot.utils.utils import setup_logging
from pilot.utils.tracer import initialize_tracer, root_tracer, SpanType, SpanTypeRunName
from pilot.utils.system_utils import get_system_info

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -838,6 +839,7 @@ def _start_local_worker(
metadata={
"run_service": SpanTypeRunName.WORKER_MANAGER,
"params": _get_dict_from_obj(worker_params),
"sys_infos": _get_dict_from_obj(get_system_info()),
},
):
worker = _build_worker(worker_params)
Expand Down Expand Up @@ -974,6 +976,7 @@ def run_worker_manager(
os.path.join(LOGDIR, "dbgpt_model_worker_manager_tracer.jsonl"),
root_operation_name="DB-GPT-WorkerManager-Entry",
)

_start_local_worker(worker_manager, worker_params)
_start_local_embedding_worker(
worker_manager, embedding_model_name, embedding_model_path
Expand All @@ -985,11 +988,13 @@ def run_worker_manager(
if not embedded_mod:
import uvicorn

loop = asyncio.get_event_loop()
loop.run_until_complete(worker_manager.start())
uvicorn.run(
app, host=worker_params.host, port=worker_params.port, log_level="info"
)
else:
# Embedded mod, start worker manager
loop = asyncio.get_event_loop()
loop.run_until_complete(worker_manager.start())


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion pilot/server/dbgpt_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(ROOT_PATH)
import signal
from pilot.configs.config import Config
from pilot.configs.model_config import LLM_MODEL_CONFIG, EMBEDDING_MODEL_CONFIG, LOGDIR
from pilot.component import SystemApp
Expand Down Expand Up @@ -40,6 +39,7 @@
)
from pilot.utils.tracer import root_tracer, initialize_tracer, SpanType, SpanTypeRunName
from pilot.utils.parameter_utils import _get_dict_from_obj
from pilot.utils.system_utils import get_system_info

static_file_path = os.path.join(os.getcwd(), "server/static")

Expand Down Expand Up @@ -190,6 +190,7 @@ def run_webserver(param: WebWerverParameters = None):
metadata={
"run_service": SpanTypeRunName.WEBSERVER,
"params": _get_dict_from_obj(param),
"sys_infos": _get_dict_from_obj(get_system_info()),
},
):
param = initialize_app(param)
Expand Down
Loading

0 comments on commit f1bb53f

Please sign in to comment.