Remove toml (#210)
# PR Description `arcade.toml` was deprecated in favor of `credentials.yaml` in PR #116 . This PR completely removes any references to handling the deprecation & any references to `arcade.toml`
This commit is contained in:
parent
3f9da98560
commit
cdd90b4844
7 changed files with 6 additions and 85 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,7 +1,5 @@
|
|||
.DS_Store
|
||||
arcade.toml # Deprecated in favor of credentials.yaml
|
||||
credentials.yaml
|
||||
docker/arcade.toml # Deprecated in favor of credentials.yaml
|
||||
docker/credentials.yaml
|
||||
|
||||
*.lock
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import yaml
|
|||
from rich.console import Console
|
||||
|
||||
from arcade.cli.constants import LOGIN_FAILED_HTML, LOGIN_SUCCESS_HTML
|
||||
from arcade.cli.utils import create_new_env_file, is_config_file_deprecated
|
||||
from arcade.cli.utils import create_new_env_file
|
||||
|
||||
console = Console()
|
||||
|
||||
|
|
@ -116,11 +116,8 @@ def check_existing_login() -> bool:
|
|||
Check if the user is already logged in by verifying the config file.
|
||||
|
||||
Returns:
|
||||
bool: True if the user is already logged in or is using the deprecated config file, False otherwise.
|
||||
bool: True if the user is already logged in, False otherwise.
|
||||
"""
|
||||
if is_config_file_deprecated():
|
||||
return True
|
||||
|
||||
# Create a new env file if one doesn't already exist
|
||||
create_new_env_file()
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ from arcade.cli.utils import (
|
|||
OrderCommands,
|
||||
compute_engine_base_url,
|
||||
compute_login_url,
|
||||
delete_deprecated_config_file,
|
||||
get_eval_files,
|
||||
get_user_input,
|
||||
handle_chat_interaction,
|
||||
|
|
@ -104,8 +103,6 @@ def logout() -> None:
|
|||
"""
|
||||
Logs the user out of Arcade Cloud.
|
||||
"""
|
||||
delete_deprecated_config_file()
|
||||
|
||||
# If ~/.arcade/credentials.yaml exists, delete it
|
||||
config_file_path = os.path.expanduser("~/.arcade/credentials.yaml")
|
||||
if os.path.exists(config_file_path):
|
||||
|
|
|
|||
|
|
@ -578,33 +578,6 @@ def create_new_env_file() -> None:
|
|||
console.print(f"Created new environment file at {env_file}", style="bold green")
|
||||
|
||||
|
||||
def is_config_file_deprecated() -> bool:
|
||||
"""
|
||||
Check if the user is using the deprecated config file.
|
||||
|
||||
Returns:
|
||||
bool: True if the user is using the deprecated config file, False otherwise.
|
||||
"""
|
||||
deprecated_config_file_path = os.path.expanduser("~/.arcade/arcade.toml")
|
||||
if os.path.exists(deprecated_config_file_path):
|
||||
console.print(
|
||||
f"Deprecation Notice: You are using a deprecated config file at {deprecated_config_file_path}. Please migrate to the new format by running,\n\n\t$ arcade logout && arcade login\n",
|
||||
style="bold yellow",
|
||||
)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def delete_deprecated_config_file() -> None:
|
||||
"""
|
||||
Delete the deprecated config file if it exists.
|
||||
"""
|
||||
deprecated_config_file_path = os.path.expanduser("~/.arcade/arcade.toml")
|
||||
|
||||
if os.path.exists(deprecated_config_file_path):
|
||||
os.remove(deprecated_config_file_path)
|
||||
|
||||
|
||||
def get_user_input() -> str:
|
||||
"""
|
||||
Get input from the user, handling multi-line input.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import os
|
|||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import toml
|
||||
import yaml
|
||||
from pydantic import BaseModel, ConfigDict, ValidationError
|
||||
|
||||
|
|
@ -62,13 +61,6 @@ class Config(BaseConfig):
|
|||
config_path = os.getenv("ARCADE_WORK_DIR") or Path.home() / ".arcade"
|
||||
return Path(config_path).resolve()
|
||||
|
||||
@classmethod
|
||||
def get_deprecated_config_file_path(cls) -> Path:
|
||||
"""
|
||||
Get the path to the deprecated Arcade configuration file.
|
||||
"""
|
||||
return cls.get_config_dir_path() / "arcade.toml"
|
||||
|
||||
@classmethod
|
||||
def get_config_file_path(cls) -> Path:
|
||||
"""
|
||||
|
|
@ -96,22 +88,17 @@ class Config(BaseConfig):
|
|||
- A default Engine configuration (host: "api.arcade-ai.com", port: None, tls: True)
|
||||
- No user configuration
|
||||
|
||||
If a deprecated TOML configuration file is found, it will be automatically converted
|
||||
to the new YAML format. This ensures that the application always has a valid configuration
|
||||
to work with, but it may not be suitable for all use cases. If a specific configuration
|
||||
is required, ensure that the configuration file exists before calling this method.
|
||||
|
||||
Returns:
|
||||
Config: The loaded or newly created configuration.
|
||||
|
||||
Raises:
|
||||
ValueError: If the existing configuration file is invalid or cannot be converted.
|
||||
ValueError: If the existing configuration file is invalid.
|
||||
"""
|
||||
cls.ensure_config_dir_exists()
|
||||
|
||||
config_file_path = cls.get_config_file_path()
|
||||
|
||||
if not config_file_path.exists() and not cls._migrate_deprecated_config_file():
|
||||
if not config_file_path.exists():
|
||||
# Create a file using the default configuration
|
||||
default_config = cls.model_construct(api=ApiConfig.model_construct())
|
||||
default_config.save_to_file()
|
||||
|
|
@ -157,31 +144,3 @@ class Config(BaseConfig):
|
|||
Config.ensure_config_dir_exists()
|
||||
config_file_path = Config.get_config_file_path()
|
||||
config_file_path.write_text(yaml.dump(self.model_dump()))
|
||||
|
||||
@classmethod
|
||||
def _migrate_deprecated_config_file(cls) -> bool:
|
||||
"""
|
||||
Migrate the deprecated config file to the new format if the deprecated config file exists.
|
||||
|
||||
Returns:
|
||||
bool: True if the migration occurred, False otherwise.
|
||||
"""
|
||||
deprecated_config_file_path = Config.get_deprecated_config_file_path()
|
||||
|
||||
if deprecated_config_file_path.exists():
|
||||
# If the user is using the deprecated config file, then convert it to the new yaml format
|
||||
try:
|
||||
old_config: dict[str, Any] = toml.load(deprecated_config_file_path)
|
||||
old_config = {"cloud": old_config}
|
||||
with open(cls.get_config_file_path(), "w") as f:
|
||||
yaml.dump(old_config, f)
|
||||
os.remove(deprecated_config_file_path)
|
||||
print(
|
||||
f"\033[1;33mAutomatically migrated the deprecated config file {deprecated_config_file_path} to {cls.get_config_file_path()}\033[0m"
|
||||
)
|
||||
except Exception as e:
|
||||
raise OSError(
|
||||
f"Invalid configuration file at {deprecated_config_file_path} could not be automatically converted to the new format. Please manually migrate to {cls.get_config_file_path()} by running `arcade logout && arcade login`."
|
||||
) from e
|
||||
return True
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@ pydantic = "^2.7.0"
|
|||
typer = "^0.9.0"
|
||||
rich = "^13.7.1"
|
||||
Jinja2 = ">=3.1.5,<4.0.0"
|
||||
toml = "^0.10.2"
|
||||
pyyaml = "^6.0"
|
||||
tomlkit = "^0.12.4"
|
||||
openai = "^1.36.0" # TODO: relax to an earlier version that still has what we need
|
||||
arcadepy = "1.0.0rc1"
|
||||
pyjwt = "^2.8.0"
|
||||
|
|
@ -52,7 +50,6 @@ mypy = "^1.5.1"
|
|||
pre-commit = "^3.4.0"
|
||||
tox = "^4.11.1"
|
||||
pytest-asyncio = "^0.23.7"
|
||||
types-toml = "^0.10.8"
|
||||
types-pytz = "^2024.1"
|
||||
types-python-dateutil = "^2.8.2"
|
||||
types-PyYAML = "^6.0.0"
|
||||
|
|
|
|||
4
contrib/langchain/.gitignore
vendored
4
contrib/langchain/.gitignore
vendored
|
|
@ -1,6 +1,6 @@
|
|||
.DS_Store
|
||||
arcade.toml
|
||||
docker/arcade.toml
|
||||
credentials.yaml
|
||||
docker/credentials.yaml
|
||||
|
||||
*.lock
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue