Skip to content

Commit

Permalink
refactor(init): removed kitchenai yml from init requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
esteban-puerta-rs committed Oct 27, 2024
1 parent f8ace41 commit 502a45c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8 deletions.
3 changes: 3 additions & 0 deletions kitchenai/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@



30 changes: 27 additions & 3 deletions kitchenai/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
from django.conf import settings
from cookiecutter.main import cookiecutter
from typing_extensions import Annotated
from rich.console import Console
from rich.spinner import Spinner

console = Console()

logger = logging.getLogger(__name__)

app = typer.Typer()

@app.command()
Expand All @@ -18,10 +22,30 @@ def add(module: str = typer.Argument("app.kitchen:kitchen")):
execute_from_command_line(["manage", "add_module", module])

@app.command()
def init():
def init(verbose: Annotated[int, typer.Option(help="verbosity level. default 0")] = 0):
django.setup()
from django.core.management import execute_from_command_line
execute_from_command_line(["manage", "migrate"])
execute_from_command_line(["manage", "init"])
from kitchenai.core.models import KitchenAIManagement
from django.conf import settings

cmd = ["manage", "migrate","--verbosity", f"{verbose}"]

if not verbose == 1:
with console.status("Applying migrations...", spinner="dots"):
execute_from_command_line(cmd)
else:
execute_from_command_line(cmd)


KitchenAIManagement.objects.all().delete()
try:
mgmt = KitchenAIManagement.objects.create(
version = settings.VERSION,
project_name = "default"
)
except Exception as e:
logger.error(e)
return


@app.command()
Expand Down
9 changes: 8 additions & 1 deletion kitchenai/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@
# 0. Setup
# --------------------------------------------------------------------------------------------


VERSION = "0.0.1"

BASE_DIR = Path(__file__).resolve(strict=True).parent.parent

APPS_DIR = BASE_DIR / "kitchenai"

KITCHENAI_DB_DIR = BASE_DIR / '.kitchenai'

KITCHENAI_DB_DIR.mkdir(exist_ok=True)

env = Env()
env.read_env(Path(BASE_DIR, ".env").as_posix())

Expand Down Expand Up @@ -56,7 +63,7 @@
CSRF_COOKIE_SECURE = not DEBUG

DATABASES = {
"default": env.dj_db_url("DATABASE_URL", default="sqlite:///db.sqlite3"),
"default": env.dj_db_url("DATABASE_URL", default=f"sqlite:///{KITCHENAI_DB_DIR / 'db.sqlite3'}"),
}
DATABASES["default"]["ATOMIC_REQUESTS"] = False

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ dependencies = [
"sentry-sdk",
"typer",
"whitenoise",
"cookiecutter"
"cookiecutter",
"rich"
]

scripts.kitchenai = "kitchenai.__main__:main"
Expand Down
10 changes: 7 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

#
# This file is autogenerated by hatch-pip-compile with Python 3.11
#
# [constraints] requirements.txt (SHA256: 618a6a537aaab456e4811a335eee5e07ba29c910e1e1c050340cac2c611907c3)
# [constraints] requirements.txt (SHA256: 9ea184c46b3b5c6a9cd0638530342b4fba7ac2fccf2b5472412447ae35303083)
#
# - django-browser-reload
# - django-debug-toolbar
Expand Down Expand Up @@ -56,6 +55,7 @@
# - psycopg[binary]
# - pyyaml
# - refreshcss
# - rich
# - sentry-sdk
# - slippers
# - typer
Expand Down Expand Up @@ -1204,7 +1204,10 @@ pyzmq==26.2.0
# jupyter-server
questionary==1.10.0
# via bump-my-version

rcssmin==1.1.2
# via
# -c requirements.txt
# django-compressor
referencing==0.35.1
# via
# jsonschema
Expand Down Expand Up @@ -1250,6 +1253,7 @@ rfc3986-validator==0.1.1
rich==13.9.2
# via
# -c requirements.txt
# hatch.envs.dev
# bump-my-version
# cappa
# chromadb
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
# - psycopg[binary]
# - pyyaml
# - refreshcss
# - rich
# - sentry-sdk
# - slippers
# - typer
Expand Down Expand Up @@ -552,6 +553,7 @@ pyyaml==6.0.2
# llama-index-core
# slippers
# uvicorn
rcssmin==1.1.2
# via django-compressor
refreshcss==0.5.1
# via hatch.envs.default
Expand All @@ -577,6 +579,7 @@ requests-oauthlib==2.0.0
# kubernetes
rich==13.9.2
# via
# hatch.envs.default
# chromadb
# cookiecutter
# falco-app
Expand Down

0 comments on commit 502a45c

Please sign in to comment.