Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding loopTool to analysis tools #1098

Merged
merged 53 commits into from
Sep 13, 2023
Merged

Conversation

avdudchenko
Copy link
Contributor

Fixes/Resolves:

This is PR includes the complete loopTool that uses current WaterTAP parametr sweep tool.

The PR includes the full loopTool and documentation.
-Support parameter sweeps
-Support differential parameter sweeps

Currently, the loopTool is not setup to run tests in parallel due to ongoing work of adding a parallel manager, this will need to be updated later on.

(replace this with the issue # fixed or resolved, if no issue exists then a brief statement of what this PR does)

Summary/Motivation:

Changes proposed in this PR:

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

else:
return {key: loop_value}

def setup_multi_processing(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the parallel manager to setup parallel computing. It has logic for how to handle concurrent futures or MPI depending on the user specification and conda environment.

Copy link
Contributor Author

@avdudchenko avdudchenko Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the loopTool, as it needs to know if its running with MPI or not for when handling file saving (e.g. getting rank 0), other wise it setups number of subprocess and passes it to parameter sweep tool, which sets up its own parallel management.
Furthermore, number of subprocesses is only auto defined by looptool, if user does not provide a number them self, as it always opts to run in parallel, this is not the case in parameter sweep tool. We can change this behavior in parametersweep tool (e.g. always revert to multi-processing and auto define number of subprocesses based on available resources). Either way is fine, but the loopTool should not handle the logic for how paramterSweep tool handles multiprocessing, it should just instruct it on what should be done.

@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Patch coverage: 93.81% and no project coverage change.

Comparison is base (3b37c9c) 94.92% compared to head (66574b5) 94.93%.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1098    +/-   ##
========================================
  Coverage   94.92%   94.93%            
========================================
  Files         331      333     +2     
  Lines       32501    32950   +449     
========================================
+ Hits        30852    31280   +428     
- Misses       1649     1670    +21     
Files Changed Coverage Δ
...tertap/tools/analysis_tools/loop_tool/loop_tool.py 93.52% <93.52%> (ø)
...ools/analysis_tools/loop_tool/data_merging_tool.py 93.93% <93.93%> (ø)
...ap/tools/parameter_sweep/parameter_sweep_reader.py 98.90% <96.29%> (-1.10%) ⬇️
...atertap/tools/parallel/parallel_manager_factory.py 93.93% <100.00%> (+0.39%) ⬆️
watertap/tools/parameter_sweep/model_manager.py 93.54% <100.00%> (+11.29%) ⬆️
watertap/tools/parameter_sweep/parameter_sweep.py 96.11% <100.00%> (ø)

☔ View full report in Codecov by Sentry.

📢 Have feedback on the report? Share it here.

@ksbeattie ksbeattie added the Priority:High High Priority Issue or PR label Aug 10, 2023
avdudchenko and others added 4 commits August 14, 2023 15:41
PR#1102 adds managment for num of subprocess for ray io when running on cluster
not really needed can be done in place
Copy link
Contributor

@adam-a-a adam-a-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some comments from a first pass. I didn't go through all the details just yet but plan to do a second, more thorough pass.

docs/technical_reference/tools/loopTool.rst Outdated Show resolved Hide resolved
docs/technical_reference/tools/loopTool.rst Outdated Show resolved Hide resolved
docs/technical_reference/tools/loopTool.rst Outdated Show resolved Hide resolved
docs/technical_reference/tools/loopTool.rst Outdated Show resolved Hide resolved
docs/technical_reference/tools/loopTool.rst Outdated Show resolved Hide resolved
docs/technical_reference/tools/loopTool.rst Outdated Show resolved Hide resolved
docs/technical_reference/tools/loopTool.rst Outdated Show resolved Hide resolved
Comment on lines 148 to 149
"nominal_lb": values["nominal_lb"],
"nominal_ub": values["nominal_ub"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these point to nominal_lb and nominal_ub based on the logic above regarding diff_mode being precentile or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes fixed that in next commit.

avdudchenko and others added 7 commits August 23, 2023 23:39
Co-authored-by: Adam Atia <aatia@keylogic.com>
Co-authored-by: Adam Atia <aatia@keylogic.com>
Co-authored-by: Adam Atia <aatia@keylogic.com>
Co-authored-by: Adam Atia <aatia@keylogic.com>
Co-authored-by: Adam Atia <aatia@keylogic.com>
Co-authored-by: Adam Atia <aatia@keylogic.com>
Comment on lines +112 to +113
# with open("test_expected_diff_directory.yaml", "w") as file:
# documents = yaml.dump(lp.sweep_directory, file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# with open("test_expected_diff_directory.yaml", "w") as file:
# documents = yaml.dump(lp.sweep_directory, file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to leave these in, so its easy to recreate the test file in the future. (You can't really create it manually)...

Copy link
Contributor

@k1nshuk k1nshuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already a big PR so it may be fine to make changes in subsequent PRs.

outputs[key] = model.find_component(pyo_object)
return outputs

def run_parameter_sweep(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of constructing the keyword argument dictionary here and constructing the parameter sweep object, can we call the parameter_sweep function? Same goes for the differential parameter sweep function later in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to use the ps API directly, as some options are not available in parmenter functions (Which IMO should be depreciated, not sure why we even have that). (such as custom_function and custom_function_kwargs).

@ksbeattie ksbeattie requested review from hunterbarber, luohezhiming and lbibl and removed request for luohezhiming September 7, 2023 20:28
Copy link
Contributor

@lbibl lbibl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find notable issues. Approving at this point. Maybe we count on more testing of them in future's practices.

@bknueven bknueven merged commit 196dd4b into watertap-org:main Sep 13, 2023
22 checks passed
lbianchi-lbl pushed a commit to watertap-org/parameter-sweep that referenced this pull request May 1, 2024
* merged LoopTool from Analysis

* updated diff test

* add_diff_fixed_names

* Update loopTool.rst

* Update index.rst

* fixed tests

* Fixing file pathing, using abspath(__file__)

* fixed covecod for diff_spec, and pathing in test files

* switched to useing parallel manager to get mpi config

PRwatertap-org/watertap#1102 adds managment for num of subprocess for ray io when running on cluster

* simplify mpi check

* Remove setup_multi_processing

not really needed can be done in place

* Update docs/technical_reference/tools/loopTool.rst

Co-authored-by: Adam Atia <aatia@keylogic.com>

* Update docs/technical_reference/tools/loopTool.rst

Co-authored-by: Adam Atia <aatia@keylogic.com>

* Update docs/technical_reference/tools/loopTool.rst

Co-authored-by: Adam Atia <aatia@keylogic.com>

* Update docs/technical_reference/tools/loopTool.rst

Co-authored-by: Adam Atia <aatia@keylogic.com>

* Update docs/technical_reference/tools/loopTool.rst

Co-authored-by: Adam Atia <aatia@keylogic.com>

* Update docs/technical_reference/tools/loopTool.rst

Co-authored-by: Adam Atia <aatia@keylogic.com>

* Update docs/technical_reference/tools/loopTool.rst

Co-authored-by: Adam Atia <aatia@keylogic.com>

* update watertap-org/watertap#1 to match new async setup

* updarted tests to reader and small fixes throughout

* added additonal tests

* Update test_data_merging_tool.py

* moved doc to howto as it seems better place for it

* Update index.rst

* Removed legacy code, added additional tests, added MPI test

* Update mpi4py-test.yml

* mpi fix try watertap-org/watertap#1

* Fixing MPI test

* Fixed MPI rank

* Clean up and changes to MPI rank

* update doc and added outputs and tests

* cleaned up sim_csaes and added key tests for yaml config file

* Update mpi4py-test.yml

* Update docs/how_to_guides/how_to_use_loopTool_to_explore_flowsheets.rst

Co-authored-by: Kinshuk Panda <kinshukpanda@gmail.com>

* Update watertap/tools/analysis_tools/loop_tool/loop_tool.py

Co-authored-by: Kinshuk Panda <kinshukpanda@gmail.com>

* Update watertap/tools/analysis_tools/loop_tool/loop_tool.py

Co-authored-by: Kinshuk Panda <kinshukpanda@gmail.com>

* Update docs/how_to_guides/how_to_use_loopTool_to_explore_flowsheets.rst

Co-authored-by: Kinshuk Panda <kinshukpanda@gmail.com>

* Update watertap/tools/analysis_tools/loop_tool/loop_tool.py

Co-authored-by: Kinshuk Panda <kinshukpanda@gmail.com>

* Update watertap/tools/analysis_tools/loop_tool/loop_tool.py

Co-authored-by: Kinshuk Panda <kinshukpanda@gmail.com>

* Update watertap/tools/analysis_tools/loop_tool/loop_tool.py

Co-authored-by: Kinshuk Panda <kinshukpanda@gmail.com>

* Update watertap/tools/analysis_tools/loop_tool/tests/test_loop_tool.py

Co-authored-by: Kinshuk Panda <kinshukpanda@gmail.com>

* updates to loopt tool

* Update test_loop_tool.py

* Update test_loop_tool.py

* Update loop_tool.py

---------

Co-authored-by: Kinshuk Panda <kinshukpanda@gmail.com>
Co-authored-by: bknueven <30801372+bknueven@users.noreply.github.com>
Co-authored-by: Adam Atia <aatia@keylogic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:High High Priority Issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants