Skip to content

Commit

Permalink
Create seprate poetry folders.
Browse files Browse the repository at this point in the history
  • Loading branch information
spahrenk committed Nov 7, 2024
1 parent c974bc2 commit 1484ef1
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cmake/poetry-install.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# run 'poetry install' in python folder

macro(install_poetry)
macro(poetry_install pythonScriptDir)

# execute 'poetry install'
set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python")
#set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python")
if (NOT ${PROJECT_NAME}_PYTHON_SETUP)
execute_process(
COMMAND poetry install
Expand Down
2 changes: 1 addition & 1 deletion scripts/python/data_model/build_data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def generate(repo_dir, data_model_dir, gen_out_dir):
# main
if __name__ == "__main__":

repo_dir = "../../"
repo_dir = "../../../"
data_model_dir = ""
gen_out_dir = ""
n_args = len(sys.argv) - 1
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ add_custom_target(${PROJECT_NAME}_version_header
set_target_properties(${PROJECT_NAME}_version_header PROPERTIES FOLDER Dependencies/HPWHsim)

#generate hpwh-data-model source
set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python")
set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python/data_model")
set(dataModelDir "${PROJECT_SOURCE_DIR}/vendor/hpwh_data_model")
set(genCodeDir "${PROJECT_SOURCE_DIR}/src/hpwh_data_model")

include(poetry-install)
install_poetry()
poetry_install(${pythonScriptDir})
execute_process(
COMMAND ${CMAKE_COMMAND} -E make_directory "${dataModelDir}"

COMMAND ${GIT_EXECUTABLE} submodule update --init "${dataModelDir}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT

COMMAND poetry run python "data_model/build_data_model.py" "${PROJECT_SOURCE_DIR}" "${dataModelDir}" "${genCodeDir}"
COMMAND poetry run python "build_data_model.py" "${PROJECT_SOURCE_DIR}" "${dataModelDir}" "${genCodeDir}"
WORKING_DIRECTORY "${pythonScriptDir}"
RESULT_VARIABLE result1
ERROR_VARIABLE errors1
Expand Down
13 changes: 6 additions & 7 deletions src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3326,7 +3326,6 @@ void HPWH::initPreset(const std::string& modelName)
#ifndef HPWH_ABRIDGED
void HPWH::readFileAsJSON(string modelName, nlohmann::json& j)
{

std::string configFile = modelName + ".txt";

setAllDefaults(); // reset all defaults if you're re-initializing
Expand All @@ -3341,10 +3340,12 @@ void HPWH::readFileAsJSON(string modelName, nlohmann::json& j)
name = modelName;

nlohmann::json j_tank({});
nlohmann::json j_heatsourceconfigs = nlohmann::json::array({});
// some variables that will be handy
std::size_t heatsource, sourceNum, nTemps, tempInt;
std::size_t num_nodes = 0, numHeatSources = 0;
nlohmann::json j_heatsourceconfigs;

std::size_t heatsource, sourceNum, tempInt;
std::size_t num_nodes = 0;
std::size_t numHeatSources = 0;
std::size_t nTemps = 0;

string tempString, units;
double tempDouble;
Expand Down Expand Up @@ -4084,8 +4085,6 @@ void HPWH::readFileAsJSON(string modelName, nlohmann::json& j)

void HPWH::initFromFileJSON(nlohmann::json& j)
{

// std::cout << j.dump(2) << "\n";
auto& j_tank = j["tank"];
auto& j_heatsourceconfigs = j["heat_source_configurations"];

Expand Down
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ list(REMOVE_DUPLICATES extendedModelNames)
cmake_dependent_option(${PROJECT_NAME}_PYTHON_PLOTS "Generate plots using python comparing measured and simulated data" ON "${PROJECT_NAME}_IS_TOP_LEVEL" OFF)

if (${PROJECT_NAME}_PYTHON_PLOTS)
set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python/plotting")
include(poetry-install)
install_poetry()
poetry_install(${pythonScriptDir})
endif ()

#Tests for successful runs
Expand Down

0 comments on commit 1484ef1

Please sign in to comment.