Skip to content

Commit b5b47a6

Browse files
committed
update package infrastructure
1 parent 094511c commit b5b47a6

15 files changed

+273
-163
lines changed

.coveragerc

-28
This file was deleted.

.github/workflows/python-package.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ jobs:
1818
matrix:
1919
os: [ubuntu-latest]
2020
python-version: ['3.9', '3.10'] #, '3.11'] possible conflicts between numpy & astropy on 3.11.
21-
astropy-version: ['<5.1', '<5.3', '<6.0']
22-
desiutil-version: ['3.3.1', 'main']
21+
astropy-version: ['<6.0', '<6.1', '<7.0']
22+
desiutil-version: ['3.4.3', 'main']
2323

2424
steps:
2525
- name: Checkout code
26-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2727
with:
2828
fetch-depth: 0
2929
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v4
30+
uses: actions/setup-python@v5
3131
with:
3232
python-version: ${{ matrix.python-version }}
3333
- name: Install Python dependencies
3434
run: |
3535
python -m pip install --upgrade pip setuptools wheel
3636
python -m pip install pytest jinja2
37-
python -m pip install numpy\<1.23
37+
python -m pip install numpy\<2.0
3838
python -m pip install "git+https://github.com/desihub/desiutil.git@${{ matrix.desiutil-version }}#egg=desiutil"
3939
python -m pip install "astropy${{ matrix.astropy-version }}"
4040
- name: Run the test
@@ -52,19 +52,19 @@ jobs:
5252

5353
steps:
5454
- name: Checkout code
55-
uses: actions/checkout@v3
55+
uses: actions/checkout@v4
5656
with:
5757
fetch-depth: 0
5858
- name: Set up Python ${{ matrix.python-version }}
59-
uses: actions/setup-python@v4
59+
uses: actions/setup-python@v5
6060
with:
6161
python-version: ${{ matrix.python-version }}
6262
- name: Install Python dependencies
6363
run: |
6464
python -m pip install --upgrade pip setuptools wheel
6565
python -m pip install pytest pytest-cov coveralls
66+
python -m pip install numpy\<2.0
6667
python -m pip install -r requirements.txt
67-
python -m pip install --upgrade numpy\<1.23
6868
- name: Run the test with coverage
6969
run: |
7070
pytest --cov
@@ -86,11 +86,11 @@ jobs:
8686

8787
steps:
8888
- name: Checkout code
89-
uses: actions/checkout@v3
89+
uses: actions/checkout@v4
9090
with:
9191
fetch-depth: 0
9292
- name: Set up Python ${{ matrix.python-version }}
93-
uses: actions/setup-python@v4
93+
uses: actions/setup-python@v5
9494
with:
9595
python-version: ${{ matrix.python-version }}
9696
- name: Install Python dependencies
@@ -112,15 +112,15 @@ jobs:
112112
matrix:
113113
os: [ubuntu-latest]
114114
python-version: ['3.10']
115-
desiutil-version: ['3.3.0']
115+
desiutil-version: ['3.4.3']
116116

117117
steps:
118118
- name: Checkout code
119-
uses: actions/checkout@v3
119+
uses: actions/checkout@v4
120120
with:
121121
fetch-depth: 0
122122
- name: Set up Python ${{ matrix.python-version }}
123-
uses: actions/setup-python@v4
123+
uses: actions/setup-python@v5
124124
with:
125125
python-version: ${{ matrix.python-version }}
126126
- name: Install Python dependencies
@@ -144,11 +144,11 @@ jobs:
144144

145145
steps:
146146
- name: Checkout code
147-
uses: actions/checkout@v3
147+
uses: actions/checkout@v4
148148
with:
149149
fetch-depth: 0
150150
- name: Set up Python ${{ matrix.python-version }}
151-
uses: actions/setup-python@v4
151+
uses: actions/setup-python@v5
152152
with:
153153
python-version: ${{ matrix.python-version }}
154154
- name: Install Python dependencies

.readthedocs.yml

-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ sphinx:
2222

2323
# Optionally set the version of Python and requirements required to build your docs
2424
python:
25-
# version: 3
26-
# system_packages: true
2725
install:
2826
- requirements: doc/rtd-requirements.txt

LICENSE.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014-2022, DESI Collaboration <[email protected]>
1+
Copyright (c) 2014-2024, DESI Collaboration <[email protected]>
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification,

MANIFEST.in

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
include LICENSE.rst
2-
include README.rst
3-
include requirements.txt
4-
5-
graft bin
6-
graft doc
7-
graft etc
8-
9-
prune build
10-
prune dist
11-
prune htmlcov
12-
prune doc/_build
1+
prune .github
2+
global-exclude .gitignore .readthedocs.yml

doc/changes.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ desidatamodel Change Log
55
24.10 (unreleased)
66
------------------
77

8-
* No changes yet.
8+
* Update package infrastructure, ... (PR `#200`_).
9+
10+
.. _`#200`: https://github.com/desihub/desidatamodel/pull/200
911

1012
24.9 (2024-09-12)
1113
-----------------

py/desidatamodel/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
This package provides support for the DESI_ Data Model.
99
10-
.. _DESI: http://desi.lbl.gov
10+
.. _DESI: https://www.desi.lbl.gov
1111
"""
1212
#
1313
# Set version string.

py/desidatamodel/check.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -328,16 +328,16 @@ def extract_metadata(self, error=False):
328328
spanend = int(g[1])
329329
log.debug('Detected range specification from HDU %d to HDU %d',
330330
spanstart, spanend)
331-
spanref = [l for l in section if l.startswith('Data:')][0]
331+
spanref = [ln for ln in section if ln.startswith('Data:')][0]
332332
spanext = spanref[spanref.lower().index('see') + 4:].replace('.', '')
333333
try:
334334
spanmeta = self.hdumeta[spanext]
335335
except KeyError:
336336
m = "Cannot find EXTNAME = '%s' which is supposed to define HDU %d to HDU %d!"
337337
log.critical(m, spanext, spanstart, spanend)
338338
raise DataModelError(m % (spanext, spanstart, spanend))
339-
spanname = [l.split('=')[1].strip() for l in section
340-
if l.startswith('EXTNAME = ')][0]
339+
spanname = [ln.split('=')[1].strip() for ln in section
340+
if ln.startswith('EXTNAME = ')][0]
341341
extnames = [p.strip() for p in spanname.split(',')]
342342
if len(range(spanstart, spanend+1)) == len(extnames):
343343
for i, l in enumerate(range(spanstart, spanend+1)):
@@ -357,7 +357,7 @@ def extract_metadata(self, error=False):
357357
meta = dict()
358358
meta['number'] = k
359359
meta['title'] = section[0]
360-
hdu_cross_ref = [l for l in section if l.startswith('See `')]
360+
hdu_cross_ref = [ln for ln in section if ln.startswith('See `')]
361361
if hdu_cross_ref:
362362
log.debug("Found HDU cross-reference: %s", hdu_cross_ref[0])
363363
hcr = self._cross_reference(hdu_cross_ref[0]).split('#')
@@ -372,7 +372,7 @@ def extract_metadata(self, error=False):
372372
if 'Empty HDU.' in section:
373373
meta['extension'] = 'IMAGE'
374374
meta['format'] = 'Empty HDU.'
375-
image_data = [l for l in section if l.startswith('Data:')]
375+
image_data = [ln for ln in section if ln.startswith('Data:')]
376376
if image_data:
377377
meta['extension'] = 'IMAGE'
378378
meta['format'] = image_data[0]
@@ -439,8 +439,8 @@ def extract_metadata(self, error=False):
439439
# the detailed policy on EXTNAME.
440440
#
441441
try:
442-
meta['extname'] = [l.split()[2] for l in section
443-
if l.startswith('EXTNAME = ')][0]
442+
meta['extname'] = [ln.split()[2] for ln in section
443+
if ln.startswith('EXTNAME = ')][0]
444444
except IndexError:
445445
meta['extname'] = 'HDU{0:02d}'.format(k)
446446
if (k > 0 or (k == 0 and meta['format'] != 'Empty HDU.')):

py/desidatamodel/test/datamodeltestcase.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ def assertInLog(self, logger, message=''):
9595
def badUnitMessage(self, unit):
9696
"""Returns a string that can be used to match errors related to bad units.
9797
"""
98-
m = "'{0}' did not parse as fits unit: At col {1:d}, Unit 'ergs' not supported by the FITS standard. Did you mean erg?".format(unit, unit.index('ergs'))
98+
m = ("'{0}' did not parse as fits unit: At col {1:d}, Unit 'ergs' not " +
99+
"supported by the FITS standard. Did you mean erg?").format(unit, unit.index('ergs'))
99100
if self.astropyVersion >= version.parse('4.0'):
100-
m += " If this is meant to be a custom unit, define it with 'u.def_unit'. To have it recognized inside a file reader or other code, enable it with 'u.add_enabled_units'. For details, see http://docs.astropy.org/en/latest/units/combining_and_defining.html"
101+
m += (" If this is meant to be a custom unit, define it with 'u.def_unit'. " +
102+
"To have it recognized inside a file reader or other code, enable it with " +
103+
"'u.add_enabled_units'. For details, see http://docs.astropy.org/en/latest/units/combining_and_defining.html")
101104
if self.astropyVersion >= version.parse('4.0.2'):
102105
m = m.replace('http', 'https')
103106
return m

py/desidatamodel/test/test_check.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,9 @@ def test_validate_prototype_hdu_mismatch(self):
471471
foo = f.extract_metadata()
472472
f.hdumeta['foobar'] = 'baz'
473473
f.validate_prototype(error=True)
474-
self.assertLog(log, -2, "{0} has the wrong number of sections (HDUs) according to {1}, skipping to next candidate.".format(str(modelfile).replace('.rst', '.fits'), modelfile))
474+
self.assertLog(log, -2, ("{0} has the wrong number of sections (HDUs) " +
475+
"according to {1}, skipping to next " +
476+
"candidate.").format(str(modelfile).replace('.rst', '.fits'), modelfile))
475477
self.assertLog(log, -1, "No useful prototype files found for {0}!".format(modelfile))
476478

477479
def test_validate_prototype_hdu_keyword_mismatch(self):
@@ -484,7 +486,8 @@ def test_validate_prototype_hdu_keyword_mismatch(self):
484486
f.validate_prototype()
485487
f._stub_meta[0]['keywords'].append(('BUNIT', 'erg', 'str', 'This is a test.'))
486488
f.validate_prototype(error=True)
487-
self.assertLog(log, -1, "Prototype file {0} has these keywords in HDU0 missing from model: {{'BUNIT'}}".format(str(modelfile).replace('.rst', '.fits')))
489+
self.assertLog(log, -1, ("Prototype file {0} has these keywords " +
490+
"in HDU0 missing from model: {{'BUNIT'}}").format(str(modelfile).replace('.rst', '.fits')))
488491

489492
def test_validate_prototype_hdu_keyword_type_mismatch(self):
490493
"""Test the data model validation method with a keyword type mismatch.
@@ -496,7 +499,9 @@ def test_validate_prototype_hdu_keyword_type_mismatch(self):
496499
f.extract_metadata()
497500
f.hdumeta['PRIMARY']['keywords'][2] = ('BSCALE', '1.2', 'float', '')
498501
f.validate_prototype()
499-
self.assertLog(log, -1, "File %s HDU%d keyword %s has different keyword type according to %s (%s != %s)." % (f.prototype, 0, 'BSCALE', modelfile, 'int', 'float'))
502+
self.assertLog(log, -1, ("File %s HDU%d keyword %s has different keyword " +
503+
"type according to %s (%s != %s).") %
504+
(f.prototype, 0, 'BSCALE', modelfile, 'int', 'float'))
500505

501506
def test_validate_prototype_hdu_wrong_keyword(self):
502507
"""Test the data model validation method with wrong HDU keyword names.
@@ -521,7 +526,9 @@ def test_validate_prototype_hdu_extension_type(self):
521526
f.validate_prototype()
522527
f._stub_meta[1]['extension'] = 'IMAGE'
523528
f.validate_prototype(error=True)
524-
self.assertLog(log, -1, "Prototype file {0} has an extension type mismatch in HDU1 (IMAGE != BINTABLE) according to {1}.".format(str(modelfile).replace('.rst', '.fits'), modelfile))
529+
self.assertLog(log, -1, ("Prototype file {0} has an extension type " +
530+
"mismatch in HDU1 (IMAGE != BINTABLE) according " +
531+
"to {1}.").format(str(modelfile).replace('.rst', '.fits'), modelfile))
525532
# f._stub_meta[1]['extname'] = ''
526533
# f.validate_prototype(error=True)
527534
# self.assertLog(log, -1, "Prototype file {0} has no EXTNAME in HDU1.".format(str(modelfile).replace('.rst', '.fits')))
@@ -536,7 +543,9 @@ def test_validate_prototype_hdu_extension_name(self):
536543
f.validate_prototype()
537544
f._stub_meta[1]['extname'] = 'GALAXY'
538545
f.validate_prototype(error=True)
539-
self.assertLog(log, -1, "Prototype file {0} has an EXTNAME mismatch in HDU1 (GALAXY != Galaxies) according to {1}.".format(str(modelfile).replace('.rst', '.fits'), modelfile))
546+
self.assertLog(log, -1, ("Prototype file {0} has an EXTNAME mismatch in " +
547+
"HDU1 (GALAXY != Galaxies) according to " +
548+
"{1}.").format(str(modelfile).replace('.rst', '.fits'), modelfile))
540549
f._stub_meta[1]['extname'] = ''
541550
f.validate_prototype(error=True)
542551
self.assertLog(log, -2, "Prototype file {0} has no EXTNAME in HDU1.".format(str(modelfile).replace('.rst', '.fits')))

py/desidatamodel/test/test_scan.py

+24-7
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,30 @@ def test_union_metadata(self, mock_update, mock_mark):
129129
foo = model.get_regexp('/desi/spectro/data')
130130
union_metadata(model, stubs)
131131
mock_mark.assert_called_once()
132-
mock_update.assert_has_calls([call(0, [('NAXIS1', '100', 'int', ''), ('NAXIS2', '100', 'int', ''), ('BSCALE', '1', 'int', ''), ('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')]),
133-
call(1, [('NAXIS1', '32', 'int', 'length of dimension 1'), ('NAXIS2', '3', 'int', 'length of dimension 2')]),
134-
call(1, [('Name', 'Type', 'Units', 'Description'), ('target', 'char[20]', '', ''), ('V_mag', 'float32', 'mag', ''), ('vdisp', 'float64', 'km/s', '')], columns=True),
135-
call(0, [('NAXIS1', '100', 'int', ''), ('NAXIS2', '100', 'int', ''), ('BSCALE', '1', 'int', ''), ('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')]),
136-
call(1, [('NAXIS1', '32', 'int', 'length of dimension 1'), ('NAXIS2', '3', 'int', 'length of dimension 2')]),
137-
call(1, [('Name', 'Type', 'Units', 'Description'), ('target', 'char[20]', '', ''), ('V_mag', 'float32', 'mag', ''), ('vdisp', 'float64', 'km/s', '')], columns=True),
138-
call(0, [('NAXIS1', '100', 'int', ''), ('NAXIS2', '100', 'int', ''), ('BSCALE', '1', 'int', ''), ('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')])])
132+
mock_update.assert_has_calls([call(0, [('NAXIS1', '100', 'int', ''),
133+
('NAXIS2', '100', 'int', ''),
134+
('BSCALE', '1', 'int', ''),
135+
('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')]),
136+
call(1, [('NAXIS1', '32', 'int', 'length of dimension 1'),
137+
('NAXIS2', '3', 'int', 'length of dimension 2')]),
138+
call(1, [('Name', 'Type', 'Units', 'Description'),
139+
('target', 'char[20]', '', ''),
140+
('V_mag', 'float32', 'mag', ''),
141+
('vdisp', 'float64', 'km/s', '')], columns=True),
142+
call(0, [('NAXIS1', '100', 'int', ''),
143+
('NAXIS2', '100', 'int', ''),
144+
('BSCALE', '1', 'int', ''),
145+
('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')]),
146+
call(1, [('NAXIS1', '32', 'int', 'length of dimension 1'),
147+
('NAXIS2', '3', 'int', 'length of dimension 2')]),
148+
call(1, [('Name', 'Type', 'Units', 'Description'),
149+
('target', 'char[20]', '', ''),
150+
('V_mag', 'float32', 'mag', ''),
151+
('vdisp', 'float64', 'km/s', '')], columns=True),
152+
call(0, [('NAXIS1', '100', 'int', ''),
153+
('NAXIS2', '100', 'int', ''),
154+
('BSCALE', '1', 'int', ''),
155+
('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')])])
139156

140157
@patch('sys.argv', ['deep_scan_metadata', '--verbose', '--number', '1000', 'DESI_SPECTRO_DATA/NIGHT/EXPID/desi-EXPID.rst', '/desi/spectro/data'])
141158
def test_options(self):

pyproject.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[build-system]
2+
requires = ["setuptools",
3+
"wheel"]
4+
build-backend = 'setuptools.build_meta'

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
astropy
22
sphinx-toolbox
33
jinja2
4-
git+https://github.com/desihub/desiutil.git@3.3.1#egg=desiutil
4+
git+https://github.com/desihub/desiutil.git@3.4.3#egg=desiutil

0 commit comments

Comments
 (0)