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

Snapshot computation #101

Merged
merged 55 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
59602c6
Initial commit for snapshot commputation
tjwsch Apr 4, 2024
577ab9d
Snapshot: change import of module
tjwsch Apr 4, 2024
32732c5
Adapt SnapshotComputation further
tjwsch Apr 5, 2024
87e0a36
Adapt Snapshot test
tjwsch Apr 5, 2024
8889fab
Snapshot: Formatting
tjwsch Apr 15, 2024
2468c37
Prepare Snapshot class further
tjwsch Apr 22, 2024
bea7c94
First working version of snapshot computation
tjwsch May 3, 2024
11591d8
Add snapshot test, improve snapshot and restructure
tjwsch May 7, 2024
4ff34c5
Add snapshot test, improve snapshot and restructure part 2
tjwsch May 7, 2024
e2cf6f0
Improve logging, comments and minor structural improvements
tjwsch May 8, 2024
a0d6ad5
Snapshot: extend setup and github actions
tjwsch May 13, 2024
cd4cfda
Move Snapshot into Micro Manager and update execution
tjwsch May 29, 2024
9c4d87a
Add post-processing script option and restructure snapshot example
tjwsch May 29, 2024
0f85490
Add post-processing to snapshot config file
tjwsch Jun 4, 2024
f79ecc4
Make snapshot executable and rename snapshot files
tjwsch Jun 9, 2024
c2ee68f
Restructure snapshot computation
tjwsch Jun 12, 2024
6d7ce89
Restructure config
tjwsch Jun 12, 2024
2b1a32f
Update snapshot computation still without chunking
tjwsch Jun 13, 2024
0f5a388
Remove unintentional print statement
tjwsch Jun 13, 2024
8c3dd6f
Update comments in tests
tjwsch Jun 13, 2024
722e84d
Read only the necessary input on each process
tjwsch Jun 13, 2024
2fb49a1
Clarify text and names
tjwsch Jun 14, 2024
350afa8
Add HDF5 dependency
tjwsch Jun 14, 2024
ba68ecd
Make h5py optional dependency
tjwsch Jun 18, 2024
a6697cb
Fix h5py optional
tjwsch Jun 18, 2024
3ac7f5c
Initial commit for snapshot commputation
tjwsch Apr 4, 2024
71506f7
Snapshot: change import of module
tjwsch Apr 4, 2024
948380c
Adapt SnapshotComputation further
tjwsch Apr 5, 2024
c535a34
Snapshot: Formatting
tjwsch Apr 15, 2024
f618eb5
Prepare Snapshot class further
tjwsch Apr 22, 2024
58bb33f
First working version of snapshot computation
tjwsch May 3, 2024
abeb932
Add snapshot test, improve snapshot and restructure
tjwsch May 7, 2024
b00d586
Add snapshot test, improve snapshot and restructure part 2
tjwsch May 7, 2024
bc1b40e
Improve logging, comments and minor structural improvements
tjwsch May 8, 2024
048b32a
Move Snapshot into Micro Manager and update execution
tjwsch May 29, 2024
ec700a7
Add post-processing script option and restructure snapshot example
tjwsch May 29, 2024
cd20df9
Make snapshot executable and rename snapshot files
tjwsch Jun 9, 2024
c6f5f74
Restructure snapshot computation
tjwsch Jun 12, 2024
97d113e
Restructure config
tjwsch Jun 12, 2024
487a8cb
Update snapshot computation still without chunking
tjwsch Jun 13, 2024
6901039
Remove unintentional print statement
tjwsch Jun 13, 2024
e41dadf
Update comments in tests
tjwsch Jun 13, 2024
5c43a9b
Make h5py optional dependency
tjwsch Jun 18, 2024
5b5eca9
Fix h5py optional
tjwsch Jun 18, 2024
282d8b5
Change snapshot case in main
tjwsch Jul 9, 2024
b0466ba
Move dt to simulation parameters in Snapshot and snapshot specific dt
tjwsch Jul 11, 2024
b39c659
Fix init
tjwsch Jul 11, 2024
9557483
Merge branch 'develop' into snapshot_computation
IshaanDesai Jul 23, 2024
338d0fa
Fix issue of using member variable in Config class
IshaanDesai Jul 23, 2024
ae5bbdd
Fix tests
IshaanDesai Jul 23, 2024
bb0dec6
Apply suggestions from code review
tjwsch Jul 24, 2024
4611922
Apply review suggestions
tjwsch Jul 24, 2024
d78bdeb
Remove output dir from gitignore
tjwsch Jul 24, 2024
a7beda7
Extend CHANGELOG.md
tjwsch Jul 25, 2024
8d43edd
Update CHANGELOG.md
tjwsch Jul 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,42 @@ jobs:
apt-get -qq install python3-dev python3-pip git python-is-python3 pkg-config
pip3 install --upgrade pip

- name: Install Micro Manager and uninstall pyprecice
working-directory: micro-manager
- name: Install Micro Manager and run micro_manager unit test
working-directory: micro-manager/
run: |
pip3 install --user .
pip3 uninstall -y pyprecice
cd tests/unit
python3 -m unittest test_micro_manager.py

- name: Install Micro Manager and run interpolation unit test
working-directory: micro-manager/
run: |
pip3 install --user .[sklearn]
pip3 uninstall -y pyprecice
cd tests/unit
python3 -m unittest test_interpolation.py

- name: Run micro_manager unit test
working-directory: micro-manager/tests/unit
run: python3 -m unittest test_micro_manager.py
- name: Install Micro Manager and run micro simulation crash unit test
working-directory: micro-manager/
run: |
pip3 install --user .
pip3 uninstall -y pyprecice
cd tests/unit
python3 -m unittest test_micro_simulation_crash_handling.py

- name: Run interpolation unit test
working-directory: micro-manager/tests/unit
run: python3 -m unittest test_interpolation.py
- name: Install Micro Manager and run HDF5 read and write unit tests
working-directory: micro-manager/
run: |
pip3 install --user .[snapshot]
pip3 uninstall -y pyprecice
cd tests/unit
python3 -m unittest test_hdf5_functionality.py

- name: Run micro simulation crash unit test
working-directory: micro-manager/tests/unit
run: python3 -m unittest test_micro_simulation_crash_handling.py
- name: Install Micro Manager and run snapshot_computation unit tests
working-directory: micro-manager/
run: |
pip3 install --user .[snapshot]
pip3 uninstall -y pyprecice
cd tests/unit
python3 -m unittest test_snapshot_computation.py
3 changes: 3 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ precice-events/
# PyCharm related files
.idea
__pycache__

# Snapshot results
output/
tjwsch marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions examples/clean-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ rm -rfv precice-profiling/
rm -fv *-events.json
rm -fv cpp-dummy/micro-manager.log
rm -fv cpp-dummy/micro_dummy.cpython-310-x86_64-linux-gnu.so
rm -r -fv snapshot-example/output
rm -fv snapshot-example/*.log
Binary file added examples/parameter.hdf5
Binary file not shown.
17 changes: 17 additions & 0 deletions examples/snapshot-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"micro_file_name": "python-dummy/micro_dummy",
"coupling_params": {
"parameter_file_name": "parameter.hdf5",
"read_data_names": {"macro-scalar-data": "scalar", "macro-vector-data": "vector"},
"write_data_names": {"micro-scalar-data": "scalar", "micro-vector-data": "vector"}
},
"simulation_params": {
"micro_dt": 1.0
},
"snapshot_params": {
"post_processing_file_name": "snapshot_postprocessing"
},
"diagnostics": {
"output_micro_sim_solve_time": "True"
}
tjwsch marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 4 additions & 0 deletions examples/snapshot_postprocessing.py
IshaanDesai marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Postprocessing:
def postprocessing(sim_output):
sim_output["micro-scalar-data"] = sim_output["micro-scalar-data"] + 20
return sim_output
23 changes: 21 additions & 2 deletions micro_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,38 @@
from .config import Config
from .micro_manager import MicroManagerCoupling

try:
from .snapshot.snapshot import MicroManagerSnapshot

is_snapshot_possible = True
except ImportError:
is_snapshot_possible = False


def main():

def main() -> None:
parser = argparse.ArgumentParser(description=".")
parser.add_argument(
"config_file", type=str, help="Path to the JSON config file of the manager."
)
parser.add_argument(
"--snapshot", action="store_true", help="compute offline snapshot database"
)

args = parser.parse_args()
config_file_path = args.config_file
if not os.path.isabs(config_file_path):
config_file_path = os.getcwd() + "/" + config_file_path

manager = MicroManagerCoupling(config_file_path)
if not args.snapshot:
manager = MicroManagerCoupling(config_file_path)
else:
if is_snapshot_possible:
manager = MicroManagerSnapshot(config_file_path)
else:
raise ImportError(
"The Micro Manager snapshot computation requires the h5py package."
)

manager.initialize()

Expand Down
Loading