Skip to content

Commit

Permalink
Merge pull request #984 from Capsize-Games/devastator
Browse files Browse the repository at this point in the history
Devastator
  • Loading branch information
w4ffl35 authored Jan 21, 2025
2 parents fcf40db + 178ab54 commit 99c6017
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 23 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="airunner",
version="3.1.6",
version="3.1.7",
author="Capsize LLC",
description="A Stable Diffusion GUI",
long_description=open("README.md", "r", encoding="utf-8").read(),
Expand Down
7 changes: 7 additions & 0 deletions src/airunner/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
db_path = os.path.expanduser("~/.local/share/airunner/data/airunner.db")
config.set_main_option("sqlalchemy.url", f"sqlite:///{db_path}")

# check if db file exists
print("*"*100)
if not os.path.exists(db_path):
print(f"Database file not found at {db_path}")
else:
print(f"Database file found at {db_path}")

# Import your models here
from airunner.data.models.settings_models import (
Conversation, Message, Summary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import sqlite
from sqlalchemy.engine.reflection import Inspector
from sqlalchemy.exc import OperationalError

# revision identifiers, used by Alembic.
revision: str = 'f403ff7468e8'
Expand All @@ -18,25 +20,18 @@
depends_on: Union[str, Sequence[str], None] = None

def upgrade():
try:
# Add bot_mood column to conversation table
bind = op.get_bind()
inspector = Inspector.from_engine(bind)
columns = [col['name'] for col in inspector.get_columns('conversations')]

if 'bot_mood' not in columns:
op.add_column('conversations', sa.Column('bot_mood', sa.Text(), nullable=True))
except sqlite.DatabaseError:
pass

try:
# Remove bot_mood column from chatbot table
op.drop_column('chatbots', 'bot_mood')
except sqlite.DatabaseError:
pass
except OperationalError as e:
print(f"Error dropping column 'bot_mood' from 'chatbots': {e}")

def downgrade():
try:
op.add_column('chatbots', sa.Column('bot_mood', sa.Text(), nullable=True))
except sqlite.DatabaseError:
pass

try:
op.drop_column('conversations', 'bot_mood')
except sqlite.DatabaseError:
pass
op.add_column('chatbots', sa.Column('bot_mood', sa.Text(), nullable=True))
op.drop_column('conversations', 'bot_mood')
2 changes: 2 additions & 0 deletions src/airunner/app_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def start(self):
signal.signal(signal.SIGINT, self.signal_handler)
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseDesktopOpenGL)
self.app = QApplication.instance()
if self.app is None:
self.app = QApplication([])

self.wizard = SetupWizardWindow()
self.wizard.exec()
Expand Down
17 changes: 14 additions & 3 deletions src/airunner/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
"""
----------------------------------------------------------------
Import order is crucial for AI Runner to work as expected.
Expand Down Expand Up @@ -44,6 +45,9 @@
from alembic.config import Config
from alembic import command
from pathlib import Path
from airunner.data.models.settings_models import ApplicationSettings
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session

def setup_database():
base_path = Path(os.path.dirname(os.path.realpath(__file__)))
Expand All @@ -55,9 +59,16 @@ def setup_database():

def main():
setup_database()
App(
defendatron=facehuggershield.huggingface.defendatron
)

# Get the first ApplicationSettings record from the database and check for run_setup_wizard boolean
engine = create_engine("sqlite:///" + os.path.join(base_dir, "airunner.db"))
session = scoped_session(sessionmaker(bind=engine))
application_settings = session.query(ApplicationSettings).first()
if application_settings.run_setup_wizard:
from airunner.app_installer import AppInstaller
AppInstaller()
else:
App(defendatron=facehuggershield.huggingface.defendatron)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from airunner.windows.setup_wizard.installation_settings.install_failed_page import InstallFailedPage
from airunner.windows.setup_wizard.installation_settings.install_page import InstallPage
from airunner.windows.setup_wizard.installation_settings.install_success_page import InstallSuccessPage
from airunner.windows.setup_wizard.path_settings.path_settings import PathSettings


class DownloadWizardWindow(QWizard, MediatorMixin, SettingsMixin):
"""
Expand Down Expand Up @@ -51,8 +53,9 @@ def init_pages(self):
):
create_airunner_paths(self.path_settings)

self.setPage(0, InstallPage(self))
self.setPage(1, InstallSuccessPage(self))
self.setPage(0, PathSettings(self))
self.setPage(1, InstallPage(self))
self.setPage(2, InstallSuccessPage(self))
failed = False

if failed:
Expand Down
8 changes: 7 additions & 1 deletion src/airunner/windows/main/settings_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,13 @@ def chatbot(self) -> Type[Chatbot]:

@property
def user(self) -> Type[User]:
return self.session.query(User).first()
user = self.session.query(User).first()
if user is None:
user = User()
user.username = "User"
self.session.add(user)
self.session.commit()
return user

@property
def window_settings(self):
Expand Down

0 comments on commit 99c6017

Please sign in to comment.