Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: sed -i 's/host=db/host=127.0.0.1/' db.config.example
- name: Run linters
run: |
flake8 app.py controllers/ models/ view/
mypy app.py controllers/ models/ view/
flake8 app.py controllers/ models/ views/
mypy app.py controllers/ models/ views/
- name: Run tests
run: pytest --cov=controllers --cov=models
34 changes: 13 additions & 21 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

import streamlit as st

from views import (
api_configurazione,
esecuzione_test,
gestione_domande,
gestione_set,
home,
visualizza_risultati,
)
from views.session_state import initialize_session_state
from views.style_utils import load_css
from utils.startup_utils import setup_logging
Expand All @@ -34,16 +26,16 @@
# Aggiungi CSS personalizzato e stili globali
load_css()

PAGES = {
"Home": home.render,
"Configurazione API": api_configurazione.render,
"Gestione Domande": gestione_domande.render,
"Gestione Set di Domande": gestione_set.render,
"Esecuzione Test": esecuzione_test.render,
"Visualizzazione Risultati": visualizza_risultati.render,
}

selected_page = st.sidebar.radio("Navigazione", list(PAGES.keys()))

render_page = PAGES[selected_page]
render_page()
# --- Definizione pagine con il nuovo sistema ---
Home = st.Page("views/home.py", title="Home", icon=":material/home:", default=True)
Configurazione_API = st.Page("views/api_configurazione.py", title="Configurazione API", icon=":material/api:")
Gestione_domande = st.Page("views/gestione_domande.py", title="Gestione Domande", icon=":material/construction:")
Gestione_set = st.Page("views/gestione_set.py", title="Gestione Set di Domande", icon=":material/list:")
Esecuzione_test = st.Page("views/esecuzione_test.py", title="Esecuzione Test", icon=":material/rule_settings:")
Visualizza_risultati = st.Page("views/visualizza_risultati.py",
title="Visualizzazione Risultati",
icon=":material/bar_chart:")

# --- Navigazione ---
pg = st.navigation([Home, Configurazione_API, Gestione_domande, Gestione_set, Esecuzione_test, Visualizza_risultati])
pg.run()
2 changes: 1 addition & 1 deletion controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Gestione dei preset API
import logging
from .startup_controller import get_initial_state

from .api_preset_controller import (
load_presets,
Expand Down Expand Up @@ -65,7 +66,6 @@
calculate_statistics = TestResult.calculate_statistics

# Funzioni di avvio
from .startup_controller import get_initial_state
logger = logging.getLogger(__name__)


Expand Down
Binary file added controllers/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion controllers/question_set_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pandas as pd

from models.question_set import QuestionSet, PersistSetsResult, question_set_importer
from models.question_set import QuestionSet, question_set_importer # PersistSetsResult not used
from utils.cache import (
get_questions as _get_questions,
get_question_sets as _get_question_sets,
Expand All @@ -15,6 +15,7 @@
)
logger = logging.getLogger(__name__)


def load_sets() -> pd.DataFrame:
"""Restituisce tutti i set di domande utilizzando la cache."""
return _get_question_sets()
Expand Down
2 changes: 1 addition & 1 deletion controllers/startup_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DefaultConfig,
initialize_database,
load_default_config,
setup_logging,
# setup_logging,
)

logger = logging.getLogger(__name__)
Expand Down
14 changes: 14 additions & 0 deletions db.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[mysql]
host=db
user=root
password=
database=llm_platform
port=3306
ssl_ca=

# Per l'ambiente Docker, utilizzare:
# host=db
# user=root
# password=
# database=llm_platform
# port=3306
Binary file added models/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added models/__pycache__/api_preset.cpython-311.pyc
Binary file not shown.
Binary file added models/__pycache__/database.cpython-311.pyc
Binary file not shown.
Binary file added models/__pycache__/db_utils.cpython-311.pyc
Binary file not shown.
Binary file added models/__pycache__/orm_models.cpython-311.pyc
Binary file not shown.
Binary file added models/__pycache__/question.cpython-311.pyc
Binary file not shown.
Binary file added models/__pycache__/question_set.cpython-311.pyc
Binary file not shown.
Binary file added models/__pycache__/test_result.cpython-311.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions models/cached_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from models.test_result import TestResult
logger = logging.getLogger(__name__)


def get_questions() -> List[Question]:
return Question.load_all()

Expand Down
1 change: 0 additions & 1 deletion models/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,3 @@ def init_db(self) -> None:
class Base(DeclarativeBase):
"""Base class per i modelli dichiarativi SQLAlchemy."""
pass

1 change: 0 additions & 1 deletion models/question_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,3 @@ def gather_data(self) -> List[Dict[str, Any]]: # type: ignore[override]


question_set_importer = QuestionSetImporter()

1 change: 0 additions & 1 deletion models/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,3 @@ def gather_data(self) -> pd.DataFrame: # type: ignore[override]


test_result_importer = TestResultImporter()

