Skip to content

Commit

Permalink
updated config path
Browse files Browse the repository at this point in the history
  • Loading branch information
SongminYu committed Jan 9, 2024
1 parent 781aad9 commit 17df61f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
6 changes: 4 additions & 2 deletions tests/behavior/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from models.behavior.main import gen_household_profiles
from models.behavior.main import gen_person_profiles
from plotters.behavior.person_activity_share import person_activity_share
Expand All @@ -6,14 +8,14 @@


def run_flex_behavior_model(project_name: str):
config = Config(project_name=project_name)
config = Config(project_name=project_name, project_path=os.path.dirname(__file__))
init_project_db(config)
gen_person_profiles(config)
gen_household_profiles(config)


def run_flex_behavior_plotter(project_name: str):
config = Config(project_name=project_name)
config = Config(project_name=project_name, project_path=os.path.dirname(__file__))
person_activity_share(config, person_types=[1, 2, 3, 4], day_types=[1, 2])


Expand Down
4 changes: 2 additions & 2 deletions tests/community/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ def copy_household_ref_hour(


def run_flex_community_model(project_name: str):
config = Config(project_name=project_name)
config = Config(project_name=project_name, project_path=os.path.dirname(__file__))
init_project_db(config)
run_community_model(config)


def run_flex_community_plotter(project_name: str):
config = Config(project_name=project_name)
config = Config(project_name=project_name, project_path=os.path.dirname(__file__))
aggregator_profit(config)
p2p_trading_amount(config, id_scenario=1)
battery_operation(config, id_scenario=1)
Expand Down
6 changes: 3 additions & 3 deletions tests/operation/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def generate_params_combination_df(params_values: Dict[str, List[int]]) -> pd.Da


def run_flex_operation_model(project_name: str):
config = Config(project_name=project_name)
config = Config(project_name=project_name, project_path=os.path.dirname(__file__))
init_project_db(config)
run_operation_model(config=config, save_hour=True, scenario_ids=[1])
# run_operation_model_parallel(config=config, task_num=8, save_hour=True)
run_operation_model_parallel(config=config, task_num=8, save_hour=True)


def run_flex_operation_plotter(project_name: str):
config = Config(project_name=project_name)
config = Config(project_name=project_name, project_path=os.path.dirname(__file__))
household_load_balance(config, scenario_ids=[1])


Expand Down
13 changes: 4 additions & 9 deletions utils/config.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import logging
import os


class Config:

def __init__(self, project_name: str):
def __init__(self, project_name: str, project_path: str):
self.root = os.path.abspath(os.curdir)
self.project_name: str = project_name
self.project_path: str = project_path
self.input = self.create_folder("input")
self.output = self.create_folder("output")
self.figure = self.create_folder("output/figure")
self.task_id = None
self.task_output = None
# self.config_logging()

@staticmethod
def create_folder(path: str):
def create_folder(self, path: str):
path = os.path.join(self.project_path, path)
if not os.path.exists(path):
os.makedirs(path)
return path
Expand All @@ -27,10 +26,6 @@ def set_task_id(self, task_id: int) -> "Config":
os.makedirs(self.task_output)
return self

@staticmethod
def config_logging():
logging.getLogger("pyomo.core").setLevel(logging.ERROR)

def make_copy(self) -> "Config":
rk = self.__class__(self.project_name)
for k, v in self.__dict__.items():
Expand Down

0 comments on commit 17df61f

Please sign in to comment.