Git Product home page Git Product logo

pythia-python's Introduction

PYTHIA 8 Docker image with Python 3 and HEP simulation stack

Docker Pulls Docker Image Size (tag) Binder

PYTHIA is a program for the generation of high-energy physics events, i.e. for the description of collisions at high energies between elementary particles such as e+, e-, p and pbar in various combinations.

PYTHIA 8's source is distributed on GitLab and is a product of the PYTHIA development team.

Distributed Software

The Docker image contains:

Installation

docker pull matthewfeickert/pythia-python:pythia8.308

Use

You can either use the image as "PYTHIA as a service", as demoed here with the test script in the repo using the Python bindings

docker run \
  --rm \
  --user $(id -u $USER):$(id -g $USER) \
  --volume $PWD:/home/docker/work \
  matthewfeickert/pythia-python:pythia8.308 \
  'python tests/main01.py > main01_out_py.txt'

or the original C++

docker run \
  --rm \
  --user $(id -u $USER):$(id -g $USER) \
  --volume $PWD:/home/docker/work \
  matthewfeickert/pythia-python:pythia8.308 \
  'g++ tests/main01.cc -pthread -o tests/main01 $(pythia8-config --cxxflags --ldflags); ./tests/main01 > main01_out_cpp.txt'

or you can run interactively

docker run \
  --rm \
  -ti \
  --publish 8888:8888 \
  --user $(id -u $USER):$(id -g $USER) \
  --volume $PWD:/home/docker/work \
  matthewfeickert/pythia-python:pythia8.308

pythia-python's People

Contributors

matthewfeickert avatar mattleblanc avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pythia-python's Issues

Multi-arch image support in CI via splitting builds and using `docker manifest`

I already know how to do this manually with things like

multi_platform:
	docker pull python:3.10-slim-bullseye
	docker pull tonistiigi/binfmt
ifeq ($(shell uname -m),x86_64)
	docker run --privileged --rm tonistiigi/binfmt --install arm64
else
	docker run --privileged --rm tonistiigi/binfmt --install amd64
endif
	docker buildx create \
		--name buildx_builder \
		--driver docker-container \
		--bootstrap \
		--use
	docker buildx build \
	--file Dockerfile \
	--platform linux/amd64,linux/arm64 \
	--build-arg BASE_IMAGE=python:3.10-slim-bullseye \
	--build-arg HEPMC_VERSION=3.2.5 \
	--build-arg LHAPDF_VERSION=6.5.3 \
	--build-arg FASTJET_VERSION=3.4.0 \
	--build-arg PYTHIA_VERSION=8308 \
	--tag matthewfeickert/pythia-python:pythia8.308 \
	--tag matthewfeickert/pythia-python:latest \
	--push \
	.
	docker buildx stop buildx_builder
	docker buildx rm buildx_builder

but to do this in CI this is too slow (takes almost 6 hours) with

...
    - name: Build and publish to registry
      id: docker_build_latest
      uses: docker/build-push-action@v3
      with:
        context: .
        file: Dockerfile
        tags: ${{ github.repository }}:latest,${{ github.repository }}:pythia8.308,${{ github.repository }}:pythia8.308-hepmc3.2.5-fastjet3.4.0-python3.10
        labels: |
          org.opencontainers.image.source=${{ github.event.repository.html_url }}
          org.opencontainers.image.revision=${{ github.sha }}
        push: true
        platforms: linux/amd64,linux/arm64

taking far too long and can time out.

As pointed out by Anthony Sottile on Twitter, probably the easiest way to get around this is to build separate images in CI (using GitHub Actions for linux/amd64 and Cirrus CI for linux/arm64) with something like

docker buildx build \
	--file Dockerfile \
	--platform linux/amd64 \
	--tag matthewfeickert/pythia-python:latest-amd64 \
	--push \
	.

on GitHub Actions (x86_64) and

docker buildx build \
	--file Dockerfile \
	--platform linux/arm64 \
	--tag matthewfeickert/pythia-python:latest-arm64 \
	--push \
	.

on Cirrus CI (aarch64). Once both of those images are up on the container registry of choice (here Docker Hub but probably also want to do this for ghcr as well later) would then want to in another workflow do

$ docker manifest create matthewfeickert/pythia-python:latest \
    --amend matthewfeickert/pythia-python:latest-amd64 \
    --amend matthewfeickert/pythia-python:latest-arm64
$ docker manifest push matthewfeickert/pythia-python:latest

I assume that as docker manifest create --help doesn't make it clear, there is no way to to multiple manifest tags at once and so to also do a tag of matthewfeickert/pythia-python:pythia8.308 it would require

