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

Added a yml file to build the docker image #74

Merged
merged 19 commits into from
Oct 28, 2024
Merged

Conversation

Unique-Usman
Copy link
Contributor

Create a github action for building and running the docker image.

@etpeterson, hello, how are you doing and how have you been ?

Should we make the github action to build the image and also run it or just building. For running, we will need some data, should we download the data during in the github action or add the data as part of the repository ?

Copy link
Contributor

@etpeterson etpeterson left a comment

Choose a reason for hiding this comment

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

I really like this direction. Just a few comments but I think it's really close already.

.github/workflows/docker-build-and-run.yml Outdated Show resolved Hide resolved
.github/workflows/docker-build-and-run.yml Show resolved Hide resolved
docker run -it --rm --name TF2.4_IVIM-MRI_CodeCollection \
-v ${{ github.workspace }}:/usr/src/app \
-v ${{ github.workspace }}:/usr/app/output \
tf2.4_ivim-mri_codecollection brain.nii.gz brain.bvec brain.bval
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the data are available. We could pull it, but that run would take a while. Maybe we could read a small text file that does just a few fits and takes just a second or two. We really just want to run it to confirm it works, we have other tests to check the actual results.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How to go about the reading the small text file ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps even easier to simulate something. You can generate signals using from utilities.data_simulation.GenerateData import GenerateData. It's done in test_ivim_synthetic.py for example. Then save it to a nifti using the function you wrote, then read the nifti. Maybe just a 10x10x1 or something small and fast. B-values of [0, 50, 100, 200, 500, 1000] with maybe one or two vectors.

.github/workflows/docker-build-and-run.yml Show resolved Hide resolved
@etpeterson
Copy link
Contributor

Create a github action for building and running the docker image.

@etpeterson, hello, how are you doing and how have you been ?

Should we make the github action to build the image and also run it or just building. For running, we will need some data, should we download the data during in the github action or add the data as part of the repository ?

Doing well and thanks for coming back to this. I submitted a review for you.

docker run -it --rm --name TF2.4_IVIM-MRI_CodeCollection \
-v ${{ github.workspace }}:/usr/src/app \
-v ${{ github.workspace }}:/usr/app/output \
tf2.4_ivim-mri_codecollection brain.nii.gz brain.bvec brain.bval
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps even easier to simulate something. You can generate signals using from utilities.data_simulation.GenerateData import GenerateData. It's done in test_ivim_synthetic.py for example. Then save it to a nifti using the function you wrote, then read the nifti. Maybe just a 10x10x1 or something small and fast. B-values of [0, 50, 100, 200, 500, 1000] with maybe one or two vectors.


- name: Save Docker image to a tarball
run: |
docker save -o tf2.4_ivim-mri_codecollection.tar tf2.4_ivim-mri_codecollection
Copy link
Contributor

Choose a reason for hiding this comment

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

These things are large, how about also zipping it.

@etpeterson
Copy link
Contributor

@etpeterson

https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/blob/main/utilities/data_simulation/GenerateData.py#L25

https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/blob/main/tests/IVIMmodels/unit_tests/test_ivim_synthetic.py#L23C4-L23C34

How do we get the ivim_data ?

I'm just saying random but realistic f [0, 1], D [0, 1e-3], D* [0, 1e-1], generate b-value curves from that using the GenerateData that you linked to and the b-values I suggested above. Generate that volume and use that as a test dataset.

@Unique-Usman
Copy link
Contributor Author

@etpeterson, I think I might need your regarding this part. Thank you. I am able to get it.

@etpeterson
Copy link
Contributor

@etpeterson, I think I might need your regarding this part. Thank you. I am able to get it.

Something roughly like this. I haven't tested it but it has the basics.

