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

Swap to pdm #166

Merged
merged 6 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions .github/workflows/conda-build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
defaults:
run:
shell: bash -l {0}
env:
OORB_DATA: /tmp/oorb/data

steps:
- name: Checkout git repo
Expand All @@ -28,24 +30,16 @@ jobs:
activate-environment: "thor"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies (excluding adam_core and quivr since they are not available via conda)
- name: Install openorb dependencies
run: |
tail +3 requirements.txt > requirements_conda.txt
conda install -c defaults -c conda-forge -c astropy -c moeyensj --file requirements_conda.txt --yes
- name: Update OBSCODE.dat
run: |
cd $CONDA_PREFIX/share/oorb
curl https://www.minorplanetcenter.net/iau/lists/ObsCodes.html -o ObsCodes.html
sed -e '2d' ObsCodes.html | grep -v "<" > OBSCODE.dat
rm -f ObsCodes.html
cp OBSCODE.dat $CONDA_PREFIX/share/openorb/OBSCODE.dat
- name: Install adam_core and quivr
run: |
pip install adam-core@git+https://github.com/B612-Asteroid-Institute/adam_core@main
pip install quivr@git+https://github.com/moeyensj/quivr@concatenate-empty-attributes
sudo apt-get update -y
sudo apt-get install -y gfortran liblapack-dev
wget -P /tmp/ https://storage.googleapis.com/oorb-data/oorb_data.tar.gz
mkdir -p /tmp/oorb/
tar -xvf /tmp/oorb_data.tar.gz -C /tmp/oorb/
- name: Build and install
run: pip install . --no-deps
run: pip install .[dev]
- name: Lint
run: pre-commit run --all-files
run: pdm lint
- name: Test
run: pytest . --cov
run: pdm test
34 changes: 0 additions & 34 deletions .github/workflows/conda-publish.yml

This file was deleted.

9 changes: 5 additions & 4 deletions .github/workflows/docker-build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: docker - Build Lint and Test

on:
Expand All @@ -12,16 +11,18 @@ jobs:
runs-on: ubuntu-latest
env:
IMAGE_TAG: ${{ github.sha }}
OORB_DATA: /tmp/oorb/data

steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Build
run: docker build --load -t thor:$IMAGE_TAG .
- name: Lint
run: docker run -i thor:$IMAGE_TAG pre-commit run --all-files
run: docker run -i thor:$IMAGE_TAG pdm lint
- name: Test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can dump the docker builds altogether with the simpler pyoorb / numpy install?

run: docker run -i thor:$IMAGE_TAG pytest . --cov
run: docker run -i thor:$IMAGE_TAG pdm test
31 changes: 15 additions & 16 deletions .github/workflows/pip-build-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,28 @@ jobs:
defaults:
run:
shell: bash -l {0}
env:
OORB_DATA: /tmp/oorb/data

steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: "thor"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install openorb using conda
run: conda install -c defaults -c conda-forge openorb --yes
- name: Update OBSCODE.dat
run: |
cd $CONDA_PREFIX/share/oorb && ./updateOBSCODE
cp OBSCODE.dat $CONDA_PREFIX/share/openorb/OBSCODE.dat
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
- name: Build and install
run: pip install .[tests]
- name: Install openorb dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y gfortran liblapack-dev
wget -P /tmp/ https://storage.googleapis.com/oorb-data/oorb_data.tar.gz
mkdir -p /tmp/oorb/
tar -xvf /tmp/oorb_data.tar.gz -C /tmp/oorb/
- name: Install Dependencies
run: |
pip install pip --upgrade
pip install ".[dev]"
- name: Integration Tests
run: pytest . -m "integration"
run: pdm test -k integration
42 changes: 20 additions & 22 deletions .github/workflows/pip-build-lint-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,36 @@ jobs:
defaults:
run:
shell: bash -l {0}
env:
OORB_DATA: /tmp/oorb/data

steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: "thor"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install openorb using conda
run: conda install -c defaults -c conda-forge openorb --yes
- name: Update OBSCODE.dat
run: |
cd $CONDA_PREFIX/share/oorb
curl https://www.minorplanetcenter.net/iau/lists/ObsCodes.html -o ObsCodes.html
sed -e '2d' ObsCodes.html | grep -v "<" > OBSCODE.dat
rm -f ObsCodes.html
cp OBSCODE.dat $CONDA_PREFIX/share/openorb/OBSCODE.dat
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
- name: Build and install
run: pip install .[tests]
- name: Install openorb dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y gfortran liblapack-dev
wget -P /tmp/ https://storage.googleapis.com/oorb-data/oorb_data.tar.gz
mkdir -p /tmp/oorb/
tar -xvf /tmp/oorb_data.tar.gz -C /tmp/oorb/
- name: Install Dependencies
run: |
pip install pip --upgrade
pip install ".[dev]"
- name: Lint
run: pre-commit run --all-files
- name: Test
run: pytest . --cov --cov-report xml
- name: Coverage
run: pdm run lint
# - name: Type check
# run: pdm run typecheck
- name: Test with coverage
run: pdm run coverage
- name: Coverage Report
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.COVERALLS_TOKEN }}
Expand Down
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Data files
thor/data
thor/data/log.yaml
thor/version.py
# Version file: set by pdm-scm
src/thor/_version.py

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down Expand Up @@ -108,7 +106,7 @@ ipython_config.py

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
Expand Down
30 changes: 0 additions & 30 deletions .pre-commit-config.yaml

This file was deleted.

56 changes: 11 additions & 45 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1,22 @@
FROM ubuntu:latest
FROM python:3.11

# Set shell to bash
SHELL ["/bin/bash", "-c"]
CMD ["/bin/bash"]

# Update system dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y curl gfortran git liblapack-dev make pip python3.11 python-is-python3 unzip wget
&& apt-get install -y pip git wget tar gfortran liblapack-dev

# Upgrade pip to the latest version and install pre-commit
RUN pip install --upgrade pip pre-commit
RUN pip install --upgrade cython==0.29.36 setuptools setuptools_scm
RUN chmod 777 /opt

# Install numpy
RUN git clone https://github.com/numpy/numpy.git /opt/numpy
RUN cd /opt/numpy && git checkout v1.24.4 && git submodule update --init
RUN cd /opt/numpy && python3 setup.py build --cpu-baseline=native install


# Install openorb
# TODO: We need a more robust way to be appropriately natively compiled pyoorb installed
# including data file generation
RUN git clone https://github.com/B612-Asteroid-Institute/oorb.git /opt/oorb
RUN cd /opt/oorb && git checkout fork
RUN cd /opt/oorb && ./configure gfortran opt --with-pyoorb --with-f2py=/usr/local/bin/f2py --with-python=python3
# Add '-march=native' to compiler options by running a sed
# script directly on the Makefile.includse file. This is a
# hack to get around the fact that the configure script
# doesn't support this option.
RUN sed -i 's/FCOPTIONS = .*/FCOPTIONS = $(FCOPTIONS_OPT_GFORTRAN) -march=native/g' /opt/oorb/Makefile.include
# --no-build-isolation is needed because we need to ensure we use
# the same version of numpy as the one we compiled previously so
# that it matches the version of f2py we passed in to ./configure.
RUN pip install --no-build-isolation -v /opt/oorb

# Generate the data files
RUN cd /opt/oorb && make ephem
RUN cd /opt/oorb/data && ./getBC430
RUN cd /opt/oorb/data && ./updateOBSCODE
ENV OORBROOT=/opt/oorb
ENV OORB_DATA=/opt/oorb/data

# Install pre-commit hooks (before THOR is installed to cache this step)
RUN mkdir /code/
COPY .pre-commit-config.yaml /code/
WORKDIR /code/
RUN git init . \
&& git add .pre-commit-config.yaml \
&& pre-commit install-hooks \
&& rm -rf .git
# Install openorb dependencies
RUN wget -P /tmp/ https://storage.googleapis.com/oorb-data/oorb_data.tar.gz \
&& mkdir -p /tmp/oorb/ \
&& tar -xvf /tmp/oorb_data.tar.gz -C /tmp/oorb/
ENV OORB_DATA=/tmp/oorb/data/

# Install THOR
RUN mkdir -p /code/
WORKDIR /code/
ADD . /code/
RUN SETUPTOOLS_SCM_PRETEND_VERSION=1 pip install -e .[tests,dev]
RUN pip install -e .[dev]
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include thor/*.py
include src/*.py
include *.md
include *.toml
include *.yaml
Loading
Loading