$ docker manifest create matthewfeickert/pythia-python:pythia8.308 \
    --amend matthewfeickert/pythia-python:latest-amd64 \
    --amend matthewfeickert/pythia-python:latest-arm64
$ docker manifest push matthewfeickert/pythia-python:pythia8.308

Broken tests due to install location

@mattleblanc has found that the tests are currently broken, as most of this software retains information about where it was installed (sadly) so PR #10 breaks things by installing under /copy/local in the builder.

This can be fixed by exporting environment variables ahead of time (as is recommended in /usr/local/share/Pythia8/htmldoc/ROOTusage.html)

export PYTHIA8=/usr/local
export PYTHIA8DATA="${PYTHIA8}"/share/Pythia8/xmldoc 

however this isn't super ideal, so it might be worth going back to individual copies from /usr/local in the builder image given that this affects many things:

$ docker run --rm -it matthewfeickert/pythia-python:pythia8.301 "grep -r '/copy/local' /usr/"
Binary file /usr/local/lib/libfastjettools.so.0.0.0 matches
Binary file /usr/local/lib/libpythia8.a matches
/usr/local/lib/libfastjettools.la:dependency_libs=' /copy/local/lib/libfastjet.la'
/usr/local/lib/libfastjettools.la:libdir='/copy/local/lib'
/usr/local/lib/libfastjetplugins.la:dependency_libs=' /copy/local/lib/libsiscone_spherical.la /copy/local/lib/libsiscone.la /copy/local/lib/libfastjet.la'
/usr/local/lib/libfastjetplugins.la:libdir='/copy/local/lib'
Binary file /usr/local/lib/libfastjetplugins.so.0.0.0 matches
/usr/local/lib/libsiscone_spherical.la:dependency_libs=' /copy/local/lib/libsiscone.la'
/usr/local/lib/libsiscone_spherical.la:libdir='/copy/local/lib'
Binary file /usr/local/lib/pythia8.so matches
Binary file /usr/local/lib/libpythia8.so matches
/usr/local/lib/libsiscone.la:libdir='/copy/local/lib'
Binary file /usr/local/lib/libsiscone_spherical.so.0.0.0 matches
Binary file /usr/local/lib/python3.7/site-packages/__pycache__/fastjet.cpython-37.pyc matches
Binary file /usr/local/lib/python3.7/site-packages/__pycache__/fastjet.cpython-37.opt-1.pyc matches
/usr/local/lib/python3.7/site-packages/_fastjet.la:dependency_libs=' /copy/local/lib/libfastjettools.la /copy/local/lib/libfastjet.la'
/usr/local/lib/python3.7/site-packages/_fastjet.la:libdir='/copy/local/lib/python3.7/site-packages'
Binary file /usr/local/lib/python3.7/site-packages/_fastjet.so.0.0.0 matches
/usr/local/lib/libfastjet.la:libdir='/copy/local/lib'
/usr/local/share/Pythia8/examples/Makefile.inc:# --prefix=/copy/local
/usr/local/share/Pythia8/examples/Makefile.inc:PREFIX_BIN=/copy/local/bin
/usr/local/share/Pythia8/examples/Makefile.inc:PREFIX_INCLUDE=/copy/local/include
/usr/local/share/Pythia8/examples/Makefile.inc:PREFIX_LIB=/copy/local/lib
/usr/local/share/Pythia8/examples/Makefile.inc:PREFIX_SHARE=/copy/local/share/Pythia8
/usr/local/bin/fastjet-config:prefix=/copy/local
/usr/local/bin/fastjet-config:installationdir=/copy/local
/usr/local/bin/fastjet-config:	echo "  ./configure  '--prefix=/copy/local' '--enable-pyext=yes' 'CXX=/usr/bin/g++' 'PYTHON=/usr/local/bin/python'"
/usr/local/bin/fastjet-config:	printf "Configuration summary:\n----------------------\n  Installation directory     /copy/local\n  Shared libraries           yes\n  Static libraries           yes\n  Debug flag                 yes\n  CGAL support               no\n  Plugins: EECambridge       yes\n           Jade              yes\n           NestedDefs        yes\n           SISCone           yes\n           CDFCones          yes\n           D0RunICone        no\n           D0RunIICone       no\n           ATLASCone         no\n           CMSIterativeCone  no\n           PxCone            no\n           TrackJet          no\n           GridJet           yes\n  Monolithic plugins lib     yes\n  Python interface           yes\n  Swig python generator      no\n"
/usr/local/bin/pythia8-config:CFG_FILE=/copy/local/share/Pythia8/examples/Makefile.inc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.