From bb6a8ab5488418ab9cdc0780c1c9f81ab0e98c3a Mon Sep 17 00:00:00 2001 From: Sync-Packages Action Date: Fri, 19 Jul 2024 05:01:43 +0000 Subject: [PATCH] Sync: devchat[main](a84dfe79) Merge pull request #409 from devchat-ai/improve-err-msg --- site-packages/devchat-0.3.0.dist-info/RECORD | 4 ++-- site-packages/devchat/utils.py | 10 ++++++++++ site-packages/devchat/workflow/env_manager.py | 17 +++++++++-------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/site-packages/devchat-0.3.0.dist-info/RECORD b/site-packages/devchat-0.3.0.dist-info/RECORD index 2738331..a53ce7d 100644 --- a/site-packages/devchat-0.3.0.dist-info/RECORD +++ b/site-packages/devchat-0.3.0.dist-info/RECORD @@ -162,7 +162,7 @@ devchat/path.py,sha256=I_rASGjunCNBj6NxDd9j1APqc-COsRk8-HX9I6CEF8k,182 devchat/prompt.py,sha256=ZMdyRE4WIidg46_S3-VwpZ6D52bVYpP5ANhzvSJyY8c,9492 devchat/store.py,sha256=-KHp0N9F0t2VjAVXcANJa6tusNZQnd8d5vY4tuPzIFA,11954 devchat/tiktoken_cache/9b5ad71b2ce5302211f9c61530b329a4922fc6a4,sha256=Ijkht27pm96ZW3_3OFE-7xAPtR0YyTWXoRO8_-hlsqc,1681126 -devchat/utils.py,sha256=GdI7DovvEzeG6oKnn8R-siGeW0myfQ76X1tDAhEKELQ,7650 +devchat/utils.py,sha256=ScQwBeWrxVcjP-5VbL7UGMKb7VV4KmyN39nhxNpCyxA,7914 devchat/workflow/README.md,sha256=a48aJE5X8vjgasI9lhJljlUjwLvn7vO7tlG0PFM67m0,201 devchat/workflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 devchat/workflow/__pycache__/__init__.cpython-38.pyc,, @@ -189,7 +189,7 @@ devchat/workflow/command/env.py,sha256=wXZc497GwSjWk8T37krTkxqyjUhWSAh0c0RCwmLzR devchat/workflow/command/list.py,sha256=MYX469XXazUzNkahXuTlIJYIf_r_t1RwGrKEfugY8HY,1228 devchat/workflow/command/run.py,sha256=tSdDeVNBtNt7xwn6Q3hgjsMZUbL0NPt2g3-fsVAUg9A,214 devchat/workflow/command/update.py,sha256=7hmqqtJHpKZ2I03zQtT-aGvw63L5V0Lsmi-qe8ThjL4,761 -devchat/workflow/env_manager.py,sha256=F2xBVXZ6CXe98nlD21rluoFDRcOe8Iak5aTB2b5f1h4,8361 +devchat/workflow/env_manager.py,sha256=h5hPUfGrlG-8KMkfpVAuD_fvkS_myLi5s7jPf_uOyfs,8474 devchat/workflow/envs.py,sha256=-lVTLjWRMrb8RGVVlHgWKCiGZaojNdmycjHFT0ZKjEo,298 devchat/workflow/namespace.py,sha256=CaotAAcSwGINH871zXcs2frBlzuf-eZ2DMEIx_8uRUo,3880 devchat/workflow/path.py,sha256=VOZbxZxUFYAgiD-FgXsLkSrKq4g_xyb0KLBIGuyvE8Y,1355 diff --git a/site-packages/devchat/utils.py b/site-packages/devchat/utils.py index 2c179bf..f0ed1be 100644 --- a/site-packages/devchat/utils.py +++ b/site-packages/devchat/utils.py @@ -22,6 +22,16 @@ def setup_logger(file_path: Optional[str] = None): logging.root.handlers = [handler] +def get_logging_file() -> Optional[str]: + """ + Get the file path of the global file log handler. + """ + for handler in logging.root.handlers: + if isinstance(handler, logging.FileHandler): + return handler.baseFilename + return None + + def get_logger(name: str = None, handler: logging.Handler = None) -> logging.Logger: local_logger = logging.getLogger(name) diff --git a/site-packages/devchat/workflow/env_manager.py b/site-packages/devchat/workflow/env_manager.py index 41728bb..13a81aa 100644 --- a/site-packages/devchat/workflow/env_manager.py +++ b/site-packages/devchat/workflow/env_manager.py @@ -4,7 +4,7 @@ import subprocess import sys from typing import Dict, Optional, Tuple -from devchat.utils import get_logger +from devchat.utils import get_logger, get_logging_file from .envs import MAMBA_BIN_PATH from .path import ENV_CACHE_DIR, MAMBA_PY_ENVS, MAMBA_ROOT @@ -94,6 +94,7 @@ class PyEnvManager: if not should_remove_old: return py + log_file = get_logging_file() print("\n```Step\n# Setting up workflow environment\n", flush=True) if should_remove_old: print(f"- Dependencies of {env_name} have been changed.", flush=True) @@ -104,11 +105,11 @@ class PyEnvManager: print(f"- Creating {env_name} with {py_version}...", flush=True) create_ok, msg = self.create(env_name, py_version) if not create_ok: - print(f"- Failed to create {env_name}", flush=True) + print(f"- Failed to create {env_name}.", flush=True) + print(f"\nFor more details, check {log_file}.", flush=True) print("\n```", flush=True) print( - f"\n\nFailed to create {env_name}, the workflow will not run." - f"\n\nPlease try again later.", + f"\n\nFailed to create {env_name}, the workflow will not run.", flush=True, ) logger.warning(f"Failed to create {env_name}: {msg}") @@ -121,11 +122,11 @@ class PyEnvManager: print(f"- Installing dependencies from {filename}...", flush=True) install_ok, msg = self.install(env_name, reqirements_file) if not install_ok: - print(f"- Failed to install dependencies from {filename}", flush=True) + print(f"- Failed to install dependencies from {filename}.", flush=True) + print(f"\nFor more details, check {log_file}.", flush=True) print("\n```", flush=True) print( - "\n\nFailed to install dependencies, the workflow will not run." - "\n\nPlease try again later.", + "\n\nFailed to install dependencies, the workflow will not run.", flush=True, ) logger.warning(f"Failed to install dependencies: {msg}") @@ -198,7 +199,7 @@ class PyEnvManager: """ is_exist = os.path.exists(os.path.join(MAMBA_PY_ENVS, env_name)) if is_exist: - return True + return True, "" # create the environment cmd = [