Skip to content

Commit

Permalink
Merge pull request #114 from pllim/setup-cleanup-🧹
Browse files Browse the repository at this point in the history
MNT: Infrastructure update
  • Loading branch information
pllim authored Mar 26, 2020
2 parents b2a7ab6 + d6d68c2 commit 22fec3b
Show file tree
Hide file tree
Showing 29 changed files with 230 additions and 180 deletions.
2 changes: 2 additions & 0 deletions .bandit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exclude_dirs:
- acstools/tests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ sdist
develop-eggs
.installed.cfg
distribute-*.tar.gz
pip-wheel-metadata/
acstools/version.py

# Other
.cache
Expand Down
5 changes: 3 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ python:
version: 3.7
system_packages: true
install:
- requirements: doc/rtd-pip-requirements
- method: setuptools
- method: pip
path: .
extra_requirements:
- docs

# Don't build any extra formats
formats: []
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/spacetelescope/acstools/releases
19 changes: 6 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,18 @@ bc1.name = "release"
// Would be nice if Jenkins can access /grp/hst/cdbs/xxxx directly.
bc1.env_vars = ['TEST_BIGDATA=https://bytesalad.stsci.edu/artifactory']
bc1.conda_channels = ['http://ssb.stsci.edu/astroconda']
bc1.conda_packages = ['python=3.6',
'requests',
'numpy',
'matplotlib',
'scipy',
'stsci.tools']
bc1.build_cmds = ["pip install scikit-image ci-watson",
"python setup.py install"]
bc1.conda_packages = ['python=3.6']
bc1.build_cmds = ["pip install -e .[test,all]"]
bc1.test_cmds = ["pytest --basetemp=tests_output --junitxml results.xml --bigdata -v"]
bc1.failedUnstableThresh = 1
bc1.failedFailureThresh = 6

// Run with astropy dev and Python 3.7
// Run with astropy dev and Python 3.8
bc2 = utils.copy(bc1)
bc2.name = "dev"
bc2.conda_packages[0] = "python=3.7"
bc2.build_cmds = ["pip install scikit-image ci-watson",
"pip install git+https://github.com/astropy/astropy.git#egg=astropy --upgrade --no-deps",
"python setup.py install"]
bc2.conda_packages[0] = "python=3.8"
bc2.build_cmds = ["pip install git+https://github.com/astropy/astropy.git#egg=astropy --upgrade --no-deps",
"pip install -e .[test,all]"]

// Iterate over configurations that define the (distibuted) build matrix.
// Spawn a host of the given nodetype for each combination and run in parallel.
Expand Down
19 changes: 6 additions & 13 deletions JenkinsfileRT
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,18 @@ bc.name = "release"
bc.env_vars = ['TEST_BIGDATA=https://bytesalad.stsci.edu/artifactory',
'jref=/grp/hst/cdbs/jref/']
bc.conda_channels = ['http://ssb.stsci.edu/astroconda']
bc.conda_packages = ['python=3.6',
'requests',
'numpy',
'matplotlib',
'scipy',
'stsci.tools']
bc.build_cmds = ["pip install scikit-image ci-watson",
"python setup.py install"]
bc.conda_packages = ['python=3.6']
bc.build_cmds = ["pip install -e .[test,all]"]
bc.test_cmds = ["pytest --basetemp=tests_output --junitxml results.xml --bigdata --slow -v"]
bc.failedUnstableThresh = 1
bc.failedFailureThresh = 6

// Astropy dev and Python 3.7
// Astropy dev and Python 3.8
bc1 = utils.copy(bc)
bc1.name = "dev"
bc1.conda_packages[0] = "python=3.7"
bc1.build_cmds = ["pip install scikit-image",
"pip install git+https://github.com/astropy/astropy.git#egg=astropy --upgrade --no-deps",
"python setup.py install"]
bc1.conda_packages[0] = "python=3.8"
bc1.build_cmds = ["pip install git+https://github.com/astropy/astropy.git#egg=astropy --upgrade --no-deps",
"pip install -e .[test,all]"]

// Iterate over configurations that define the (distributed) build matrix.
// Spawn a host (or workdir) for each combination and run in parallel.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2018, Space Telescope Science Institute, AURA
Copyright (c) 2020, Space Telescope Science Institute, AURA
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include README.rst
include LICENSE.txt
include CHANGES.rst
include setup.cfg
include pyproject.toml
recursive-include doc *

prune build
Expand Down
44 changes: 17 additions & 27 deletions acstools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
"""The acstools package holds Python tasks useful for analyzing ACS data.
These tasks include:
Utility and library functions used by these tasks are also included in this
module.
"""
from pkg_resources import get_distribution, DistributionNotFound


