Fix issue when config dir is created even if YOLO_CONFIG_DIR is set (#4054)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
single_channel
valfrom 1 year ago committed by GitHub
parent 379f31904a
commit 40af5b0fa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -568,9 +568,10 @@ def get_user_config_dir(sub_dir='Ultralytics'):
raise ValueError(f'Unsupported operating system: {platform.system()}') raise ValueError(f'Unsupported operating system: {platform.system()}')
# GCP and AWS lambda fix, only /tmp is writeable # GCP and AWS lambda fix, only /tmp is writeable
if not is_dir_writeable(str(path.parent)): if not is_dir_writeable(path.parent):
path = Path('/tmp') / sub_dir LOGGER.warning(f"WARNING ⚠️ user config directory '{path}' is not writeable, defaulting to '/tmp' or CWD."
LOGGER.warning(f"WARNING ⚠️ user config directory is not writeable, defaulting to '{path}'.") 'Alternatively you can define a YOLO_CONFIG_DIR environment variable for this path.')
path = Path('/tmp') / sub_dir if is_dir_writeable('/tmp') else Path().cwd() / sub_dir
# Create the subdirectory if it does not exist # Create the subdirectory if it does not exist
path.mkdir(parents=True, exist_ok=True) path.mkdir(parents=True, exist_ok=True)
@ -578,7 +579,7 @@ def get_user_config_dir(sub_dir='Ultralytics'):
return path return path
USER_CONFIG_DIR = Path(os.getenv('YOLO_CONFIG_DIR', get_user_config_dir())) # Ultralytics settings dir USER_CONFIG_DIR = Path(os.getenv('YOLO_CONFIG_DIR') or get_user_config_dir()) # Ultralytics settings dir
SETTINGS_YAML = USER_CONFIG_DIR / 'settings.yaml' SETTINGS_YAML = USER_CONFIG_DIR / 'settings.yaml'

Loading…
Cancel
Save