Skip to content

Commit 4cbce21

Browse files
committed
* Add CI jenkins script to trigger builds in lsstts jenkins server.
* Update setup.py to improve compatibility with conda build. * Remove init files from test folder to improve compatibility with conda build. * Fix rubin_sim/maf/mafContrib/n_galactic_stars.py run method definition. * Update the following unit tests to be compatible with conda build. * tests/photUtils/test_BandpassDict.py * tests/photUtils/test_Photometry.py * tests/photUtils/test_Sed.py * tests/photUtils/test_SedList.py * tests/photUtils/test_SNR.py * tests/utils/test_ModifiedJulianDate.py * tests/utils/test_Trixel.py
1 parent 8bdca05 commit 4cbce21

14 files changed

+66
-39
lines changed

ci/Jenkinsfile_rubin_sim.conda

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@Library('JenkinsShared')_
2+
ExternalCondaPipeline("rubin-sim")

rubin_sim/maf/mafContrib/n_galactic_stars.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ def __init__(self, filtername='r', filterCol='filter'):
1515

1616
def run(self, dataSlice, slicePoint=None):
1717

18+
pass

setup.cfg

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[flake8]
2+
max-line-length = 110
3+
max-doc-length = 79
4+
ignore = E133, E226, E228, N802, N803, N806, N812, N813, N815, N816, W503
5+
exclude =
6+
doc/**,
7+
bin/**,
8+
**/*/__init__.py,
9+
**/*/version.py,
10+
tests/.tests
11+
12+
[tool:pytest]
13+
addopts = --flake8 --black
14+
flake8-ignore = E133 E226 E228 N802 N803 N806 N812 N813 N815 N816 W503
15+
16+
[metadata]
17+
version = attr: setuptools_scm.get_version

setup.py

+30-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
1-
from setuptools import setup
1+
from setuptools import setup, find_packages
22

3-
setup(name='rubin_sim',
4-
version='0.01',
5-
scripts=['bin/maf/addRun', 'bin/maf/glance_dir',
6-
'bin/maf/maf_night_report', 'bin/maf/scimaf_dir',
7-
'bin/maf/showMaf', 'bin/maf/generate_ss',
8-
'bin/maf/run_moving_calc', 'bin/maf/run_moving_fractions',
9-
'bin/maf/run_moving_join',
10-
'bin/movingObjects/makeLSSTobs', 'bin/movingObjects/addSeds',
11-
'bin/movingObjects/generateCoefficients',
12-
'bin/rs_download_data'],
13-
packages=['rubin_sim', ],
14-
)
3+
scm_version_template = """# Generated by setuptools_scm
4+
__all__ = ["__version__"]
5+
6+
__version__ = "{version}"
7+
"""
8+
9+
setup(
10+
name="rubin_sim",
11+
use_scm_version={
12+
"write_to": "rubin_sim/version.py",
13+
"write_to_template": scm_version_template,
14+
},
15+
scripts=[
16+
"bin/maf/addRun",
17+
"bin/maf/glance_dir",
18+
"bin/maf/maf_night_report",
19+
"bin/maf/scimaf_dir",
20+
"bin/maf/showMaf",
21+
"bin/maf/generate_ss",
22+
"bin/maf/run_moving_calc",
23+
"bin/maf/run_moving_fractions",
24+
"bin/maf/run_moving_join",
25+
"bin/movingObjects/makeLSSTobs",
26+
"bin/movingObjects/addSeds",
27+
"bin/movingObjects/generateCoefficients",
28+
"bin/rs_download_data",
29+
],
30+
packages=find_packages(),
31+
)

tests/__init__.py

Whitespace-only changes.

tests/photUtils/test_BandpassDict.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import numpy as np
55
from rubin_sim.photUtils import Bandpass, Sed, BandpassDict, SedList
66
from rubin_sim.data import get_data_dir
7-
from rubin_sim.utils import getPackageDir
87
import rubin_sim
98

109

@@ -14,7 +13,7 @@ def setUp(self):
1413
self.rng = np.random.RandomState(32)
1514
self.bandpassPossibilities = ['u', 'g', 'r', 'i', 'z', 'y']
1615
self.bandpassDir = os.path.join(get_data_dir(), 'throughputs', 'baseline')
17-
self.sedDir = os.path.join(getPackageDir(rubin_sim), 'tests', 'photUtils',
16+
self.sedDir = os.path.join('tests', 'photUtils',
1817
'cartoonSedTestData/galaxySed')
1918
self.sedPossibilities = os.listdir(self.sedDir)
2019

@@ -662,7 +661,7 @@ def testLoadTotalBandpassesFromFiles(self):
662661
expected result
663662
"""
664663

665-
bandpassDir = os.path.join(getPackageDir(rubin_sim), 'tests', 'photUtils',
664+
bandpassDir = os.path.join('tests', 'photUtils',
666665
'cartoonSedTestData')
667666
bandpassNames = ['g', 'r', 'u']
668667
bandpassRoot = 'test_bandpass_'
@@ -697,7 +696,7 @@ def testLoadBandpassesFromFiles(self):
697696
expected result
698697
"""
699698

700-
fileDir = os.path.join(getPackageDir(rubin_sim), 'tests', 'photUtils',
699+
fileDir = os.path.join('tests', 'photUtils',
701700
'cartoonSedTestData')
702701
bandpassNames = ['g', 'z', 'i']
703702
bandpassRoot = 'test_bandpass_'

tests/photUtils/test_Photometry.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
import unittest
5-
from rubin_sim.utils import ObservationMetaData, getPackageDir
5+
from rubin_sim.utils import ObservationMetaData
66
from rubin_sim.utils.CodeUtilities import sims_clean_up
77
from rubin_sim.photUtils.Bandpass import Bandpass
88
from rubin_sim.photUtils.Sed import Sed
@@ -36,9 +36,7 @@ def testAlternateBandpassesStars(self):
3636
that some default value did not change and the code actually ended up loading the
3737
LSST bandpasses.
3838
"""
39-
package_dir = getPackageDir(rubin_sim)
40-
41-
bandpassDir = os.path.join(package_dir, 'tests/photUtils', 'cartoonSedTestData')
39+
bandpassDir = os.path.join('tests', 'photUtils', 'cartoonSedTestData')
4240

4341
cartoon_dict = BandpassDict.loadTotalBandpassesFromFiles(['u', 'g', 'r', 'i', 'z'],
4442
bandpassDir=bandpassDir,
@@ -57,7 +55,7 @@ def testAlternateBandpassesStars(self):
5755
sedObj = Sed()
5856
phiArray, waveLenStep = sedObj.setupPhiArray(bplist)
5957

60-
sedFileName = os.path.join(package_dir, 'tests/photUtils',
58+
sedFileName = os.path.join('tests/photUtils',
6159
'cartoonSedTestData/starSed/')
6260
sedFileName = os.path.join(sedFileName, 'kurucz', 'km20_5750.fits_g40_5790.gz')
6361
ss = Sed()

tests/photUtils/test_SNR.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66
from rubin_sim.photUtils import Sed, Bandpass, PhotometricParameters, LSSTdefaults
77
from rubin_sim.photUtils.utils import setM5
88
import rubin_sim
9-
from rubin_sim.utils import getPackageDir
109
from rubin_sim.data import get_data_dir
1110

1211
class TestSNRmethods(unittest.TestCase):
1312

1413
def setUp(self):
1514

16-
package_dir = getPackageDir(rubin_sim)
17-
starName = os.path.join(package_dir,
18-
'tests/photUtils/cartoonSedTestData/starSed/')
15+
starName = os.path.join('tests', 'photUtils', 'cartoonSedTestData', 'starSed')
1916
starName = os.path.join(starName, 'kurucz', 'km20_5750.fits_g40_5790.gz')
2017
self.starSED = Sed()
2118
self.starSED.readSED_flambda(starName)
@@ -113,7 +110,7 @@ def testSignalToNoise(self):
113110
self.hardwareList[i],
114111
photParams, FWHMeff=defaults.FWHMeff(self.filterNameList[i])))
115112

116-
sedDir = os.path.join(getPackageDir(rubin_sim), 'tests/photUtils',
113+
sedDir = os.path.join('tests', 'photUtils',
117114
'cartoonSedTestData/starSed/')
118115
sedDir = os.path.join(sedDir, 'kurucz')
119116
fileNameList = os.listdir(sedDir)

tests/photUtils/test_Sed.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import rubin_sim.photUtils.Bandpass as Bandpass
1111
from rubin_sim.photUtils import PhotometricParameters
1212
import rubin_sim
13-
from rubin_sim.utils import getPackageDir
1413

1514
ROOT = os.path.abspath(os.path.dirname(__file__))
1615

@@ -173,7 +172,7 @@ def test_eq(self):
173172
"""
174173
Test that __eq__ in Sed works correctly
175174
"""
176-
sed_dir = os.path.join(getPackageDir(rubin_sim), 'tests/photUtils',
175+
sed_dir = os.path.join('tests', 'photUtils',
177176
'cartoonSedTestData', 'starSed', 'kurucz')
178177
list_of_seds = os.listdir(sed_dir)
179178
sedname1 = os.path.join(sed_dir, list_of_seds[0])
@@ -203,7 +202,7 @@ def test_cache(self):
203202
with readSED_flambda, it should get stored in the
204203
_global_misc_sed_cache)
205204
"""
206-
sed_dir = os.path.join(getPackageDir(rubin_sim), 'tests/photUtils',
205+
sed_dir = os.path.join('tests', 'photUtils',
207206
'cartoonSedTestData', 'starSed', 'kurucz')
208207

209208
sed_name_list = os.listdir(sed_dir)

tests/photUtils/test_SedList.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44

55
from rubin_sim.photUtils import Bandpass, Sed, SedList
66
import rubin_sim
7-
from rubin_sim.utils import getPackageDir
87
from rubin_sim.data import get_data_dir
98

109

1110
class SedListTest(unittest.TestCase):
1211

1312
def setUp(self):
1413
self.rng = np.random.RandomState(18233)
15-
self.sedDir = os.path.join(getPackageDir(rubin_sim),
16-
'tests/photUtils/cartoonSedTestData/galaxySed/')
14+
self.sedDir = os.path.join('tests', 'photUtils', 'cartoonSedTestData', 'galaxySed')
1715
self.sedPossibilities = os.listdir(self.sedDir)
1816

1917
def getListOfSedNames(self, nNames):

tests/site_models/__init__.py

Whitespace-only changes.

tests/utils/testModules/__init__.py

-1
This file was deleted.

tests/utils/test_ModifiedJulianDate.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import copy
77
import inspect
8-
from rubin_sim.utils import ModifiedJulianDate, UTCtoUT1Warning, getPackageDir
8+
from rubin_sim.utils import ModifiedJulianDate, UTCtoUT1Warning
99
import rubin_sim
1010

1111

@@ -27,7 +27,7 @@ def test_tai_from_utc(self):
2727
API changes in astropy.
2828
"""
2929

30-
file_name = os.path.join(getPackageDir(rubin_sim), 'tests', 'utils')
30+
file_name = os.path.join('tests', 'utils')
3131
file_name = os.path.join(file_name, 'testData', 'utc_tai_comparison_data.txt')
3232

3333
dtype = np.dtype([('utc', float), ('tai', float)])

tests/utils/test_Trixel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from rubin_sim.utils import sphericalFromCartesian, cartesianFromSpherical
1717
from rubin_sim.utils import rotAboutY, rotAboutX, rotAboutZ
18-
from rubin_sim.utils import angularSeparation, _angularSeparation, getPackageDir
18+
from rubin_sim.utils import angularSeparation, _angularSeparation
1919
import rubin_sim
2020

2121

@@ -536,8 +536,8 @@ def test_against_fatboy(self):
536536
Test findHtmid against a random selection of stars from fatboy
537537
"""
538538
dtype = np.dtype([('htmid', int), ('ra', float), ('dec', float)])
539-
data = np.genfromtxt(os.path.join(getPackageDir(rubin_sim), 'tests',
540-
'utils/testData', 'htmid_test_data.txt'),
539+
data = np.genfromtxt(os.path.join('tests',
540+
'utils', 'testData', 'htmid_test_data.txt'),
541541
dtype=dtype)
542542
self.assertGreater(len(data), 20)
543543
for i_pt in range(len(data)):

0 commit comments

Comments
 (0)