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 GitHub actions for maurorigo #30

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
26 changes: 26 additions & 0 deletions .github/workflows/rigo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Actions on Rigo
on: [push]
jobs:
test-docker-image:
runs-on: ubuntu-latest
container: ghcr.io/maurorigo/jaxubuntu:latest

steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Test for vim
run: test -f /bin/vim && echo "Vim is installed."
- name: Test for python
run: python3 --version
- name: Test for numpy
run: python3 -c "import numpy" && echo "numpy is installed."
- name: Test for jax
run: python3 -c "import jax" && echo "jax is installed."
- name: Run short test in tests/rigo directory
run: |
cd tests/rigo
python3 test.py
- name: Run long test in tests/rigo directory
run: |
cd tests/rigo
python3 MCtest.py
17 changes: 17 additions & 0 deletions docker/maurorigo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:focal

RUN apt-get update \
&& apt-get install -y vim \
&& apt-get install -y python3 \
&& apt-get install -y python3-pip \
&& pip install numpy \
&& pip install --upgrade "jax[cpu]"
RUN echo 'echo "This image runs Ubuntu and has vim, python, pip, numpy and jax installed."' > /usr/local/bin/start.sh
RUN echo 'echo "For a simple test, run \"python3 test.py\"."' >> /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh

WORKDIR /home

COPY test.py test.py

ENTRYPOINT /usr/local/bin/start.sh && /bin/bash
15 changes: 15 additions & 0 deletions docker/maurorigo/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import numpy as np
import jax
jax.config.update('jax_platform_name', 'cpu')

print("Test code using numpy and jax with cpu.")

arr = np.arange(10)

arrnp = np.random.permutation(arr)
print(f"Permuted with numpy: {arrnp}.")

key = jax.random.PRNGKey(13)
arrjnp = jax.random.permutation(key, arr)
assert len(arrjnp) == 10, "Something is wrong with the jax installation."
print(f"Permuted with jax: {arrjnp}.")
Loading