Skip to content

Making wheel 2#69

Open
shimwell wants to merge 160 commits intodevelopfrom
making-wheel-2
Open

Making wheel 2#69
shimwell wants to merge 160 commits intodevelopfrom
making-wheel-2

Conversation

@shimwell
Copy link
Owner

@shimwell shimwell commented Feb 16, 2025

# delete old images
docker rmi openmc_wheel:python3.10 -f
docker rmi openmc_wheel:python3.11 -f
docker rmi openmc_wheel:python3.12 -f

# build manylinux image
docker build -t openmc -f manylinux.Dockerfile .
docker build --no-cache --build-arg Python_ABI=cp310-cp310 --build-arg=OPENMC_USE_DAGMC=ON -t openmc_wheel:python3.10 -f manylinux.Dockerfile .
docker build --no-cache --build-arg Python_ABI=cp311-cp311 --build-arg=OPENMC_USE_DAGMC=ON -t openmc_wheel:python3.11 -f manylinux.Dockerfile .
docker build --no-cache --build-arg Python_ABI=cp312-cp312 --build-arg=OPENMC_USE_DAGMC=ON -t openmc_wheel:python3.12 -f manylinux.Dockerfile .

mkdir wheelhouse
docker create --name openmc_wheel_container_3.10 openmc_wheel:python3.10
docker cp openmc_wheel_container_3.10:/root/openmc/dist/. wheelhouse
docker rm openmc_wheel_container_3.10

docker create --name openmc_wheel_container_3.11 openmc_wheel:python3.11
docker cp openmc_wheel_container_3.11:/root/openmc/dist/. wheelhouse
docker rm openmc_wheel_container_3.11

docker create --name openmc_wheel_container_3.12 openmc_wheel:python3.12
docker cp openmc_wheel_container_3.12:/root/openmc/dist/. wheelhouse
docker rm openmc_wheel_container_3.12

docker build -f wheeltest.Dockerfile --build-arg python_version=3.10 .
docker build -f wheeltest.Dockerfile --build-arg python_version=3.11 .
docker build -f wheeltest.Dockerfile --build-arg python_version=3.12 .

wheeltest.Dockerfile

FROM ubuntu:24.04

ARG python_version=3.12
ENV python_version_no_dot=${python_version//./}

RUN apt update -y && apt upgrade -y && \
    apt install -y software-properties-common && \
    add-apt-repository ppa:deadsnakes/ppa && \
    apt update -y && \
    apt install -y python${python_version} python${python_version}-venv python3-pip

RUN apt install libhdf5-dev -y

RUN python${python_version} -m venv openmc_venv
ENV PATH=/openmc_venv/bin:$PATH
COPY wheelhouse/openmc-0.15.1.dev0-cp${python_version_no_dot}-cp${python_version_no_dot}-manylinux_2_28_x86_64.whl .
RUN python${python_version} -m pip install openmc-0.15.1.dev0-cp${python_version_no_dot}-cp${python_version_no_dot}-manylinux_2_28_x86_64.whl[vtk]
RUN python${python_version} -c "import openmc.lib"
COPY minimal_test.py .
COPY small_dagmc_file.h5m .
COPY cross_sections.xml .
COPY Li.h5 .
COPY Li7.h5 .
COPY small_um.vtk .
RUN apt install libxrender1 -y
RUN python${python_version} minimal_test.py

minimal_test.py

import openmc

openmc.config['cross_sections'] = 'cross_sections.xml'

mat1 = openmc.Material(name='mat1')
mat1.add_nuclide('Li7', 0.95)
mat1.set_density('g/cm3', 1.0)

materials = openmc.Materials([mat1])

bound_dag_univ = openmc.DAGMCUniverse(filename='small_dagmc_file.h5m').bounded_universe()
my_geometry = openmc.Geometry(root=bound_dag_univ)

umesh = openmc.UnstructuredMesh(filename='small_um.vtk', library='moab')
umesh.id = 1

mesh_filter = openmc.MeshFilter(umesh)

# Create flux mesh tally to score alpha production
mesh_tally = openmc.Tally(tally_id=1, name='alpha_production_on_mesh')  # note the tally_id is specified
mesh_tally.filters = [mesh_filter]
mesh_tally.scores = ['(n,Xa)']  # where X is a wild card


tallies = openmc.Tallies([mesh_tally])


my_source = openmc.IndependentSource()
my_source.space = openmc.stats.Point((0.4, 0, 0.4))


settings = openmc.Settings()
settings.run_mode = 'fixed source'
settings.batches = 3
settings.particles = 1000
settings.source = my_source
settings.photon_transport=True

my_model = openmc.Model(
    materials=materials,
    geometry=my_geometry,
    settings=settings,
    tallies=tallies
)

statepoint_file = my_model.run()

statepoint = openmc.StatePoint(statepoint_file)

my_tally = statepoint.get_tally(name='alpha_production_on_mesh')

umesh_from_sp = statepoint.meshes[1] # note to self we can add a function to openmc to get the mesh by type or name

# needed to trigger internal mesh data loading with openmc v0.15, fixed on dev
# note to self we can add a function to openmc to get this automated when writting to vtk
centroids = umesh_from_sp.centroids
mesh_vols = umesh_from_sp.volumes


umesh_from_sp.write_data_to_vtk(
    datasets={'mean': my_tally.mean.flatten()},
    filename = "shape_alpha_production_on_mesh.vtu",
)
umesh_from_sp.write_data_to_vtk(
    datasets={'mean': my_tally.mean.flatten()},
    filename = "shape_alpha_production_on_mesh.vtk",
)

input.zip

@jon-proximafusion
Copy link
Collaborator

@ahnaf-tahmid-chowdhury would you be able to take a peak that this branch. I've kept it up to date with openmc develop branch.

The wheel is mainly working but I just want to be able to run this command with the manylinux docker file on this branch as this builds a simplified py3.10 wheel.

docker build --no-cache --build-arg Python_ABI=cp310-cp310 --build-arg=OPENMC_USE_DAGMC=ON -t openmc_wheel:python3.10 -f manylinux.Dockerfile .

The part that is not working is that even if the openmc executable is inside the wheel and gets installed it is not found when one types openmc, I think the openmc/init.py file needs to be changed to find it.

@ahnaf-tahmid-chowdhury
Copy link
Collaborator

Is it only happening with python 3.10?

Maybe we need to install python 3.10 dev packages for this

@jon-proximafusion
Copy link
Collaborator

Is it only happening with python 3.10?

Maybe we need to install python 3.10 dev packages for this

I tried installing python 3.10 in the docker container but none of these commands find the packages.
yum install python3.10-devel
yum install python3.10-dev
yum install python3.10-venv

I tried changing the docker image to older images but they don't contain yum
manylinux_2_24_x86_64
manylinux2014_x86_64

I can confirm this inability to find the openmc executable also happens with python 3.11
docker build --no-cache --build-arg Python_ABI=cp311-cp311 --build-arg=OPENMC_USE_DAGMC=ON -t openmc_wheel:python3.11 -f manylinux.Dockerfile .
and also with
docker build --no-cache --build-arg Python_ABI=cp312-cp312 --build-arg=OPENMC_USE_DAGMC=ON -t openmc_wheel:python3.12 -f manylinux.Dockerfile .

on this branch at least it does not work. I must have changed something with the packaging but not sure what.

 => ERROR [openmc 8/8] RUN openmc --version                                                                                                              0.1s 
------                                                                                                                                                        
 > [openmc 8/8] RUN openmc --version:                                                                                                                         
0.108 /bin/sh: openmc: command not found 

@shimwell
Copy link
Owner Author

I see the openmc executable is in the wheel and gets installed to the core/bin directory

Just this path does not appear to be included in the system paths so the terminal command openmc does not find the executable but it is at least in the site-packages folder structure

Screenshot From 2025-02-21 13-00-15

@shimwell
Copy link
Owner Author

ok that last commit solved my issues. 🎉

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was expecting GenerateScript.cmake file instead. Where you got this file?

@shimwell shimwell mentioned this pull request Apr 23, 2025
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.

4 participants