Binary file added utils/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added utils/__pycache__/cache.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file added utils/__pycache__/export_template.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file added utils/__pycache__/import_template.cpython-311.pyc
Binary file not shown.
Binary file added utils/__pycache__/openai_client.cpython-311.pyc
Binary file not shown.
Binary file added utils/__pycache__/startup_utils.cpython-311.pyc
Binary file not shown.
Binary file added views/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file added views/__pycache__/esecuzione_test.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file added views/__pycache__/gestione_set.cpython-311.pyc
Binary file not shown.
Binary file added views/__pycache__/home.cpython-311.pyc
Binary file not shown.
Binary file added views/__pycache__/session_state.cpython-311.pyc
Binary file not shown.
Binary file added views/__pycache__/set_helpers.cpython-311.pyc
Binary file not shown.
Binary file added views/__pycache__/state_models.cpython-311.pyc
Binary file not shown.
Binary file added views/__pycache__/style_utils.cpython-311.pyc
Binary file not shown.
Binary file not shown.
10 changes: 8 additions & 2 deletions views/api_configurazione.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import streamlit as st

from views import register_page
# from views import register_page
from views.style_utils import add_page_header, add_section_title
from controllers import (
save_preset,
Expand Down Expand Up @@ -116,7 +116,7 @@ def delete_preset_callback(preset_id):
st.error(message)


@register_page("Configurazione API")
# @register_page("Configurazione API")
def render():
add_page_header(
"Gestione Preset API",
Expand Down Expand Up @@ -283,3 +283,9 @@ def render():
if "preset_deleted_message" in st.session_state:
st.success(st.session_state.preset_deleted_message)
del st.session_state.preset_deleted_message


if __name__ == "__main__":
render()
else:
render()
10 changes: 8 additions & 2 deletions views/esecuzione_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import streamlit as st

from controllers import run_test, load_sets, load_presets, get_preset_by_name
from views import register_page
# from views import register_page
from views.style_utils import add_page_header, add_section_title
logger = logging.getLogger(__name__)

Expand All @@ -22,7 +22,7 @@ def run_llm_test_callback():
st.session_state.run_llm_test = True


@register_page("Esecuzione Test")
# @register_page("Esecuzione Test")
def render():
# === Inizializzazione delle variabili di stato ===
if 'test_mode' not in st.session_state:
Expand Down Expand Up @@ -165,3 +165,9 @@ def render():
st.write("**Risposta Generata:**", result['actual_answer'])
st.write("**Punteggio:**", f"{result['evaluation']['score']:.1f}%")
st.write("**Valutazione:**", result['evaluation']['explanation'])


if __name__ == "__main__":
render()
else:
render()
10 changes: 8 additions & 2 deletions views/gestione_domande.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
delete_question_action,
import_questions_action,
)
from views import register_page
# from views import register_page
from views.style_utils import add_page_header
from views.state_models import QuestionPageState
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -106,7 +106,7 @@ def confirm_delete_question_dialog(question_id, question_text):
st.rerun()


@register_page("Gestione Domande")
# @register_page("Gestione Domande")
def render():
# === Inizializzazione dello stato ===
st.session_state.setdefault("question_page_state", QuestionPageState())
Expand Down Expand Up @@ -303,3 +303,9 @@ def render():
key="import_questions_btn",
on_click=import_questions_callback
)


if __name__ == "__main__":
render()
else:
render()
10 changes: 8 additions & 2 deletions views/gestione_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
load_sets,
prepare_sets_for_view,
)
from views import register_page
# from views import register_page
from views.style_utils import add_page_header, add_global_styles
from views.state_models import SetPageState
from views.set_helpers import (
Expand All @@ -18,7 +18,7 @@
logger = logging.getLogger(__name__)


@register_page("Gestione Set di Domande")
# @register_page("Gestione Set di Domande")
def render():
add_global_styles()

Expand Down Expand Up @@ -350,3 +350,9 @@ def render():
key="import_set_btn",
on_click=lambda: import_set_callback(state)
)


if __name__ == "__main__":
render()
else:
render()
12 changes: 9 additions & 3 deletions views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import logging

import streamlit as st
from .style_utils import add_home_styles
from views import register_page
from views.style_utils import add_home_styles
# from views import register_page

logger = logging.getLogger(__name__)


@register_page("Home")
# @register_page("Home")
def render():
"""Visualizza la pagina principale con le funzionalità della piattaforma."""

Expand Down Expand Up @@ -100,3 +100,9 @@ def render():
""",
unsafe_allow_html=True,
)


if __name__ == "__main__":
render()
else:
render()
4 changes: 3 additions & 1 deletion views/style_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

logger = logging.getLogger(__name__)


def load_css():
"""
Applica il CSS globale presente in 'styles.css'.
Expand All @@ -18,13 +19,14 @@ def load_css():
css_content = css_path.read_text()
st.markdown(f"<style>{css_content}</style>", unsafe_allow_html=True)
else:
st.warning("File styles.css non trovato. Assicurati che sia presente nella cartella utils.")
st.warning("File styles.css non trovato. Assicurati che sia presente nella cartella views.")


def add_global_styles():
"""Aggiunge stili globali all'applicazione."""
load_css()


def add_page_header(title: str, icon: str = "💡", description: str | None = None):
"""Aggiunge un'intestazione di pagina stilizzata."""
load_css()
Expand Down
Loading
Loading