Skip to content

Commit

Permalink
Adjustments (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: Mostafa Elgayar <[email protected]>
  • Loading branch information
matsch845 and Elgayar authored Jun 12, 2024
1 parent 73633b1 commit 29e6c15
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/security-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Security Check
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
security_check:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ It is recommended to run the backend in a virtual environment.
In the project root, run to create the conda environment and install all required packages.

```bash
conda env create -f environment.yml && conda activate chargify
conda env create -f environment.yml && conda activate aip-porsche
```

To start the backend API, move into the api directory (`cd api/app`) and run
Expand Down
1 change: 1 addition & 0 deletions api/app/core/charging_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def get_soc_curve_from_commutes(
(soc_curve.index > last_trip_end) & (soc_curve.index <= trip_start)
].index:
soc_curve.at[i] = current_soc

last_trip_end = trip_end
mask = (soc_curve.index > trip_start) & (
soc_curve.index < trip_end + timedelta(hours=1)
Expand Down
10 changes: 9 additions & 1 deletion api/app/routers/schedule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pathlib
import sys
import pytz

base_path = pathlib.Path(__file__).parents[3]
sys.path.append(str(base_path))
Expand Down Expand Up @@ -68,11 +69,18 @@ async def get_schedule(
energy_mix = prediction.pd_dataframe()
energy_mix = energy_mix.reset_index()

timezone = pytz.timezone("Europe/Berlin") # hard coded to Germany (for now)

# calculate charging windows
soc_curve = get_soc_curve_from_commutes(
commutes,
datetime(
datetime.now().year, datetime.now().month, datetime.now().day, 0, 0, 0
datetime.now(timezone).year,
datetime.now(timezone).month,
datetime.now(timezone).day,
0,
0,
0,
),
initial_soc,
car,
Expand Down
7 changes: 4 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:
- parso=0.8.4
- pexpect=4.9.0
- pickleshare=0.7.5
- pip=24.0
- pip=23.3.2
- prompt-toolkit=3.0.42
- ptyprocess=0.7.0
- pure_eval=0.2.2
Expand Down Expand Up @@ -59,7 +59,7 @@ dependencies:
- cython==3.0.10
- darts==0.29.0
- dnspython==2.6.1
- fastapi==0.109.0
- fastapi==0.111.0
- fastapi-camelcase==2.0.0
- filelock==3.14.0
- firebase-admin==6.3.0
Expand Down Expand Up @@ -124,12 +124,13 @@ dependencies:
- pyyaml==6.0.1
- requests==2.31.0
- rsa==4.9
- safety==3.2.0
- scikit-learn==1.4.2
- scipy==1.13.0
- shap==0.45.1
- slicer==0.0.8
- sniffio==1.3.1
- starlette==0.35.1
- starlette==0.37.2
- statsforecast==1.7.4
- statsmodels==0.14.2
- sympy==1.12
Expand Down
12 changes: 5 additions & 7 deletions frontend/src/components/CommuteForm/CommuteForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export default function CommuteForm() {
mutators={{ ...arrayMutators }}
initialValues={{
isRoundTrip: false,
usage: [],
approxDistanceKm: 0,
approxDurationMinutes: 0,
usage: [{}],
traffic: "LOW",
}}
render={({ handleSubmit, form }) => (
Expand All @@ -54,7 +52,7 @@ export default function CommuteForm() {
{({ input }) => (
<FormControl>
<FormLabel>User ID</FormLabel>
<Input {...input} type="text" />
<Input required {...input} type="text" />
</FormControl>
)}
</Field>
Expand All @@ -63,7 +61,7 @@ export default function CommuteForm() {
{({ input }) => (
<FormControl>
<FormLabel>Commute Name</FormLabel>
<Input {...input} type="text" />
<Input required {...input} type="text" />
</FormControl>
)}
</Field>
Expand All @@ -81,15 +79,15 @@ export default function CommuteForm() {
{({ input }) => (
<FormControl>
<FormLabel>Approximate Distance (km)</FormLabel>
<Input {...input} />
<Input required {...input} />
</FormControl>
)}
</Field>
<Field name="approxDurationMinutes" type="number">
{({ input }) => (
<FormControl>
<FormLabel>Approximate Duration (minutes)</FormLabel>
<Input {...input} />
<Input required {...input} />
</FormControl>
)}
</Field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default function UsageArrayField() {
<HStack key={name} mb={3}>
<Field name={`${name}.day`} component="select">
{({ input }) => (
<Select {...input}>
<option>Select day</option>
<Select required {...input}>
<option value="">Select day</option>
<option value="MON">Monday</option>
<option value="TUE">Tuesday</option>
<option value="WED">Wednesday</option>
Expand All @@ -34,11 +34,11 @@ export default function UsageArrayField() {
</Field>

<Field name={`${name}.startTime`} component="input" type="time">
{({ input }) => <Input {...input} />}
{({ input }) => <Input required {...input} />}
</Field>

<Field name={`${name}.endTime`} component="input" type="time">
{({ input }) => <Input {...input} />}
{({ input }) => <Input required {...input} />}
</Field>

<Button onClick={() => fields.remove(index)}>
Expand Down
4 changes: 3 additions & 1 deletion model/inference/smard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests
import logging
import pytz
from datetime import datetime, timedelta

import pandas as pd
Expand All @@ -12,7 +13,8 @@

def get_week_start_dates_until_cutoff(n_lookback):
"""Returns a list of the start dates of weeks from now until the given cutoff date at 00:00:00"""
current_date = datetime.now()
timezone = pytz.timezone("Europe/Berlin") # hard coded to Germany (for now)
current_date = datetime.now(timezone)
current_date = current_date.replace(
hour=0, minute=0, second=0, microsecond=0
) # Start from beginning of today
Expand Down

0 comments on commit 29e6c15

Please sign in to comment.