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

Add separate workflow and dockerfile for conda build #1527

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from

Conversation

bquan0
Copy link
Contributor

@bquan0 bquan0 commented Mar 12, 2024

Description

This is a continuation of the closed PR #1516. In the dockerfile of that PR, we had one stage for installing dependencies via apt and one stage for installing dependencies via conda. However, we decided that it would be best to split up the apt build and the conda build for a few reasons

  • the builds weren't working.
  • When we had apt and conda in one dockerfile, we weren't able to take advantage of the fact that we could install moab, dagmc, and openmc via conda. This structural difference means that it's better to have 2 separate workflows and dockerfiles.

In this PR, I have reverted ubuntu_22.04-dev.dockerfile and docker_publish.yml to what they were 7 months ago, right before any of the conda changes were made. The only change I made was to remove the cython restriction in the dockerfile.

I also added a new conda_build.dockerfile and conda_docker.yml to build and test PyNE by installing packages via conda. It's still a work in progress and I'm open to any feedback about how I can change and improve it.

Motivation and Context

This PR will be the new PR to close #1515.

Changes

This should be a fix to the current situation on develop where conda builds weren't working properly at all. This should also be a better way to implement what #1516 was trying to accomplish.

Behavior

Current behavior is that we try to build PyNE via conda dependencies or apt dependencies in the same workflow/dockerfile. New behavior is that there will be separate workflows/dockerfiles.

Copy link
Contributor

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

Thanks for kicking this off

docker/conda_build.dockerfile Outdated Show resolved Hide resolved
docker/conda_build.dockerfile Outdated Show resolved Hide resolved
docker/conda_build.dockerfile Outdated Show resolved Hide resolved
@ahnaf-tahmid-chowdhury
Copy link
Member

I have a suggestion to make. Recently, while working on the DAGMC CI, I found its implementation to be quite well. Would it be possible for us to apply a similar method here as well? It could make it easier for us to understand all the projects as they would be configured in the same way. In the case of PyNE, we may need to add a few steps to make it compatible with the CI. What do you think, @gonuke? Do you agree, or do you have a better alternative in mind?

@gonuke
Copy link
Contributor

gonuke commented Mar 12, 2024

I think we first need to get some version of this working, and then we can look into improvements. The PyNE build process is different from the DAGMC one for a few reasons and we need to make sure that our CI is meeting our overall needs.

.github/workflows/conda_docker.yml Outdated Show resolved Hide resolved
.github/workflows/conda_docker.yml Outdated Show resolved Hide resolved
docker/ubuntu_22.04-dev.dockerfile Outdated Show resolved Hide resolved
docker/conda_build.dockerfile Outdated Show resolved Hide resolved
Comment on lines +49 to +51
# make starting directory
RUN mkdir -p $HOME/opt
RUN echo "export PATH=$HOME/.local/bin:\$PATH" >> ~/.bashrc

Choose a reason for hiding this comment

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

Not required I suppose. We may set pyne install prefix to conda dir.

Choose a reason for hiding this comment

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

Here is the issue. This should be RUN mkdir -p $HOME/opt/pyne

docker/conda_build.dockerfile Outdated Show resolved Hide resolved
bquan0 and others added 2 commits March 15, 2024 14:25

RUN export PYNE_HDF5_ARGS="" ;\
&& cd $HOME/opt \
&& git clone -b develop --single-branch https://github.com/pyne/pyne.git \

Choose a reason for hiding this comment

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

Please use COPY command here and copy the source to the dockerfile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To apply this change, I have removed the pyne-dev stage. Now, we will build the existing pyne stage in docker_publish.yml since that uses the COPY command.

Copy link
Member

@ahnaf-tahmid-chowdhury ahnaf-tahmid-chowdhury left a comment

Choose a reason for hiding this comment

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

MOAB v5.3 is old and doesn't support Cython v3. We have a separate PR #1528 for this. Please consider using Cython v0.29 for now.

docker/conda_build.dockerfile Outdated Show resolved Hide resolved
docker/ubuntu_22.04-dev.dockerfile Outdated Show resolved Hide resolved
@gonuke
Copy link
Contributor

gonuke commented Mar 20, 2024

The limitation isn't from MOAB. Conda-forge has MOAB 5.5.1

@ahnaf-tahmid-chowdhury
Copy link
Member

Unfortunately, we still need to consider staying with Cython 0.29 for this current PR, as PyNE has issues with Cython 3. This may be resolved through a separate PR #1528.

bquan0 and others added 2 commits March 22, 2024 15:35
Co-authored-by: Ahnaf Tahmid Chowdhury <ahnaf-tahmid@outlook.com>
@ahnaf-tahmid-chowdhury
Copy link
Member

It seems, the action workflows, share similarities. I'm curious if we could potentially use a single action file to select different Docker files, if feasible. I'd like to pass this decision over to @gonuke.

Copy link
Contributor

@gonuke gonuke 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 failing tests because of the inconsistent resolution of $HOME

docker/conda_build.dockerfile Show resolved Hide resolved
@bquan0
Copy link
Contributor Author

bquan0 commented Mar 27, 2024

After running into a bunch of errors (which were fixed by applying the solutions I previously found in the conda-build-fix branch that I forgot about), I'm now running into a "file not found" error when running the tests, which is strange. I did a quick vimdiff between the conda setup that I currently have and the conda setup in conda-build-fix but there weren't any differences other than order of dependencies and not having hdf5<1.14 (since having hdf5 breaks the build).

@gonuke
Copy link
Contributor

gonuke commented Mar 27, 2024

I think something changed with how pytest handles a setup function. @bennibbelink seemed to notice this with Cyclus a few days ago and made a simple fix there that avoided the issue rather than corrected it....

The missing file is downloaded in a setup method that maybe is not being run by pytest?

@ahnaf-tahmid-chowdhury
Copy link
Member

ahnaf-tahmid-chowdhury commented Mar 27, 2024

I'm not sure if this is the problem. I've been working on scikit-build-core and have fixed all the test issues; now all tests are passing. However, I've noticed some UnicodeDecodeError instances and resolved the use of the setup function in two files. @bquan0, could you please try running pytest -ra in the tests folder locally and see what happens?

@bquan0
Copy link
Contributor Author

bquan0 commented Mar 29, 2024

I noticed that the tests were also not working for the original docker_publish.yml where we install dependencies with apt. I think this has to do with the pytest version since they deprecated the setup() and teardown() functions in version 7.2.0. From some initial testing on my laptop with the pytest 8.1.1, it seems like we need to rename these functions into setup_function() and teardown_function().

@bquan0
Copy link
Contributor Author

bquan0 commented Mar 29, 2024

The change to the setup() function seems to have fixed a few of the errors. Also, the most recent commit isn't necessary, I just added it because I thought the setup() function still wasn't running after the rename to setup_function(). In actuality, it was running, but the failed workflow made me think otherwise.

The error that's causing the workflow to fail now has to do with the pyne.ace.ascii_to_binary() function.

The file that is missing is the C12-binary.ace file created by pyne.ace.ascii_to_binary() from C012-n.ace (file imported in the setup() function which now actually runs).

Copy link
Contributor

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

I suggested the change to setup_module() in once place and it should probably propagate to the others.

Our previous usage of setup() assumed that it was called once per module, so we want to ensure that same behavior now, and not once per function. I think (speculation) that using setup_function() and teardown_function() results in teardown happening after each test, thus removing a file generated in one test that is needed for another test. (this practice may have other flaws)

tests/test_ace.py Outdated Show resolved Hide resolved
tests/test_ace.py Outdated Show resolved Hide resolved
@bquan0
Copy link
Contributor Author

bquan0 commented Mar 29, 2024

After applying that change and removing the dec import in test_chainsolve.py (since it is deprecated in newer numpy versions and isn't used in the file), the first BuildTest (only base_python) is passing.

The other BuildTests error out in test_activation_responses.py in the test_response_hdf5_to_mesh() test due to an error with creating a mesh from PyMOAB, which I don't know how to fix.

@gonuke
Copy link
Contributor

gonuke commented Mar 29, 2024

Somethings to try in test_mesh.py:test_structured_mesh_from_coords()

  1. force ranges to be lists in assert_array_equal
  2. loop over elements in list:
for obs, exp in zip(sm.structured_coords, [range(1, 5), range(1, 4), range(1, 3)]):
    assert_array_equal(obs, exp)

@gonuke
Copy link
Contributor

gonuke commented Mar 29, 2024

For conda builds, let's pin the moab version to 5.3.0

@bquan0
Copy link
Contributor Author

bquan0 commented Mar 29, 2024

All of the tests in docker_publish.yml are now passing except for the dagmc + hdf5 test. It's failing in test_activation_responses.py in the test_activation_responses_script() function due to a FileNotFoundError for alara_inp. It seems like a mismatch in hdf5 version might be the cause.

@ahnaf-tahmid-chowdhury
Copy link
Member

Please consider pinning HDF5 to 1.10 not <1.14

@bquan0
Copy link
Contributor Author

bquan0 commented Mar 30, 2024

Big news: the original docker_publish.yml is now working!
Also, I propose that the github workflows for each dockerfile only runs when its respective dockerfile changes (and not when anything in the docker/ folder changes).

Also, I just realized that the 10 in update-alternatives --install /usr/bin/python python /usr/bin/python3 10 refers to the priority of the install, not the version of python. So, I have pinned the python version in conda to <3.10 because moab 5.3.0 doesn't work with python 3.10.

@bquan0
Copy link
Contributor Author

bquan0 commented Mar 30, 2024

After pinning "python<3.10", the moab install works.
After updating conda and using mamba to install dagmc and openmc, those installations also work.

The moab tests are now passing. However, the dagmc and openmc tests are failing due to the same ValueError: Cannot create cython.array from NULL pointer in test_response_hdf5_to_mesh() of test_activation_responses.py that we had with the moab test of the conda build previously (which we solved by pinning the moab version to 5.3.0).

@gonuke
Copy link
Contributor

gonuke commented Mar 30, 2024

The moab tests are now passing. However, the dagmc and openmc tests are failing due to the same ValueError: Cannot create cython.array from NULL pointer in test_response_hdf5_to_mesh() of test_activation_responses.py that we had with the moab test of the conda build previously (which we solved by pinning the moab version to 5.3.0).

This may be because the DAGMC conda package is out of date. I'll have to see to that.

@ahnaf-tahmid-chowdhury
Copy link
Member

I think it's not a good idea to set Python < 3.10 since ubuntu 22.04 comes with Python 3.10.6 which is old now. I will check this on the scikit-build-core branch and try to resolve that there.

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.

conda CI build was never actually relying on conda
3 participants