"""The acstools package holds Python tasks useful for analyzing ACS data."""
try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from .version import version as __version__
except ImportError:
# package is not installed
__version__ = 'unknown'
__version__ = ''


from . import acs_destripe
from . import acs_destripe_plus
from . import calacs
from . import acsccd
from . import acscte
from . import acscteforwardmodel
from . import acs2d
from . import acsrej
from . import acssum
from . import acszpt
from . import acsphotcte
from . import satdet
from . import utils_calib
from . import acs_destripe # noqa
from . import acs_destripe_plus # noqa
from . import calacs # noqa
from . import acsccd # noqa
from . import acscte # noqa
from . import acscteforwardmodel # noqa
from . import acs2d # noqa
from . import acsrej # noqa
from . import acssum # noqa
from . import acszpt # noqa
from . import acsphotcte # noqa
from . import satdet # noqa
from . import utils_calib # noqa
4 changes: 2 additions & 2 deletions acstools/acs2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""
# STDLIB
import os
import subprocess
import subprocess # nosec

__taskname__ = "acs2d"
__version__ = "2.0"
Expand Down Expand Up @@ -98,4 +98,4 @@ def acs2d(input, exec_path='', time_stamps=False, verbose=False, quiet=False,
if exe_args:
call_list.extend(exe_args)

subprocess.check_call(call_list)
subprocess.check_call(call_list) # nosec
12 changes: 8 additions & 4 deletions acstools/acs_destripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ def clean(input, suffix, stat="pmode1", maxiter=15, sigrej=2.0,
background in image rows:
* 'pmode1' - SEXTRACTOR-like mode estimate based on a
modified `Pearson's rule <http://en.wikipedia.org/wiki/Nonparametric_skew#Pearson.27s_rule>`_:
modified `Pearson's rule <https://en.wikipedia.org/wiki/Nonparametric_skew#Pearson.27s_rule>`_:
``2.5*median-1.5*mean``;
* 'pmode2' - mode estimate based on
`Pearson's rule <http://en.wikipedia.org/wiki/Nonparametric_skew#Pearson.27s_rule>`_:
`Pearson's rule <https://en.wikipedia.org/wiki/Nonparametric_skew#Pearson.27s_rule>`_:
``3*median-2*mean``;
* 'mean' - the mean of the distribution of the "good" pixels (after
clipping, masking, etc.);
Expand Down Expand Up @@ -690,7 +690,9 @@ def getcorr(): return (SMedian)
def getcorr():
imstat = ImageStats(image.science[i][BMask], 'mode',
lower=lower, upper=upper, nclip=0)
assert(imstat.npix == NPix)
if imstat.npix != NPix:
raise ValueError('imstate.npix ({}) != NPix ({})'.format(
imstat.npix, NPix))
return (imstat.mode)

elif stat == 'midpt':
Expand All @@ -700,7 +702,9 @@ def getcorr():
def getcorr():
imstat = ImageStats(image.science[i][BMask], 'midpt',
lower=lower, upper=upper, nclip=0)
assert(imstat.npix == NPix)
if imstat.npix != NPix:
raise ValueError('imstate.npix ({}) != NPix ({})'.format(
imstat.npix, NPix))
return (imstat.midpt)

nmax_rpt = 1 if rpt_clean is None else max(1, rpt_clean+1)
Expand Down
8 changes: 4 additions & 4 deletions acstools/acs_destripe_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# STDLIB
import logging
import os
import subprocess
import subprocess # nosec

# ASTROPY
from astropy.time import Time
Expand Down Expand Up @@ -135,10 +135,10 @@ def destripe_plus(inputfile, suffix='strp', stat='pmode1', maxiter=15,
background in image rows:
* 'pmode1' - SEXTRACTOR-like mode estimate based on a
modified `Pearson's rule <http://en.wikipedia.org/wiki/Nonparametric_skew#Pearson.27s_rule>`_:
modified `Pearson's rule <https://en.wikipedia.org/wiki/Nonparametric_skew#Pearson.27s_rule>`_:
``2.5*median-1.5*mean``;
* 'pmode2' - mode estimate based on
`Pearson's rule <http://en.wikipedia.org/wiki/Nonparametric_skew#Pearson.27s_rule>`_:
`Pearson's rule <https://en.wikipedia.org/wiki/Nonparametric_skew#Pearson.27s_rule>`_:
``3*median-2*mean``;
* 'mean' - the mean of the distribution of the "good" pixels (after
clipping, masking, etc.);
Expand Down Expand Up @@ -366,7 +366,7 @@ def destripe_plus(inputfile, suffix='strp', stat='pmode1', maxiter=15,
raise ValueError("Both 'scimask1' and 'scimask2' must be specified "
"or not specified together.")

calacs_str = subprocess.check_output(['calacs.e', '--version']).split()[0]
calacs_str = subprocess.check_output(['calacs.e', '--version']).split()[0] # nosec # noqa
calacs_ver = [int(x) for x in calacs_str.decode().split('.')]
if calacs_ver < [8, 3, 1]:
raise ValueError('CALACS {0} is incomptible. '
Expand Down
4 changes: 2 additions & 2 deletions acstools/acsccd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""
# STDLIB
import os
import subprocess
import subprocess # nosec

__taskname__ = "acsccd"
__version__ = "2.0"
Expand Down Expand Up @@ -112,4 +112,4 @@ def acsccd(input, exec_path='', time_stamps=False, verbose=False, quiet=False,
#if biascorr:
# call_list.append('-bias')

subprocess.check_call(call_list)
subprocess.check_call(call_list) # nosec
4 changes: 2 additions & 2 deletions acstools/acscte.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""
# STDLIB
import os
import subprocess
import subprocess # nosec

__taskname__ = "acscte"
__version__ = "1.0"
Expand Down Expand Up @@ -99,4 +99,4 @@ def acscte(input, exec_path='', time_stamps=False, verbose=False, quiet=False,
if exe_args:
call_list.extend(exe_args)

subprocess.check_call(call_list)
subprocess.check_call(call_list) # nosec
4 changes: 2 additions & 2 deletions acstools/acscteforwardmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""
# STDLIB
import os
import subprocess
import subprocess # nosec

__taskname__ = "acscteforwardmodel"
__version__ = "1.0"
Expand Down Expand Up @@ -103,4 +103,4 @@ def acscteforwardmodel(input, exec_path='', time_stamps=False, verbose=False,
if exe_args:
call_list.extend(exe_args)

subprocess.check_call(call_list)
subprocess.check_call(call_list) # nosec
13 changes: 5 additions & 8 deletions acstools/acsphotcte.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,18 @@ def _check_inputs(self, **inputs):
return key
# the last step is to ensure all the iterable inputs are the same length
nl = "\n"
try:
# First we check if there were any iterable inputs
if iterable_lengths:
# if there are we make sure theyre all the same size
assert len(set(iterable_lengths)) == 1
except AssertionError:
# First we check if there were any iterable inputs.
# If there are, we make sure theyre all the same size.
if iterable_lengths and len(set(iterable_lengths)) != 1:
iterable_lengths = list(map(str, iterable_lengths))
msg = (
"Iterable inputs are not the same length.\n"
f"Computed lengths:\n{nl.join(iterable_lengths)}"
)
LOG.error(msg)
return
else:
return inputs

return inputs

def correct_photometry(
self,
Expand Down
4 changes: 2 additions & 2 deletions acstools/acsrej.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""
# STDLIB
import os
import subprocess
import subprocess # nosec
import warnings

__taskname__ = "acsrej"
Expand Down Expand Up @@ -186,4 +186,4 @@ def acsrej(input, output, exec_path='', time_stamps=False, verbose=False,
if exe_args:
call_list.extend(exe_args)

subprocess.check_call(call_list)
subprocess.check_call(call_list) # nosec
4 changes: 2 additions & 2 deletions acstools/acssum.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""
# STDLIB
import os
import subprocess
import subprocess # nosec

__taskname__ = "acssum"
__version__ = "1.0"
Expand Down Expand Up @@ -89,4 +89,4 @@ def acssum(input, output, exec_path='', time_stamps=False, verbose=False,
if exe_args:
call_list.extend(exe_args)

subprocess.check_call(call_list)
subprocess.check_call(call_list) # nosec
4 changes: 3 additions & 1 deletion acstools/acszpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,10 @@ def _submit_request(self):
attribute.
"""
if not self._url.startswith('http'):
raise ValueError(f'Invalid URL {self._url}')
try:
self._response = urlopen(self._url)
self._response = urlopen(self._url) # nosec
except URLError as e:
msg = ('{}\n{}\nThe query failed! Please check your inputs. '
'If the error persists, submit a ticket to the '
Expand Down
4 changes: 2 additions & 2 deletions acstools/calacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""
import os
import subprocess
import subprocess # nosec

__all__ = ['calacs']

Expand Down Expand Up @@ -93,4 +93,4 @@ def calacs(input_file, exec_path=None, time_stamps=False, temp_files=False,
if exe_args:
call_list.extend(exe_args)

subprocess.check_call(call_list)
subprocess.check_call(call_list) # nosec
Loading

0 comments on commit 22fec3b

Please sign in to comment.