-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove watertap from required dependencies (#9)
* Add back MPI code that was left over from the migration * Update MPI import paths * Add pytest.importorskip to test_loop_tool.py if ro_setup not importable * Remove watertap from required dependencies * Add unsaved file and format with Black * Streamline logic handling publishing updates based on config value * Change exception type to RuntimeError since check happens at runtime
- Loading branch information
1 parent
e9afcb3
commit 7aa44dc
Showing
11 changed files
with
130 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
################################################################################# | ||
# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, | ||
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, | ||
# National Renewable Energy Laboratory, and National Energy Technology | ||
# Laboratory (subject to receipt of any required approvals from the U.S. Dept. | ||
# of Energy). All rights reserved. | ||
# | ||
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license | ||
# information, respectively. These files are also available online at the URL | ||
# "https://github.com/watertap-org/watertap/" | ||
################################################################################# | ||
|
||
try: | ||
from mpi4py.MPI import * | ||
except ImportError: | ||
from .dummy_mpi import DummyCOMM as COMM_WORLD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
################################################################################# | ||
# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, | ||
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, | ||
# National Renewable Energy Laboratory, and National Energy Technology | ||
# Laboratory (subject to receipt of any required approvals from the U.S. Dept. | ||
# of Energy). All rights reserved. | ||
# | ||
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license | ||
# information, respectively. These files are also available online at the URL | ||
# "https://github.com/watertap-org/watertap/" | ||
################################################################################# | ||
import numpy as np | ||
|
||
|
||
class DummyCOMM: | ||
|
||
rank = 0 | ||
size = 1 | ||
|
||
@staticmethod | ||
def Get_rank(): | ||
return 0 | ||
|
||
@staticmethod | ||
def Get_size(): | ||
return 1 | ||
|
||
@staticmethod | ||
def Barrier(): | ||
pass | ||
|
||
@staticmethod | ||
def Bcast(array, root=0): | ||
pass | ||
|
||
@staticmethod | ||
def bcast(array, root=0): | ||
return array | ||
|
||
@staticmethod | ||
def allgather(value): | ||
return [value] | ||
|
||
@staticmethod | ||
def Gatherv(sendbuf=None, recvbuf=(None, None), root=0): | ||
assert len(recvbuf) == 2 | ||
assert isinstance(recvbuf, tuple) | ||
receive_arr = recvbuf[0] | ||
receive_sizes = recvbuf[1] | ||
|
||
assert isinstance(receive_arr, (np.ndarray, list)) | ||
assert len(receive_arr) == sum(receive_sizes) | ||
receive_arr[:] = sendbuf[:] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
################################################################################# | ||
# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, | ||
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, | ||
# National Renewable Energy Laboratory, and National Energy Technology | ||
# Laboratory (subject to receipt of any required approvals from the U.S. Dept. | ||
# of Energy). All rights reserved. | ||
# | ||
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license | ||
# information, respectively. These files are also available online at the URL | ||
# "https://github.com/watertap-org/watertap/" | ||
################################################################################# | ||
|
||
import pytest | ||
import numpy as np | ||
from parameter_sweep.parallel.MPI.dummy_mpi import DummyCOMM | ||
|
||
|
||
@pytest.mark.integration | ||
def test_dummy_mpi(): | ||
comm = DummyCOMM | ||
rank = comm.Get_rank() | ||
size = comm.Get_size() | ||
|
||
n_arr = 3 | ||
dummy_array1 = np.arange(n_arr) | ||
comm.Bcast(dummy_array1) | ||
returned_array = comm.bcast(dummy_array1) | ||
returned_list = comm.allgather(dummy_array1) | ||
recvbuf = (np.zeros(n_arr), [n_arr]) | ||
comm.Gatherv(sendbuf=dummy_array1, recvbuf=recvbuf, root=0) | ||
|
||
assert comm is DummyCOMM | ||
assert rank == 0 | ||
assert size == 1 | ||
assert returned_array is dummy_array1 | ||
assert returned_list == [dummy_array1] | ||
assert (recvbuf[0] == dummy_array1).all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters