Skip to content

Commit

Permalink
Merge pull request #464 from desihub/remove-desi-test
Browse files Browse the repository at this point in the history
Remove DesiTest and update to work with pytest
  • Loading branch information
sbailey authored Jan 29, 2025
2 parents 3b6a44b + 37fd43f commit 4127563
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 167 deletions.
59 changes: 32 additions & 27 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,38 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10']
numpy-version: ['<1.22', '<1.23']
astropy-version: ['<5.1']
os: [ubuntu-22.04] # , ubuntu-24.04]
python-version: ['3.10'] # '3.11', '3.12']
numpy-version: ['<1.23']
astropy-version: ['<6.1', '<7']

env:
DESIUTIL_VERSION: 3.2.1
DESIMODEL_VERSION: main
DESIMETER_VERSION: 0.6.5
DESIMODEL_DATA: branches/test-0.17
DESIUTIL_VERSION: 3.4.3
DESIMODEL_VERSION: 0.19.2
DESIMETER_VERSION: 0.7.1
DESIMODEL_DATA: branches/test-0.19
DESIMODEL: ${{ github.workspace }}/desimodel
DESITARGET_VERSION: 2.2.1
DESITARGET_VERSION: 2.5.0

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.8.0
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v2
- name: Install System Packages
run: sudo apt install libbz2-dev subversion
- name: Checkout Package
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --no-cache-dir --upgrade pip wheel
python -m pip install --no-cache-dir pyyaml requests
python -m pip install --no-cache-dir scipy matplotlib healpy
python -m pip install --no-cache-dir --upgrade pip setuptools wheel pytest
python -m pip install --no-cache-dir pyyaml requests scipy matplotlib healpy
python -m pip install --no-cache-dir --upgrade "numpy${{ matrix.numpy-version }}"
python -m pip install --no-cache-dir --upgrade "astropy${{ matrix.astropy-version }}"
python -m pip install --no-cache-dir fitsio
Expand All @@ -55,38 +56,42 @@ jobs:
python -m pip install --no-cache-dir git+https://github.com/desihub/desimeter.git@${{ env.DESIMETER_VERSION }}#egg=desimeter
mkdir -p ${{ env.DESIMODEL }}
svn export https://desi.lbl.gov/svn/code/desimodel/${{ env.DESIMODEL_DATA }}/data ${{ env.DESIMODEL }}/data
- name: Install Fiberassign
run: CC=g++ CXX=g++ CFLAGS="-fPIC" LDSHARED="g++ -shared" python -m pip install -vvv .
# - name: Install Fiberassign
# run: CC=g++ CXX=g++ CFLAGS="-fPIC" LDSHARED="g++ -shared" python -m pip install -vvv .
# - name: Run Tests
# run: python -c 'import fiberassign.test; fiberassign.test.runtests()'
- name: Compile the package
run: CC=g++ CXX=g++ CFLAGS="-fPIC" LDSHARED="g++ -shared" python setup.py build_ext --inplace
- name: Run Tests
run: python -c 'import fiberassign.test; fiberassign.test.runtests()'
run: pytest

docs:
name: Doc test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.9']
os: [ubuntu-22.04]
python-version: ['3.10']

env:
DESIUTIL_VERSION: 3.2.1
DESIUTIL_VERSION: 3.5.0

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r doc/rtd_requirements.txt
- name: Install desiutil
run: python -m pip install --no-cache-dir git+https://github.com/desihub/desiutil.git@${{ env.DESIUTIL_VERSION }}#egg=desiutil
# - name: Install desiutil
# run: python -m pip install --no-cache-dir git+https://github.com/desihub/desiutil.git@${{ env.DESIUTIL_VERSION }}#egg=desiutil
- name: Compile the package
run: CC=g++ CXX=g++ CFLAGS="-fPIC" LDSHARED="g++ -shared" python setup.py build_ext --inplace
- name: Test the documentation
Expand Down
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXOPTS = -W --keep-going
# For macports, use the second line...
SPHINXBUILD = sphinx-build
#SPHINXBUILD = sphinx-build-2.7
Expand Down
4 changes: 3 additions & 1 deletion doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ fiberassign change log
5.7.3 (unreleased)
------------------

* No changes yet.
* Remove ``DesiTest`` from setup.py and warn about other deprecated features (PR `#464`_).

.. _`#464`: https://github.com/desihub/fiberassign/pull/464

5.7.2 (2023-10-04)
------------------
Expand Down
95 changes: 6 additions & 89 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@
'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon'
'sphinx.ext.napoleon',
'sphinx_rtd_theme'
]

# Configuration for intersphinx, copied from astropy.
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
'matplotlib': ('https://matplotlib.org/', None),
'matplotlib': ('https://matplotlib.org/stable/', None),
'astropy': ('https://docs.astropy.org/en/stable/', None),
'h5py': ('https://docs.h5py.org/en/latest/', None)
'h5py': ('https://docs.scipy.org/doc/scipy/', None)
}

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -73,7 +74,7 @@

# General information about the project.
project = 'fiberassign'
copyright = '2014-2022, DESI Collaboration'
copyright = '2014-2025, DESI Collaboration'
author = 'Robert Cahn, Jaime E. Forero-Romero, Ted Kisner'

# The version info for the project you're documenting, acts as replacement for
Expand Down Expand Up @@ -150,12 +151,7 @@
# a list of builtin themes.
#html_theme = 'default'
#html_theme = 'haiku'
try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
except ImportError:
pass
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down Expand Up @@ -234,82 +230,3 @@

# Output file base name for HTML help builder.
htmlhelp_basename = 'fiberassigndoc'


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'fiberassign.tex', 'fiberassign Documentation',
'DESI Collaboration', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False

# If true, show page references after internal links.
#latex_show_pagerefs = False

# If true, show URL addresses after external links.
#latex_show_urls = False

# Documents to append as an appendix to all manuals.
#latex_appendices = []

# If false, no module index is generated.
#latex_domain_indices = True


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'fiberassign', 'fiberassign Documentation',
['DESI Collaboration'], 1)
]

# If true, show URL addresses after external links.
#man_show_urls = False


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'fiberassign', 'fiberassign Documentation',
'DESI Collaboration', 'fiberassign', 'One line description of project.',
'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
#texinfo_appendices = []

# If false, no module index is generated.
#texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
6 changes: 3 additions & 3 deletions doc/rtd_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Sphinx>6,<7
sphinx-rtd-theme>1
git+https://github.com/desihub/desiutil.git@main#egg=desiutil
Sphinx
sphinx-rtd-theme
git+https://github.com/desihub/desiutil.git@3.5.0#egg=desiutil
4 changes: 2 additions & 2 deletions py/fiberassign/test/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
TARGET_TYPE_SUPPSKY,
TARGET_TYPE_SUPPSKY, TARGET_TYPE_STANDARD)

test_assign_date = "2020-01-01T00:00:00+00:00"
sim_assign_date = "2020-01-01T00:00:00+00:00"

def sim_data_dir():
dir = "test_fiberassign_output"
Expand All @@ -33,7 +33,7 @@ def sim_data_dir():
return dir


def test_subdir_create(name):
def sim_data_subdir_create(name):
test_dir = os.path.join(sim_data_dir(), name)
if os.path.isdir(test_dir):
shutil.rmtree(test_dir)
Expand Down
26 changes: 13 additions & 13 deletions py/fiberassign/test/test_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
from fiberassign.scripts.qa_plot import parse_plot_qa, run_plot_qa


from .simulate import (test_subdir_create, sim_tiles, sim_targets,
sim_focalplane, petal_rotation, test_assign_date,
from .simulate import (sim_data_subdir_create, sim_tiles, sim_targets,
sim_focalplane, petal_rotation, sim_assign_date,
sim_stuck_sky)


Expand All @@ -73,7 +73,7 @@ def tearDown(self):

def test_io(self):
np.random.seed(123456789)
test_dir = test_subdir_create("assign_test_io")
test_dir = sim_data_subdir_create("assign_test_io")
input_mtl = os.path.join(test_dir, "mtl.fits")
input_std = os.path.join(test_dir, "standards.fits")
input_sky = os.path.join(test_dir, "sky.fits")
Expand Down Expand Up @@ -115,10 +115,10 @@ def test_io(self):
load_target_file(tgs, tagalong, input_suppsky)

# Compute the targets available to each fiber for each tile.
fp, exclude, state = sim_focalplane(rundate=test_assign_date)
fp, exclude, state = sim_focalplane(rundate=sim_assign_date)
hw = load_hardware(
focalplane=(fp, exclude, state),
rundate=test_assign_date
rundate=sim_assign_date
)
tfile = os.path.join(test_dir, "footprint.fits")
sim_tiles(tfile)
Expand Down Expand Up @@ -285,7 +285,7 @@ def test_stucksky(self):
return self.test_full(do_stucksky=True)

def test_full(self, do_stucksky=False):
test_dir = test_subdir_create("assign_test_full")
test_dir = sim_data_subdir_create("assign_test_full")
np.random.seed(123456789)
input_mtl = os.path.join(test_dir, "mtl.fits")
input_std = os.path.join(test_dir, "standards.fits")
Expand Down Expand Up @@ -328,8 +328,8 @@ def test_full(self, do_stucksky=False):
load_target_file(tgs, tagalong, input_suppsky)

# Read hardware properties
fp, exclude, state = sim_focalplane(rundate=test_assign_date)
hw = load_hardware(focalplane=(fp, exclude, state), rundate=test_assign_date)
fp, exclude, state = sim_focalplane(rundate=sim_assign_date)
hw = load_hardware(focalplane=(fp, exclude, state), rundate=sim_assign_date)
tfile = os.path.join(test_dir, "footprint.fits")
sim_tiles(tfile)
tiles = load_tiles(tiles_file=tfile)
Expand Down Expand Up @@ -394,7 +394,7 @@ def test_full(self, do_stucksky=False):
return

def test_cli(self):
test_dir = test_subdir_create("assign_test_cli")
test_dir = sim_data_subdir_create("assign_test_cli")
np.random.seed(123456789)
input_mtl = os.path.join(test_dir, "mtl.fits")
input_std = os.path.join(test_dir, "standards.fits")
Expand Down Expand Up @@ -439,7 +439,7 @@ def test_cli(self):
"standards_per_petal": 10,
"sky_per_petal": 40,
"overwrite": True,
"rundate": test_assign_date
"rundate": sim_assign_date
}
optlist = option_list(opts)
args = parse_assign(optlist)
Expand Down Expand Up @@ -482,7 +482,7 @@ def test_cli(self):
return

def test_fieldrot(self):
test_dir = test_subdir_create("assign_test_fieldrot")
test_dir = sim_data_subdir_create("assign_test_fieldrot")
np.random.seed(123456789)
input_mtl = os.path.join(test_dir, "mtl.fits")
input_std = os.path.join(test_dir, "standards.fits")
Expand Down Expand Up @@ -544,12 +544,12 @@ def test_fieldrot(self):
tile_ids = list(tiles.id)

# Simulate a fake focalplane
fp, exclude, state = sim_focalplane(rundate=test_assign_date, fakepos=True)
fp, exclude, state = sim_focalplane(rundate=sim_assign_date, fakepos=True)

# Load the focalplane
hw = load_hardware(
focalplane=(fp, exclude, state),
rundate=test_assign_date
rundate=sim_assign_date
)

# Precompute target positions
Expand Down
Loading

0 comments on commit 4127563

Please sign in to comment.