From 80d4f32c8fc92dc275f51b5360cca5e96a9db404 Mon Sep 17 00:00:00 2001 From: Linlang <30293408+SunsetWolf@users.noreply.github.com> Date: Sat, 7 Sep 2024 12:37:08 +0800 Subject: [PATCH] feat: add collect info (#233) * add collect info * fix isort error * optimize code * fix black error * Update rdagent/app/cli.py * Modify the code according to the comments * fix isort error * add docker info * docs: update contributors (#230) * fix: package dependency. (#234) * fix package * fix lint * docs: Update development.rst (#235) * feat: add cross validation for kaggle scenario (#236) * update cross validation for kaggle scenario * CI Issues * delete useless file * CI issues * docs: Update README.md (#245) * docs: refine the README (#244) * init a scenario for kaggle feature engineering * update the readme * Delete rdagent/app/kaggle_feature/conf.py * update some pictures * Delete rdagent/app/kaggle_feature/model.py * change a photo * add pics to docs * update the readme * update the README * for a try * for another try * change the style of the pictures in readme * fix a small bug * update the readme and the docs * update the docs * fix a typo * change a website url * change some styles * fix a typo * change the size of the logo * change two urls * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: Linlang * move the component to other files * last container * optimize rdagent info * format with isort * format with black * format_with_black * fix pip error * format with isort * change requirements * fix pip error * fix_pip_error * fix pip error * format with black * fix pip error --------- Co-authored-by: you-n-g Co-authored-by: Haotian Chen <113661982+Hytn@users.noreply.github.com> Co-authored-by: Haoran Pan <167847254+TPLin22@users.noreply.github.com> Co-authored-by: Way2Learn <118058822+Xisen-Wang@users.noreply.github.com> Co-authored-by: WinstonLiyt <104308117+WinstonLiyt@users.noreply.github.com> Co-authored-by: Young --- .github/ISSUE_TEMPLATE/bug-report.md | 21 +++++-- README.md | 1 + rdagent/app/cli.py | 2 + rdagent/app/utils/info.py | 86 ++++++++++++++++++++++++++++ requirements.txt | 11 +--- 5 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 rdagent/app/utils/info.py diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 5a5808da..bde7b40e 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -27,11 +27,24 @@ Steps to reproduce the behavior: ## Environment - - - RD-Agent version: + +**Note**: Users can run `rdagent collect_info` to get system information and paste it directly here. + + - Name of current operating system: + - Processor architecture: + - System, version, and hardware information: + - Version number of the system: - Python version: - - OS: Linux - - Commit number (optional, please provide it if you are using the dev version): + - Container ID: + - Container Name: + - Container Status: + - Image ID used by the container: + - Image tag used by the container: + - Container port mapping: + - Container Label: + - Startup Commands: + - RD-Agent version: + - Package version: ## Additional Notes diff --git a/README.md b/README.md index 8b1afe05..7e277c94 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ [![Lint PR Title](https://github.com/microsoft/RD-Agent/actions/workflows/pr.yml/badge.svg)](https://github.com/microsoft/RD-Agent/actions/workflows/pr.yml) [![Readthedocs Preview](https://github.com/microsoft/RD-Agent/actions/workflows/readthedocs-preview.yml/badge.svg)](https://github.com/microsoft/RD-Agent/actions/workflows/readthedocs-preview.yml) [![Release.yml](https://github.com/microsoft/RD-Agent/actions/workflows/release.yml/badge.svg)](https://github.com/microsoft/RD-Agent/actions/workflows/release.yml) +[![Platform](https://img.shields.io/badge/platform-Linux-blue)](https://pypi.org/project/rdagent/#files) [![PyPI](https://img.shields.io/pypi/v/rdagent)](https://pypi.org/project/rdagent/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/rdagent)](https://pypi.org/project/rdagent/) [![Release](https://img.shields.io/github/v/release/microsoft/RD-Agent)](https://github.com/microsoft/RD-Agent/releases) diff --git a/rdagent/app/cli.py b/rdagent/app/cli.py index dd481853..154023d3 100644 --- a/rdagent/app/cli.py +++ b/rdagent/app/cli.py @@ -18,6 +18,7 @@ from rdagent.app.general_model.general_model import ( from rdagent.app.qlib_rd_loop.factor import main as fin_factor from rdagent.app.qlib_rd_loop.factor_from_report import main as fin_factor_report from rdagent.app.qlib_rd_loop.model import main as fin_model +from rdagent.app.utils.info import collect_info load_dotenv() @@ -46,5 +47,6 @@ def app(): "med_model": med_model, "general_model": general_model, "ui": ui, + "collect_info": collect_info, } ) diff --git a/rdagent/app/utils/info.py b/rdagent/app/utils/info.py new file mode 100644 index 00000000..24f78e18 --- /dev/null +++ b/rdagent/app/utils/info.py @@ -0,0 +1,86 @@ +import importlib.metadata +import platform +import sys +from pathlib import Path + +import docker +import requests +from setuptools_scm import get_version + +from rdagent.log import rdagent_logger as logger + + +def sys_info(): + """collect system related info""" + method_list = [ + ["Name of current operating system: ", "system"], + ["Processor architecture: ", "machine"], + ["System, version, and hardware information: ", "platform"], + ["Version number of the system: ", "version"], + ] + for method in method_list: + logger.info(f"{method[0]}{getattr(platform, method[1])()}") + return None + + +def python_info(): + """collect Python related info""" + python_version = sys.version.replace("\n", " ") + logger.info(f"Python version: {python_version}") + return None + + +def docker_info(): + client = docker.from_env() + containers = client.containers.list(all=True) + if containers: + containers.sort(key=lambda c: c.attrs["Created"]) + last_container = containers[-1] + logger.info(f"Container ID: {last_container.id}") + logger.info(f"Container Name: {last_container.name}") + logger.info(f"Container Status: {last_container.status}") + logger.info(f"Image ID used by the container: {last_container.image.id}") + logger.info(f"Image tag used by the container: {last_container.image.tags}") + logger.info(f"Container port mapping: {last_container.ports}") + logger.info(f"Container Label: {last_container.labels}") + logger.info(f"Startup Commands: {' '.join(client.containers.get(last_container.id).attrs['Config']['Cmd'])}") + else: + logger.info(f"No run containers.") + + +def rdagent_info(): + """collect rdagent related info""" + current_version = importlib.metadata.version("rdagent") + logger.info(f"RD-Agent version: {current_version}") + api_url = f"https://api.github.com/repos/microsoft/RD-Agent/contents/requirements.txt?ref=main" + response = requests.get(api_url) + if response.status_code == 200: + files = response.json() + file_url = files["download_url"] + file_response = requests.get(file_url) + if file_response.status_code == 200: + all_file_contents = file_response.text.split("\n") + else: + logger.warning(f"Failed to retrieve {files['name']}, status code: {file_response.status_code}") + else: + logger.warning(f"Failed to retrieve files in folder, status code: {response.status_code}") + package_list = [ + item.split("#")[0].strip() for item in all_file_contents if item.strip() and not item.startswith("#") + ] + package_version_list = [] + for package in package_list: + if package == "typer[all]": + package = "typer" + version = importlib.metadata.version(package) + package_version_list.append(f"{package}=={version}") + logger.info(f"Package version: {package_version_list}") + return None + + +def collect_info(): + """Prints information about the system and the installed packages.""" + sys_info() + python_info() + docker_info() + rdagent_info() + return None diff --git a/requirements.txt b/requirements.txt index 100136f2..59013632 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,7 +28,7 @@ tiktoken pymupdf # Extract shotsreens from pdf # azure identity related -azure.identity +azure-identity # PDF related pypdf @@ -39,17 +39,9 @@ azure-ai-formrecognizer # I think it is for running insteading of implementing. The dependency should be in statsmodels -# PDF related -pypdf -azure-core -azure-ai-formrecognizer - # factor implementations tables -# azure identity related -azure.identity - # CI Fix Tool tree-sitter-python tree-sitter @@ -72,6 +64,7 @@ selenium kaggle seaborn +setuptools-scm # This is a temporary package installed to pass the test_import test xgboost