Skip to content

Commit d9ba4b0

Browse files
committed
chore: rename stuff
1 parent afd03f4 commit d9ba4b0

7 files changed

Lines changed: 24 additions & 15 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ RUN pip install --no-cache-dir -r requirements.txt
1818

1919

2020
# Run the application when the container launches
21-
CMD ["python", "app/register.py"]
21+
CMD ["python", "app/agent.py"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ make init # create a virtual environment
3434

3535
```console
3636
source activate
37-
python -m app.register
37+
python -m app.agent
3838
```
3939

4040
## OPTIONAL: Docker

app/register.py renamed to app/agent.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from .prompt import completion
88

99

10-
# Initialize logging
1110
setup_logging()
1211
logger = get_logger(__name__)
1312

app/database.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pymysql
88

99
from app.exceptions import ConfigurationException
10+
from app.logging_config import get_logger, setup_logging
1011
from app.settings import (
1112
MYSQL_CHARSET,
1213
MYSQL_DATABASE,
@@ -17,6 +18,10 @@
1718
)
1819

1920

21+
setup_logging()
22+
logger = get_logger(__name__)
23+
24+
2025
class DatabaseConnection:
2126
"""MySQL database connection manager."""
2227

@@ -46,6 +51,7 @@ def get_connection(self) -> pymysql.Connection:
4651
Raises:
4752
pymysql.Error: If connection fails
4853
"""
54+
logger.debug("Connecting to MySQL database at %s:%s", self.host, self.port)
4955
try:
5056
connection = pymysql.connect(
5157
host=self.host,
@@ -99,6 +105,7 @@ def execute_query(self, query: str, params: Optional[tuple] = None) -> List[Dict
99105
Returns:
100106
List[Dict[str, Any]]: Query results as list of dictionaries
101107
"""
108+
logger.debug("Executing query: %s with params: %s", query, params)
102109
with self.get_cursor() as cursor:
103110
cursor.execute(query, params or ())
104111
return cursor.fetchall()
@@ -114,6 +121,7 @@ def execute_update(self, query: str, params: Optional[tuple] = None) -> int:
114121
Returns:
115122
int: Number of affected rows
116123
"""
124+
logger.debug("Executing update: %s with params: %s", query, params)
117125
with self.get_cursor() as cursor:
118126
cursor.execute(query, params or ())
119127
return cursor.rowcount
@@ -131,7 +139,7 @@ def test_connection(self) -> bool:
131139
return True
132140
# pylint: disable=broad-except
133141
except Exception as e:
134-
print(f"Database connection test failed: {e}")
142+
logger.error("Database connection test failed: %s", e)
135143
return False
136144

137145

app/prompt.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from app.stackademy import stackademy_app
2424

2525

26-
# Initialize logging
2726
setup_logging()
2827
logger = get_logger(__name__)
2928

app/stackademy.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
from app.logging_config import get_logger, setup_logging
1313

1414

15+
setup_logging()
16+
logger = get_logger(__name__)
17+
18+
1519
class StackademySpecializationArea(str, Enum):
1620
"""Available specialization areas for courses."""
1721

@@ -42,11 +46,6 @@ class StackademyRegisterCourseParams(BaseModel):
4246
full_name: str = Field(description="The full name of the new user.")
4347

4448

45-
# Initialize logging
46-
setup_logging()
47-
logger = get_logger(__name__)
48-
49-
5049
class Stackademy:
5150
"""Main application class for Stackademy with database functionality."""
5251

@@ -173,6 +172,11 @@ def register_course(self, course_code: str, email: str, full_name: str) -> bool:
173172
if not self.verify_course(course_code):
174173
logger.error("Course code %s does not exist.", course_code)
175174
return False
175+
176+
# Print success message in bold bright green
177+
success_message = f"Successfully registered {full_name} ({email}) for course {course_code}."
178+
print(f"\033[1;92m{success_message}\033[0m")
179+
logger.info(success_message)
176180
return True
177181

178182

app/tests/test_application.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import unittest
1010
from pathlib import Path
1111

12+
from app.agent import main # noqa: E402
13+
1214

1315
HERE = os.path.abspath(os.path.dirname(__file__))
1416
PROJECT_ROOT = str(Path(HERE).parent.parent)
@@ -17,9 +19,6 @@
1719
sys.path.append(PYTHON_ROOT) # noqa: E402
1820

1921

20-
from app.register import register # noqa: E402
21-
22-
2322
class TestApplication(unittest.TestCase):
2423
"""Test application."""
2524

@@ -28,6 +27,6 @@ def test_application_does_not_crash(self):
2827

2928
# pylint: disable=broad-exception-caught
3029
try:
31-
register()
30+
main()
3231
except Exception as e:
33-
self.fail(f"register raised an exception: {e}")
32+
self.fail(f"main raised an exception: {e}")

0 commit comments

Comments
 (0)