Skip to content

Commit 9c63919

Browse files
authored
Merge branch 'AOSSIE-Org:main' into main
2 parents dffbf30 + a3af96c commit 9c63919

5 files changed

Lines changed: 59 additions & 61 deletions

File tree

backend/app/logging/setup_logging.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,16 @@ def emit(self, record: logging.LogRecord) -> None:
243243
# Create a message that includes the original module in the format
244244
msg = record.getMessage()
245245

246-
# Find the appropriate logger
247-
logger = get_logger(module_name)
248-
249-
# Log the message with our custom formatting
250-
logger.log(record.levelno, f"[uvicorn] {msg}")
246+
record.msg = f"[{module_name}] {msg}"
247+
record.args = ()
248+
# Clear exception / stack info to avoid duplicate traces
249+
record.exc_info = None
250+
record.stack_info = None
251+
252+
root_logger = logging.getLogger()
253+
for handler in root_logger.handlers:
254+
if handler is not self:
255+
handler.handle(record)
251256

252257

253258
def configure_uvicorn_logging(component_name: str) -> None:

backend/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ async def root():
141141
# Create a simple config with log_config=None to disable Uvicorn's default logging
142142
config = Config(
143143
app=app,
144-
host="0.0.0.0",
144+
host="localhost",
145145
port=52123,
146146
log_level="info",
147147
log_config=None, # This is crucial - disable Uvicorn's default logging config

docs/Manual_Setup_Guide.md

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ cd PictoPy
2424
git remote add upstream https://github.com/AOSSIE-Org/PictoPy
2525
```
2626

27+
### Prerequisites:
28+
29+
#### Install and Setup Miniconda
30+
31+
Before setting up the Python backend and sync-microservice, you need to have **Miniconda** installed and set up on your system.
32+
33+
1. **Download and Install Miniconda:**
34+
35+
- Visit the [Miniconda installation guide](https://www.anaconda.com/docs/getting-started/miniconda/install#quickstart-install-instructions)
36+
- Follow the quickstart install instructions for your operating system
37+
- Make sure `conda` is available in your terminal after installation
38+
39+
2. **Verify Installation:**
40+
```bash
41+
conda --version
42+
```
43+
You should see the conda version number if installed correctly.
44+
2745
### Tauri Frontend Setup:
2846

2947
1. **Install Tauri prerequisites based on your OS using this** [guide](https://tauri.app/start/prerequisites/).
@@ -43,7 +61,7 @@ git remote add upstream https://github.com/AOSSIE-Org/PictoPy
4361

4462
### Python (FastAPI) Backend Setup Steps:
4563

46-
> **Note:** For backend setup make sure that you have **Python version 3.12**. Additionally, for Windows, make sure that you are using Powershell for the setup, not command prompt.
64+
> **Note:** For backend setup make sure that you have **Miniconda installed** (see Prerequisites section above). Additionally, for Windows, make sure that you are using Powershell for the setup, not command prompt.
4765
4866
1. **Navigate to the Backend Directory:** Open your terminal and use `cd` to change directories:
4967

@@ -53,47 +71,31 @@ git remote add upstream https://github.com/AOSSIE-Org/PictoPy
5371
cd backend
5472
```
5573
56-
2. **Set Up a Virtual Environment (Highly Recommended):** Virtual environments isolate project dependencies. Create one using:
74+
2. **Create a Conda Environment:** Create a new conda environment with Python 3.12:
5775
58-
Bash(Linux/MacOS)
59-
60-
```
61-
python3 -m venv .env
62-
```
63-
64-
Powershell(Windows)
76+
Bash/Powershell
6577
6678
```
67-
python -m venv .env
79+
conda create -p .env python=3.12
6880
```
6981
70-
3. **Activate the Virtual Environment:**
71-
72-
Bash(Linux/MacOS)
82+
3. **Activate the Conda Environment:**
7383
74-
```
75-
source .env/bin/activate
76-
```
77-
78-
Powershell(Windows)
84+
Bash/Powershell
7985
8086
```
81-
.env\Scripts\Activate.ps1
87+
conda activate ./.env
8288
```
8389
84-
After activating, you should be able to see the virtual environment's name before the current path. Something like this:
85-
86-
![alt text](/docs/assets/screenshots/virtualEnv.png)
87-
8890
4. **Install Dependencies:** The `requirements.txt` file lists required packages. Install them using pip:
8991
90-
Bash
92+
Bash/Powershell
9193
9294
```
9395
pip install -r requirements.txt
9496
```
9597
96-
5. **Running the backend:**: To start the backend in development mode, run this command while being in the backend folder and the virtual environment activated:
98+
5. **Running the backend:**: To start the backend in development mode, run this command while being in the backend folder and the conda environment activated:
9799
98100
Bash/Powershell
99101
@@ -107,7 +109,7 @@ git remote add upstream https://github.com/AOSSIE-Org/PictoPy
107109
108110
### Sync-Microservice Setup Steps:
109111
110-
> **Note:** For sync-microservice setup make sure that you have **Python version 3.12**. Additionally, for Windows, make sure that you are using Powershell for the setup, not command prompt.
112+
> **Note:** For sync-microservice setup make sure that you have **Miniconda installed** (see Prerequisites section above). Additionally, for Windows, make sure that you are using Powershell for the setup, not command prompt.
111113
112114
1. **Navigate to the Sync-Microservice Directory:** Open your terminal and use `cd` to change directories:
113115
@@ -117,45 +119,31 @@ git remote add upstream https://github.com/AOSSIE-Org/PictoPy
117119
cd sync-microservice
118120
```
119121
120-
2. **Set Up a Virtual Environment (Highly Recommended):** Virtual environments isolate project dependencies. Create one using:
121-
122-
Bash(Linux/MacOS)
122+
2. **Create a Conda Environment:** Create a new conda environment with Python 3.12:
123123
124-
```
125-
python3 -m venv .sync-env
126-
```
127-
128-
Powershell(Windows)
124+
Bash/Powershell
129125
130126
```
131-
python -m venv .sync-env
127+
conda create -p .sync-env python=3.12
132128
```
133129
134-
3. **Activate the Virtual Environment:**
130+
3. **Activate the Conda Environment:**
135131
136-
Bash(Linux/MacOS)
137-
138-
```
139-
source .sync-env/bin/activate
140-
```
141-
142-
Powershell(Windows)
132+
Bash/Powershell
143133
144134
```
145-
.sync-env\Scripts\Activate.ps1
135+
conda activate ./.sync-env
146136
```
147137
148-
After activating, you should be able to see the virtual environment's name before the current path.
149-
150138
4. **Install Dependencies:** The `requirements.txt` file lists required packages. Install them using pip:
151139
152-
Bash
140+
Bash/Powershell
153141
154142
```
155143
pip install -r requirements.txt
156144
```
157145
158-
5. **Running the sync-microservice:** To start the sync-microservice in development mode, run this command while being in the sync-microservice folder and the virtual environment activated:
146+
5. **Running the sync-microservice:** To start the sync-microservice in development mode, run this command while being in the sync-microservice folder and the conda environment activated:
159147
160148
Bash/Powershell
161149

sync-microservice/app/logging/setup_logging.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,16 @@ def emit(self, record: logging.LogRecord) -> None:
251251
# Create a message that includes the original module in the format
252252
msg = record.getMessage()
253253

254-
# Find the appropriate logger
255-
logger = get_logger(module_name)
256-
257-
# Log the message with our custom formatting
258-
logger.log(record.levelno, f"[uvicorn] {msg}")
254+
record.msg = f"[{module_name}] {msg}"
255+
record.args = ()
256+
# Clear exception / stack info to avoid duplicate traces
257+
record.exc_info = None
258+
record.stack_info = None
259+
260+
root_logger = logging.getLogger()
261+
for handler in root_logger.handlers:
262+
if handler is not self:
263+
handler.handle(record)
259264

260265

261266
def configure_uvicorn_logging(component_name: str) -> None:

sync-microservice/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
app.include_router(folders.router, prefix="/folders", tags=["Folders"])
4343

4444
if __name__ == "__main__":
45-
logger.info("Starting PictoPy Sync Microservice from main...")
45+
logger.info("Starting PictoPy Sync Microservice")
4646

4747
# Create config with log_config=None to disable Uvicorn's default logging
4848
config = Config(
4949
app=app,
50-
host="0.0.0.0",
50+
host="localhost",
5151
port=52124,
5252
log_level="info",
5353
log_config=None, # Disable uvicorn's default logging config

0 commit comments

Comments
 (0)