Skip to content

Commit

Permalink
Merge pull request #42 from tberlok/presubmit
Browse files Browse the repository at this point in the history
Presubmit
  • Loading branch information
tberlok authored Jan 21, 2024
2 parents dce63f8 + 8c1f0d1 commit 0f3569c
Show file tree
Hide file tree
Showing 71 changed files with 861 additions and 691 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/manylinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,12 @@ jobs:
# twine upload --repository-url https://test.pypi.org/legacy/ dist/*manylinux*
# Commands for uploading to pypi
#twine upload dist/*tar.gz
twine upload dist/*tar.gz
twine upload dist/*manylinux*
# How to make a pip installation on my Mac:
# make clean
# python3 setup.py sdist bdist_wheel
# twine check dist/*
# twine upload dist/*
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
run: make

- name: Validate
run: pylint --errors-only --ignored-modules=astropy.units,astropy.constants --disable=E0611,E0401,E1101,E1120,E1121 paicos
run: pylint --errors-only --ignored-modules=astropy.units,astropy.constants --disable=E0611,E0401,E1101,E1120,E1121,E1111 paicos
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global-include *.pyx
global-exclude *.c
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ clean:
rm -rf paicos.egg-info

cleanup:
rm -rf test_data
rm -rf data/test_data
rm -f data/very_small_snap_247.hdf5
rm -f data/reduced_snap2_247.hdf5

checks:
make cleanup
pytest tests/comoving
pytest tests/non-comoving
pytest tests/general
cd tests; pytest comoving
cd tests; pytest non-comoving
cd tests; pytest general

linting:
flake8 ./
pylint --errors-only --ignored-modules=astropy.units,astropy.constants --disable=E0611,E0401,E1101,E1120,E1121 paicos
pylint --errors-only --ignored-modules=astropy.units,astropy.constants --disable=E0611,E0401,E1101,E1120,E1121,E1111 paicos

make dev_checks:
dev_checks:
make checks
make linting

# Tests that can only run on some systems
make gpu_checks:
python tests/cuda-gpu/test_gpu_binary_tree.py
python tests/cuda-gpu/test_gpu_ray_projector.py
python tests/cuda-gpu/test_gpu_sph_projector.py
gpu_checks:
cd tests; python cuda-gpu/test_gpu_binary_tree.py
cd tests; python cuda-gpu/test_gpu_ray_projector.py
cd tests; python cuda-gpu/test_gpu_sph_projector.py
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
project = 'Paicos'
copyright = '2023, Thomas Berlok'
author = 'Thomas Berlok'
release = '0.1.6'
release = '0.1.8'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Running the examples and notebooks

We provide a number of examples in the subdirectories `examples/` and `ipython-notebooks`.
We recommend that you start by working your way through the notebooks, startting with
We recommend that you start by working your way through the notebooks, starting with
notebook 1a.

## Downloading sample data
Expand Down
66 changes: 57 additions & 9 deletions docs/source/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ in my `.bash_profile`.
#### Compiling on MacOs

You will need an openmp-enabled compiler. On MacOs, you can install gcc via homebrew.
The `setup.py` in the Paicos directory currently has the following hardcoded
compiler option.
You can then either modify `setup.py` with your
compiler option, .e.g.,
```
if sys.platform == 'darwin':
os.environ['CC'] = 'gcc-13'
os.environ['CXX'] = 'g++-13'
```
or by running `CC=gcc-13 make` instead of simply `make`.

If you have installed gcc via homebrew, then you can get your compiler version by running
`brew info gcc` and update `setup.py` accordingly if that does not agree with what is hardcoded.
`brew info gcc`, which you can use to modify the instructions above accordingly.


#### Compiling Paicos inside a notebook
Expand All @@ -52,7 +54,28 @@ make clean
make
```

## Option 2: Installing the development version using pip
## Option 2: Installing directly via pip

This is probably the simplest way of installing Paicos, i.e. you run
```
pip install paicos
```
in a terminal.

Note however, that this installation does not include the tests, examples
and example data.

On MacOs you might have to do something like (see details above)
```
CC=gcc-13 pip install paicos
```
If the installation succeeded then you can proceed:
```
# Check if installation worked and that you can import Paicos
python -c "import paicos"
```

## Option 3: Installing the development version using pip
```
git clone git@github.com:tberlok/paicos.git
cd paicos
Expand All @@ -61,14 +84,39 @@ python3 -m pip install -e .
make checks
```

## Option 3: Installing directly via pip
## GPU/CUDA requirements

The visualization routines that run on GPU require installing CuPy (a drop-in replacement
for NumPy that runs on the GPU) and Numba CUDA (just-in-time compilation of kernel
and device functions on the GPU). These packages only work on CUDA-enabled GPUs,
which means that you need a recent Nvidia GPU.

These packages (CuPy and Numba) are not automatically included in Paicos.
Up-to-date instructions for installing them can be found at:

- CuPy: https://docs.cupy.dev/en/stable/install.html

- Numba: https://numba.readthedocs.io/en/stable/cuda/overview.html#supported-gpus

At the time of writing, we have had success installing for CUDA version
11.2 using

This installation does not include the tests and examples and will probably mostly work on Linux machines
```
pip install paicos
pip install numba
pip install cupy-cuda112
```
and then setting the path to the CUDA installation in .bashrc as e.g.
(substitute with the path to the CUDA installation on your system)
```
export CUDA_HOME=/software/astro/cuda/11.2 # numba
export CUDA_PATH=/software/astro/cuda/11.2 # cupy
```

Finally, you need to add
```
# Check if installation worked and that you can import Paicos
python -c "import paicos"
# Whether to load GPU/cuda functionality on startup
pa.load_cuda_functionality_on_startup(True)
```
to your `user_settings.py`.


6 changes: 3 additions & 3 deletions docs/source/notebooks/creating_radial_profiles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"import numpy as np\n",
"\n",
"# Open an Arepo snapshot\n",
"snap = pa.Snapshot(pa.root_dir + \"/data\", 247)\n",
"snap = pa.Snapshot(pa.data_dir, 247)\n",
"\n",
"# The center of the most massive Friends-of-friends group in the simulation\n",
"center = snap.Cat.Group[\"GroupPos\"][0]\n",
Expand Down Expand Up @@ -86,7 +86,7 @@
],
"source": [
"# Create a Paicos writer object\n",
"radfile = pa.PaicosWriter(snap, pa.root_dir + 'data', basename='radial')\n",
"radfile = pa.PaicosWriter(snap, pa.data_dir, basename='radial')\n",
"\n",
"# Set up the binning\n",
"bins = [1e-2*r_max, r_max, 100]\n",
Expand Down Expand Up @@ -168,7 +168,7 @@
"for parttype in range(1, snap.nspecies):\n",
" pstr = '{}_'.format(parttype)\n",
" # Re-open the Arepo snapshot\n",
" snap = pa.Snapshot(pa.root_dir + \"/data\", 247)\n",
" snap = pa.Snapshot(pa.data_dir, 247)\n",
"\n",
" # Use OpenMP parallel Cython code to find this central sphere\n",
" index = pa.util.get_index_of_radial_range(snap[pstr+'Coordinates'],\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/source/notebooks/histogram2d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"import numpy as np\n",
"\n",
"# A snapshot object\n",
"snap = pa.Snapshot(pa.root_dir + 'data', 247, load_catalog=False)\n",
"snap = pa.Snapshot(pa.data_dir, 247, load_catalog=False)\n",
"\n",
"# Create histogram\n",
"rhoB = pa.Histogram2D(snap, '0_Density', '0_MagneticFieldStrength', weights='0_Masses', bins_x=200,\n",
Expand Down Expand Up @@ -104,7 +104,7 @@
"\n",
" logscale (bool): Indicates whether to use logscale for the\n",
" histogram, default is True.\n",
"\u001b[0;31mFile:\u001b[0m ~/projects/paicos/paicos/histograms/histogram2D.py\n",
"\u001b[0;31mFile:\u001b[0m /opt/homebrew/Caskroom/miniforge/base/envs/paicos/lib/python3.10/site-packages/paicos/histograms/histogram2D.py\n",
"\u001b[0;31mType:\u001b[0m type\n",
"\u001b[0;31mSubclasses:\u001b[0m "
]
Expand Down Expand Up @@ -260,7 +260,7 @@
"outputs": [],
"source": [
"# Save the histogram\n",
"hist.save(basedir=pa.root_dir + '/data', basename='rhoT_hist')"
"hist.save(basedir=pa.data_dir, basename='rhoT_hist')"
]
}
],
Expand Down
6 changes: 3 additions & 3 deletions docs/source/notebooks/histogram2d_plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "073265ea-63a9-4033-8a5f-69c45a21abe6",
"metadata": {},
"outputs": [],
"source": [
"import paicos as pa\n",
"\n",
"# Load the histogram\n",
"rhoT = pa.Histogram2DReader(pa.root_dir + '/data', 247, basename='rhoT_hist')"
"rhoT = pa.Histogram2DReader(pa.data_dir, 247, basename='rhoT_hist')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "8643b210-7450-4d16-86f8-5de72ef66432",
"metadata": {},
"outputs": [
Expand Down
Loading

0 comments on commit 0f3569c

Please sign in to comment.