-
Notifications
You must be signed in to change notification settings - Fork 12
Addition of radio-astronomy use-case #358
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
Merged
Merged
Changes from 75 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
b315069
Add radio-astronomy use case
okrochak b1755f4
radio-astronomy-raw file/dependecies clean-up
okrochak 2b61a67
Update the dependencies for radio-astronomy
okrochak 6ef72af
update lock file
okrochak 05671c1
comment out real data tests
okrochak cc3f35c
Skeleton structure for radio-astronomy integration
bcbc1ac
WIP: radio-astronomy integration
6ef0d73
radio-astronomy inte
okrochak 8dc7eaf
Refactoring some code, added a pipeline.py file to test config.yaml f…
okrochak 99e9900
updated data storage loc for git ignore
64ea1e1
merging from origin/main, keep my uv.lock file
41f56f0
mergen from origin/main
7960c3e
WIP set-up exec-pipeline from config.yaml
f556295
WIP running from config.yaml
52f9e55
additional config files for various networks
okrochak c96a6f8
radio-astronomy integration
okrochak e323381
finalized execution from Hydra config
okrochak ca03dbb
Restructuring radio-astronomy use-case
okrochak 065f619
Fine-tuning of config.yaml for HPC deployment
okrochak 167addb
removed radio-astronomy-raw
okrochak a7535f2
further fixes for multi-node deployment
okrochak 9d83812
WIP radio-astronomy - setting up for HPC/laptop use
okrochak 13a383b
pipeline_methods model loading fix
okrochak 2ee572c
pipeline_methods hotfix
okrochak 193d92d
writing tests for radio-astronomy
okrochak 4b67117
Radio-astronomy use-case
okrochak 58b289a
Pull the latest changes from main before submitting a PR
okrochak fd184f9
adjust for new TorchTrainer.execute() implementation
okrochak b1ca37b
fix documentation warnings and failing radio-astronomy tests due to n…
okrochak b5d05ab
fix title underline too short sphinx warning
okrochak f9fa442
attempt to make radio-astronomy pytests pass on GH
okrochak 764e864
Attempt to make radio-astronomy pytests pass in GH env
okrochak 79a0cd9
attempt to fix failing pytest
okrochak 141de2d
pytest fix
okrochak 8eb9647
responding to Jarl's comments - refactoring of dataset classes into one
okrochak e18492e
"Integration of new PulsarDataset class, updated configuration files"
okrochak f72e59b
responding to Jarl's comments - refactoring of dataset classes into o…
okrochak f27d095
code refactoring
okrochak 5d01de6
Refactoring to remove src/ folder and get use-case dependencies throu…
okrochak d5d54c1
quickfix failing unet test
okrochak 17fbb82
Refactoring with black to match coding style
okrochak eb17b5b
Add optional scaling functionality to trainer and config
okrochak c05e0d4
Update use-case code signatures. Remove binary model files. Include a…
okrochak 6c938bc
test retry
okrochak c608fc5
pytest fix
okrochak 4b79940
update radio-astornomy test suite
okrochak e634cfc
Removed dependency on .test_dataset, had to adjust the test suite
okrochak a7e5d25
test retry
okrochak e25e072
test fix
okrochak 5ac5210
retry tick pipeline
okrochak bea602b
add loadfile to tests
jarlsondre abc789c
added fixtures for tests and updated data.py
okrochak ab0c4cf
Merge branch 'radio-astronomy' of github.com:interTwin-eu/itwinai int…
okrochak 0dc6e46
--dist loadscope attepmt
okrochak eb637d1
retry test fix
okrochak 60eee30
Merge remote-tracking branch 'origin/main' into radio-astronomy
okrochak e239623
test loadfile
okrochak 8566af3
pytest fix retry
okrochak e64c739
update uv.lock
okrochak c47cad6
pytest fix
okrochak 52df3b2
pytest fix
okrochak 445dcd0
pytest fix
okrochak 6f4b5e6
.
okrochak 93de7aa
.
okrochak b72d1c4
.
okrochak 86c45bc
.
okrochak 26880d6
.
okrochak 7a0c645
.
okrochak a9cc5a2
.
okrochak 319f243
.
okrochak 982fb8a
.
okrochak 333e780
.
okrochak fc92c3c
finally fixed pytest issue. Wrong UV error description.
okrochak d94391f
Final fixes to respond to PR comments:
okrochak b29a41c
Inshallah the test shall pass
okrochak 5b3818c
Merge branch 'main' into radio-astronomy
okrochak 573f80b
Added and tested support for deepspeed and horovod
okrochak 3d2999f
Merge branch 'main' into radio-astronomy
okrochak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -28,7 +28,6 @@ mnist-sample-data/ | |
exp_data/ | ||
mnist_dataset/ | ||
|
||
|
||
# Kubernetes | ||
secret*.yaml | ||
|
||
|
This file contains hidden or 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 hidden or 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,58 @@ | ||
Pulsar Segmentation and Analysis for Radio-Astronomy (HTW Berlin) | ||
=============================================================================================== | ||
The code is adapted from | ||
`this repository <https://gitlab.com/ml-ppa/pulsarrfi_nn/-/tree/version_0.2/unet_semantic_segmentation?ref_type=heads>`_. | ||
Please visit the original repository for more technical information on the code. | ||
This use case features a sophisticated pipeline composed of few neural networks. | ||
|
||
Integration Author: Oleksandr Krochak, FZJ | ||
|
||
Environment Management | ||
----------------------------------------------------------------------------------------------- | ||
It is recommended to use the UV environment for running this pipeline. | ||
The overview of itwinai-wide module dependencies can be found in `intertwin/pyproject.toml`. | ||
By running `uv sync --extra devel --extra torch --extra radio-astronomy`, the uv lockfile will | ||
be generated/updated that ensures that correct dependencies are installed. If you want to | ||
change some use-case specific dependencies, please do so in pyproject.toml in the radio-astronomy | ||
section. Afterwards, re-run `uv sync` with the same flags. | ||
|
||
Alternatively, you can install the required dependencies from the use-case directory: | ||
`pip install requirements.txt` | ||
|
||
Running from a configuration file | ||
----------------------------------------------------------------------------------------------- | ||
You can run the full pipeline sequence by executing the following commands locally. | ||
itwinai will read these commands from the `config.yaml` file in the root of the repository. | ||
1. Generate the synthetic data - `itwinai exec-pipeline +pipe_key=syndata_pipeline` | ||
2. Initialize and train a UNet model - `itwinai exec-pipeline +pipe_key=unet_pipeline` | ||
3. Initialize and train a FilterCNN model - `itwinai exec-pipeline +pipe_key=fcnn_pipeline` | ||
4. Initialize and train a CNN1D model - `itwinai exec-pipeline +pipe_key=cnn1d_pipeline` | ||
5. Compile a full pipeline and test it - `itwinai exec-pipeline +pipe_key=evaluate_pipeline` | ||
|
||
When running on HPC, you can use the `batch.sh` SLURM script to run these commands. | ||
|
||
Logging with MLflow | ||
----------------------------------------------------------------------------------------------- | ||
By default, the `config.yaml` ensures that the MLflow logging is enabled during the training. | ||
During or after the run, you can launch an MLflow server by executing | ||
`mlflow server --backend-store-uri mllogs/mlflow` and connecting to `http://127.0.0.1:5000/` | ||
in your browser. | ||
|
||
Test suite | ||
----------------------------------------------------------------------------------------------- | ||
The test suite is located in the `tests/use-cases/radio-astronomy` folder. | ||
|
||
Before running the test suite, you should make sure that the pytorch fixture in: | ||
`tests/use-cases/radio-astronomy/test_radio-astronomy.py`:torch_env() | ||
is correctly defined and corresponds to the virtual environment where itwinai is installed on | ||
your system. | ||
|
||
It contains integration tests for each of the pipelines 1-5 mentioned above. The configuration | ||
and execution of the test suite is defined in: | ||
`tests/use-cases/radio-astronomy/test_radio-astronomy.py` | ||
and in the configuration file in the use-case repository: | ||
`use-cases/radio-astronomy/.config-test.yaml`. | ||
If you are updating the test suite, make sure you update both of these files. | ||
|
||
Feel free to change the pytest markers as needed, but be careful with pushing these changes. | ||
Tests should be able to run in an isolated environment. |
This file contains hidden or 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 hidden or 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
okrochak marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,121 @@ | ||
# -------------------------------------------------------------------------------------- | ||
# Part of the interTwin Project: https://www.intertwin.eu/ | ||
# | ||
# Created by: Alex Krochak | ||
# | ||
# Credit: | ||
# - Alex Krochak <o.krochak@fz-juelich.de> - FZJ | ||
# -------------------------------------------------------------------------------------- | ||
|
||
"""Tests for radio-astronomy use case. | ||
|
||
Intended to be integration tests, to make sure that updates in the code base | ||
do not break use cases' workflows. | ||
|
||
This is meant to be run from the main itwinai directory, not the use-case folder !!! | ||
"pytest use-cases/radio-astronomy/tests/test_radio-astronomy.py" | ||
|
||
NOTE FOR DEVELOPERS: if you are editing this file, make sure that entries in | ||
use-cases/radio-astronomy/.config-test.yaml are updated accordingly !!! | ||
""" | ||
|
||
import os | ||
import subprocess | ||
from pathlib import Path | ||
import shutil | ||
|
||
import pytest | ||
|
||
USECASE_FOLDER = Path("use-cases", "radio-astronomy").resolve() | ||
|
||
@pytest.fixture | ||
def torch_env() -> str: | ||
"""Returns absolute path to torch virtual environment.""" | ||
env_path = Path(os.environ.get("TORCH_ENV", "./.venv")) | ||
return str(env_path.resolve()) | ||
|
||
@pytest.fixture | ||
def syndata(tmp_path, torch_env,install_requirements): | ||
# This fixture implicitly tests the synthetic data generation pipeline | ||
install_requirements(USECASE_FOLDER, torch_env) | ||
|
||
cmd_data = ( | ||
f"{torch_env}/bin/itwinai exec-pipeline --config-name .config-test " | ||
f"+pipe_key=syndata_pipeline ++syndata_test_dir={tmp_path}/ " | ||
) | ||
if len(os.listdir(tmp_path)) == 0: # only run if directory is empty | ||
# Copy the necessary files to the temporary directory for testing | ||
shutil.copy(USECASE_FOLDER / ".config-test.yaml", tmp_path) | ||
shutil.copy(USECASE_FOLDER / "data.py", tmp_path) | ||
shutil.copy(USECASE_FOLDER / "trainer.py", tmp_path) | ||
|
||
subprocess.run(cmd_data.split(), check=True, cwd=tmp_path) | ||
|
||
return tmp_path | ||
|
||
@pytest.fixture | ||
def generate_unet(torch_env, syndata): | ||
"""Generate the U-Net model for the Filter-CNN test. """ | ||
cmd = ( | ||
f"{torch_env}/bin/itwinai exec-pipeline --config-name .config-test " | ||
f"+pipe_key=unet_pipeline ++image_directory={syndata}/ ++mask_directory={syndata}/ " | ||
) | ||
|
||
subprocess.run(cmd.split(), check=True, cwd=syndata) | ||
|
||
# @pytest.mark.skip(reason="dependent on .test_dataset, incoroporated into integration test") | ||
def test_radio_astronomy_unet(torch_env, syndata, install_requirements): | ||
"""Test U-Net Pulsar-DDT trainer by running it end-to-end | ||
via the config-test.yaml configuration file.""" | ||
|
||
install_requirements(USECASE_FOLDER, torch_env) | ||
|
||
cmd = ( | ||
f"{torch_env}/bin/itwinai exec-pipeline --config-name .config-test " | ||
f"+pipe_key=unet_pipeline ++image_directory={syndata}/ ++mask_directory={syndata}/ " | ||
) | ||
|
||
subprocess.run(cmd.split(), check=True, cwd=syndata) | ||
|
||
@pytest.mark.functional | ||
def test_radio_astronomy_filtercnn(torch_env, syndata, generate_unet, install_requirements): | ||
"""Test Filter-CNN Pulsar-DDT trainer by running it end-to-end | ||
via the config-test.yaml configuration file. Requires the U-Net model to be present.""" | ||
|
||
install_requirements(USECASE_FOLDER, torch_env) | ||
|
||
cmd = ( | ||
f"{torch_env}/bin/itwinai exec-pipeline --config-name .config-test " | ||
f"+pipe_key=fcnn_pipeline ++image_directory={syndata}/ ++mask_directory={syndata}/ " | ||
) | ||
|
||
subprocess.run(cmd.split(), check=True, cwd=syndata) | ||
|
||
def test_radio_astronomy_cnn1d(torch_env, syndata, install_requirements): | ||
"""Test CNN-1D Pulsar-DDT trainer by running it end-to-end | ||
via the config-test.yaml configuration file.""" | ||
|
||
install_requirements(USECASE_FOLDER, torch_env) | ||
|
||
cmd = ( | ||
f"{torch_env}/bin/itwinai exec-pipeline --config-name .config-test " | ||
f"+pipe_key=cnn1d_pipeline ++image_directory={syndata}/ ++mask_directory={syndata}/ " | ||
) | ||
|
||
subprocess.run(cmd.split(), check=True, cwd=syndata) | ||
|
||
@pytest.mark.skip(reason="dependent on large real data set") | ||
def test_radio_astronomy_evaluate(torch_env): | ||
"""Test the evaluate pipeline by running it end-to-end | ||
via the config-test.yaml configuration file.""" | ||
|
||
cmd = ( | ||
f"{torch_env}/bin/itwinai exec-pipeline " | ||
f"--config-name .config-test " | ||
f"+pipe_key=evaluate_pipeline " | ||
) | ||
|
||
## Run the pipeline and check file generation in the use-case folder | ||
subprocess.run(cmd.split(), check=True, cwd=USECASE_FOLDER) | ||
## Clean up the use-case folder | ||
subprocess.run("./.pytest-clean", check=True, cwd=USECASE_FOLDER) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.