gd = GenerateData()
f_in = np.random.uniform(low=0, high=1, size=(10, 10, 5))
D_in = np.random.uniform(low=0, high=1e-3, size=(10, 10, 5))
Dp_in = np.random.uniform(low=0, high=1e-1, size=(10, 10, 5))
bvals = [0, 50, 100, 500, 1000]
images = gd.ivim_signal(self, D_in, Dp_in, f_in, S0, bvalues)
save_nii(images)

@Unique-Usman
Copy link
Contributor Author

@etpeterson, I think I might need your regarding this part. Thank you. I am able to get it.

Something roughly like this. I haven't tested it but it has the basics.

gd = GenerateData()
f_in = np.random.uniform(low=0, high=1, size=(10, 10, 5))
D_in = np.random.uniform(low=0, high=1e-3, size=(10, 10, 5))
Dp_in = np.random.uniform(low=0, high=1e-1, size=(10, 10, 5))
bvals = [0, 50, 100, 500, 1000]
images = gd.ivim_signal(self, D_in, Dp_in, f_in, S0, bvalues)
save_nii(images)

Did something similay earlier. Apparently the error seems to come from GenerateData due to shape imcompability.

https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/blob/main/utilities/data_simulation/GenerateData.py#L56

https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/blob/main/utilities/data_simulation/GenerateData.py#L141

@etpeterson
Copy link
Contributor

@etpeterson, I think I might need your regarding this part. Thank you. I am able to get it.

Something roughly like this. I haven't tested it but it has the basics.

gd = GenerateData()
f_in = np.random.uniform(low=0, high=1, size=(10, 10, 5))
D_in = np.random.uniform(low=0, high=1e-3, size=(10, 10, 5))
Dp_in = np.random.uniform(low=0, high=1e-1, size=(10, 10, 5))
bvals = [0, 50, 100, 500, 1000]
images = gd.ivim_signal(self, D_in, Dp_in, f_in, S0, bvalues)
save_nii(images)

Did something similay earlier. Apparently the error seems to come from GenerateData due to shape imcompability.

https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/blob/main/utilities/data_simulation/GenerateData.py#L56

https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/blob/main/utilities/data_simulation/GenerateData.py#L141

What's the error specifically? I'm not sure if I've ever tried GenerateData with multiple values at a time, but it doesn't seem like the lines you linked should be causing problems.

@Unique-Usman
Copy link
Contributor Author

Screenshot from 2024-08-30 06-12-39

@Unique-Usman
Copy link
Contributor Author

assert D >= 0, 'D must be >= 0'

@etpeterson
Copy link
Contributor

etpeterson commented Aug 30, 2024

assert D >= 0, 'D must be >= 0'

Ok, so this assert is correct except that it should be in numpy format, so assert np.all(D>=0).

@Unique-Usman
Copy link
Contributor Author

Unique-Usman commented Sep 1, 2024

So, I made this changes, but, it seems there are multiple bugs in the GenerateData.py.
Screenshot from 2024-09-01 23-14-49

@etpeterson
Copy link
Contributor

So, I made this changes, but, it seems there are multiple bugs in the GenerateData.py.
Screenshot from 2024-09-01 23-14-49

Could be, but hard to tell just from that. Your inputs are all the same size?

@etpeterson
Copy link
Contributor

Hey, just checking - are you still working on this?

@Unique-Usman
Copy link
Contributor Author

@etpeterson, I have resumed working on it, should get back in few minutes.

… for generating the sample data. Zipped the docker image generated. Make changes to nifit_wrapper to use 4, 4
@Unique-Usman
Copy link
Contributor Author

@etpeterson kindly go through this whenever you are chanced.

Copy link
Contributor

@etpeterson etpeterson left a comment

Choose a reason for hiding this comment

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

Looking good. A few more comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is 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.

Some erroneus files, will remove it.

import nibabel as nib
from utilities.data_simulation.GenerateData import GenerateData

def save_nii(data, filename='ivim_image.nii.gz'):
Copy link
Contributor

Choose a reason for hiding this comment

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

