Skip to content

Commit ec9bbae

Browse files
committed
file fix
1 parent e5436db commit ec9bbae

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
python-version: '3.12.5' # Specify Python version (e.g., '3.9')
2727

2828
# Install dependencies (you can specify requirements.txt or pyproject.toml)
29-
- name: Install dependencies and move to the test folder
29+
- name: Install dependencies
3030
run: |
3131
python -m pip install --upgrade pip
3232
pip install pytest pandas numpy entsoe-py redis tensorflow scikit-learn sphinx

codegreen_core/utilities/log.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# to log stuff
2+
3+
from .config import Config
4+
from datetime import datetime
5+
import os
6+
import csv
7+
8+
9+
def time_prediction(data):
10+
if Config.get("enable_time_prediction_logging")==True:
11+
current_date = datetime.now()
12+
file_name = f"{current_date.strftime('%B')}_{current_date.year}.csv"
13+
file_location = os.path.join(Config.get("time_prediction_log_folder_path"), file_name)
14+
file_exists = os.path.exists(file_location)
15+
# Open the file in append mode
16+
with open(file_location, mode='a', newline='') as file:
17+
writer = csv.DictWriter(file, fieldnames=data.keys())
18+
# If the file doesn't exist, write the header
19+
if not file_exists:
20+
writer.writeheader()
21+
# Append the data to the file
22+
writer.writerow(data)
23+
else:
24+
print("Logging not enabled")

0 commit comments

Comments
 (0)