Skip to content

Commit 09c5d58

Browse files
authored
Merge pull request #29 from sdss/preptag
Adds tests for configgrp, prep for new tag
2 parents 04531f9 + aeeeabd commit 09c5d58

File tree

6 files changed

+41
-20
lines changed

6 files changed

+41
-20
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.0.1dev
2+
current_version = 2.0.2dev
33
commit = True
44
tag = False
55
tag_name = {new_version}

CHANGELOG.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ Change Log
66

77
This document records the main changes to the sdss_access code.
88

9+
2.0.1 (2022-05-13)
10+
------------------
11+
- Adds new `configgrp` special function.
12+
913
2.0.0 (2021-09-24)
1014
------------------
1115
- Breaking Change: switches `sdss_access` to use new SDSS dtn.sdss.org server
1216
- Feature: adds new "data.sdss5.org" server to support rsync, curl, and http downloads for sdss5 products
1317
- Adding new Sphinx docs for SDSS collaboration authentication
14-
- Updates the public release check to now check todays date against the tree release date, and "DR" in release name.
18+
- Updates the public release check to now check todays date against the tree release date, and "DR" in release name.
1519

1620
1.1.1 (2020-11-11)
1721
------------------

python/sdss_access/path/path.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939

4040

4141
def check_public_release(release: str = None, public: bool = False) -> bool:
42-
""" Check if a release is public
43-
42+
""" Check if a release is public
43+
4444
Checks a given release to see if it is public. A release is public if it
4545
contains "DR" in the release name, and if todays date is <= the release_date
46-
as specified in the Tree.
47-
46+
as specified in the Tree.
47+
4848
Parameters
4949
----------
5050
release : str
@@ -56,15 +56,15 @@ def check_public_release(release: str = None, public: bool = False) -> bool:
5656
-------
5757
bool
5858
If the release if public
59-
59+
6060
Raises
6161
------
6262
AttributeError
6363
when tree does not have a valid release date for a DR tree config
6464
"""
6565
today = datetime.datetime.now().date()
6666
release_date = getattr(tree, 'release_date', None)
67-
67+
6868
# check if tree has a valid release date attr
6969
if release_date is None and "DR" in tree.release:
7070
raise AttributeError("Cannot find a valid release date in the sdss-tree product. Try upgrading to min. version 3.1.0.")
@@ -118,11 +118,11 @@ def __init__(self, release=None, public=False, mirror=False, verbose=False,
118118
self.templates = tree.paths
119119
if self.release:
120120
self.replant_tree(release=self.release)
121-
121+
122122
# set public and mirror keywords
123123
self.public = check_public_release(release=self.release, public=public)
124124
self.mirror = mirror
125-
125+
126126
# set the server location and remote base
127127
self.set_netloc()
128128
self.set_remote_base()
@@ -327,7 +327,7 @@ def extract(self, name, example):
327327
elif re.search('@healpixgrp[|]', template):
328328
template = re.sub('@healpixgrp[|]', '{healpixgrp}', template)
329329
elif re.search('@configgrp[|]', template):
330-
template = re.sub('@configgrp[|]', '{configgrp}', template)
330+
template = re.sub('@configgrp[|]', '{configgrp}', template)
331331
if re.search('@plateid6[|]', template):
332332
template = re.sub('@plateid6[|]', '{plateid:0>6}', template)
333333

@@ -444,8 +444,9 @@ def exists(self, filetype, remote=None, **kwargs):
444444
if remote:
445445
# check for remote existence using a HEAD request
446446
url = self.url('', full=full)
447+
verify = kwargs.get('verify', True)
447448
try:
448-
resp = requests.head(url, allow_redirects=True)
449+
resp = requests.head(url, allow_redirects=True, verify=verify)
449450
except Exception as e:
450451
raise AccessError('Cannot check for remote file existence for {0}: {1}'.format(url, e))
451452
else:

setup.cfg

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = sdss-access
3-
version = 2.0.1dev
3+
version = 2.0.2dev
44
author = Brian Cherinka
55
author_email = bcherinka@stsci.edu
66
description = Package to dynamically build filepaths and access all SDSS SAS products
@@ -34,7 +34,7 @@ package_dir =
3434
install_requires =
3535
six>=1.11
3636
requests>=2.10.0
37-
sdss-tree>=3.0.0
37+
sdss-tree>=3.1.2
3838
sdsstools>=0.4.5
3939
tqdm>=4.46.0
4040

@@ -60,7 +60,7 @@ dev =
6060
pytest-mock>=1.13.0
6161
pytest-sugar>=0.9.2
6262
isort>=4.3.21
63-
codecov>=2.0.15
63+
codecov>=2.0.2dev5
6464
coverage[toml]>=5.0
6565
coveralls>=1.7
6666
ipdb>=0.12.3
@@ -77,6 +77,7 @@ docs =
7777
recommonmark>=0.6
7878
sphinx-issues>=1.2.0
7979
importlib_metadata>=1.6.0
80+
Jinja2<=3.0
8081

8182
[isort]
8283
line_length = 100

tests/path/test_path.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_public(self):
3939
@pytest.mark.parametrize('place, exp', [('local', False), ('remote', True)])
4040
def test_existence(self, path, place, exp):
4141
full = path.full('mangaimage', drpver='v2_5_3', plate=8116, ifu=1901, dir3d='mastar')
42-
exists = path.exists('', full=full, remote=(place == 'remote'))
42+
exists = path.exists('', full=full, remote=(place == 'remote'), verify=False)
4343
assert exp == exists
4444

4545
def test_lookup_names(self, path):
@@ -297,7 +297,7 @@ def test_svn_force_module(self, monkeyoos, path):
297297
path = Path(release='DR15')
298298
ff = path.full('mangapreimg', designid=8405, designgrp='D0084XX', mangaid='1-42007')
299299
assert 'mangapreim/v2_5/data' in ff
300-
300+
301301
ff = path.full('mangapreimg', designid=8405, designgrp='D0084XX', mangaid='1-42007', force_module=True)
302302
assert 'mangapreim/trunk/data' in ff
303303

tests/path/test_sdss5.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,31 @@ def path():
2828
class TestSVPaths(object):
2929

3030
@pytest.mark.parametrize('name, special, keys, exp',
31-
[('apStar', '@apgprefix',
31+
[('apStar', '@healpixgrp',
3232
{'apred': 'r12', 'apstar': 'stars', 'telescope': 'apo25m',
3333
'healpix': '12345', 'obj': '12345'},
34-
'r12/stars/apo25m/12/12345/apStar-r12-12345.fits')],
34+
'r12/stars/apo25m/12/12345/apStar-r12-apo25m-12345.fits')],
3535
ids=['apStar'])
3636
def test_apogee_paths(self, path, name, special, keys, exp):
3737
assert special in path.templates[name]
3838
full = path.full(name, **keys)
3939
assert exp in full
40-
40+
41+
@pytest.mark.parametrize('name, special, keys, exp',
42+
[('confSummary', '@configgrp', {'configid': 1234, 'obs': 'apo'},
43+
'0012XX/confSummary-1234.par'),
44+
('apField', '@apgprefix', {'telescope': 'apo25m', 'apred': 'r12', 'field': '2J01'},
45+
'redux/r12/stars/apo25m/2J01/apField-2J01.fits'),
46+
('apField', '@apgprefix', {'telescope': 'lco25m', 'apred': 'r12', 'field': '2J01'},
47+
'redux/r12/stars/lco25m/2J01/asField-2J01.fits'),
48+
('apHist', '@apgprefix', {'apred': 'r12', 'mjd': '52123', 'chip':'b', 'instrument': 'apogee-n'},
49+
'r12/exposures/apogee-n/52123/apHist-b-52123.fits')],
50+
ids=['configgrp', 'apgprefix-apo', 'apgprefix-lco', 'apgprefix-ins'])
51+
def test_special_function(self, path, name, special, keys, exp):
52+
assert special in path.templates[name]
53+
full = path.full(name, **keys)
54+
assert exp in full
55+
4156
def test_netloc(self, path):
4257
assert path.netloc == 'data.sdss5.org'
4358

0 commit comments

Comments
 (0)