Add VS Code Extension (#15027)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Burhan 2024-08-26 13:03:44 -04:00 committed by GitHub
parent 391dc72049
commit 848c5cd506
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 339 additions and 19 deletions

View file

@ -46,6 +46,7 @@ ARM64 = platform.machine() in {"arm64", "aarch64"} # ARM64 booleans
PYTHON_VERSION = platform.python_version()
TORCH_VERSION = torch.__version__
TORCHVISION_VERSION = importlib.metadata.version("torchvision") # faster than importing torchvision
IS_VSCODE = os.environ.get("TERM_PROGRAM", False) == "vscode"
HELP_MSG = """
Examples for running Ultralytics:
@ -1046,7 +1047,7 @@ class SettingsManager(dict):
version (str): Settings version. In case of local version mismatch, new default settings will be saved.
"""
def __init__(self, file=SETTINGS_YAML, version="0.0.4"):
def __init__(self, file=SETTINGS_YAML, version="0.0.5"):
"""Initializes the SettingsManager with default settings and loads user settings."""
import copy
import hashlib
@ -1077,6 +1078,7 @@ class SettingsManager(dict):
"raytune": True,
"tensorboard": True,
"wandb": True,
"vscode_msg": True,
}
self.help_msg = (
f"\nView settings with 'yolo settings' or at '{self.file}'"
@ -1152,6 +1154,18 @@ def url2file(url):
return Path(clean_url(url)).name
def vscode_msg(ext="ultralytics.ultralytics-snippets") -> str:
"""Display a message to install Ultralytics-Snippets for VS Code if not already installed."""
path = (USER_CONFIG_DIR.parents[2] if WINDOWS else USER_CONFIG_DIR.parents[1]) / ".vscode/extensions"
obs_file = path / ".obsolete" # file tracks uninstalled extensions, while source directory remains
installed = any(path.glob(f"{ext}*")) and ext not in (obs_file.read_text("utf-8") if obs_file.exists() else "")
return (
f"{colorstr('VS Code:')} view Ultralytics VS Code Extension ⚡ at https://docs.ultralytics.com/integrations/vscode"
if not installed
else ""
)
# Run below code on utils init ------------------------------------------------------------------------------------
# Check first-install steps