There's already a save_nifti_file in the wrapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of this file? It looks like it generates an image but I don't see it being used for anything. I was expecting to see the simulated image and associated files generated by this.

Copy link
Contributor Author

@Unique-Usman Unique-Usman Sep 26, 2024

Choose a reason for hiding this comment

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

This is the code I used for generating the signal which I was using for the docker. I did not make use of it because I already generated the images. I will restructured it to generate the images on the fly thereby making use of it in the build process.

Copy link
Contributor

Choose a reason for hiding this comment

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

This and the associated bval and bvec files are inside the docker folder, so they're getting added to the docker image. We don't want that. Also, shouldn't they be generated on the fly rather than be pre-generated?

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 will generate it on the fly, I thought it makes sense having it constant.


- name: Run Docker container
run: |
docker run --rm --name TF2.4_IVIM-MRI_CodeCollection \
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 confirm that images are actually generated. Maybe not the exact values in the images, but even that the files we expect exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, exactly.

@Unique-Usman Unique-Usman force-pushed the main branch 2 times, most recently from 056deca to 7b2f0b8 Compare September 26, 2024 11:38
@Unique-Usman
Copy link
Contributor Author

@etpeterson, kindly take a look.

Copy link
Contributor

@etpeterson etpeterson left a comment

Choose a reason for hiding this comment

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

Looking good, really just those few changes and the question about the docker file artifact.

.github/workflows/docker-build-and-run.yml Show resolved Hide resolved
.github/workflows/docker-build-and-run.yml Outdated Show resolved Hide resolved
uses: actions/upload-artifact@v4
with:
name: docker-image
path: tf2.4_ivim-mri_codecollection.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not seeing why, but the artifact is empty. I wonder if it's too big? If there's no way to save it perhaps it could be split or maybe we just forget about saving the file for now.

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 will check this and verify.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@etpeterson, I think it is there, where are you checking
Screenshot From 2024-10-01 05-29-09

Copy link
Contributor

@etpeterson etpeterson Oct 2, 2024

Choose a reason for hiding this comment

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

A whole docker image is not 198 bytes. If you download it and unzip it you'll find it empty. Also, no space left on device:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@etpeterson, any suggested solution ?

Copy link
Contributor

Choose a reason for hiding this comment

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

You could try a cleaning
- name: Cleanup Docker run: | docker system prune -a --force

You could also try alpine linux base. I think it's smaller but might not work correctly.

If neither of those works then let's build and test but not push.

…e the uploading of the docker to artifact below docker run verification
@Unique-Usman Unique-Usman force-pushed the main branch 2 times, most recently from c8e45e8 to c6a787d Compare October 21, 2024 07:31
@Unique-Usman
Copy link
Contributor Author

@etpeterson, both approach did not work. When I did the cleanup, I was still getting empty files. Also, the alpine base does not support the use of torch which is part of the requirement. So, I am removing the push component

@etpeterson
Copy link
Contributor

@etpeterson, both approach did not work. When I did the cleanup, I was still getting empty files. Also, the alpine base does not support the use of torch which is part of the requirement. So, I am removing the push component

Ok, seems like that's not possible then. You're still trying to upload the docker image though.
image

Also, please don't rewrite the history like you did with force pushes. It make it really hard to review because I can't see what you had before and what my previous comments relate to.

@Unique-Usman
Copy link
Contributor Author

Unique-Usman commented Oct 22, 2024

@etpeterson, both approach did not work. When I did the cleanup, I was still getting empty files. Also, the alpine base does not support the use of torch which is part of the requirement. So, I am removing the push component

Ok, seems like that's not possible then. You're still trying to upload the docker image though. image

My bad, I thought I removed this. I should have verfied in the actions.

Also, please don't rewrite the history like you did with force pushes. It make it really hard to review because I can't see what you had before and what my previous comments relate to.

I am sorry for this, I was avoiding this also.

@etpeterson etpeterson merged commit 5c217fc into OSIPI:main Oct 28, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants