diff --git a/dkist/_dkist_init.py b/dkist/_dkist_init.py index 73a52fb3c..f7214756e 100644 --- a/dkist/_dkist_init.py +++ b/dkist/_dkist_init.py @@ -1,6 +1,6 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst -__all__ = ['__version__', '__githash__', 'test'] +__all__ = ['__version__', '__githash__'] # this indicates whether or not we are in the package's setup.py try: @@ -23,97 +23,14 @@ __githash__ = '' -# set up the test command -def _get_test_runner(): - import os - from astropy.tests.helper import TestRunner - return TestRunner(os.path.dirname(__file__)) - - -def test(package=None, test_path=None, args=None, plugins=None, - verbose=False, pastebin=None, remote_data=False, pep8=False, - pdb=False, coverage=False, open_files=False, **kwargs): - """ - Run the tests using `py.test `__. A proper set - of arguments is constructed and passed to `pytest.main`_. - - .. _py.test: http://pytest.org/latest/ - .. _pytest.main: http://pytest.org/latest/builtin.html#pytest.main - - Parameters - ---------- - package : str, optional - The name of a specific package to test, e.g. 'io.fits' or 'utils'. - If nothing is specified all default tests are run. - - test_path : str, optional - Specify location to test by path. May be a single file or - directory. Must be specified absolutely or relative to the - calling directory. - - args : str, optional - Additional arguments to be passed to pytest.main_ in the ``args`` - keyword argument. - - plugins : list, optional - Plugins to be passed to pytest.main_ in the ``plugins`` keyword - argument. - - verbose : bool, optional - Convenience option to turn on verbose output from py.test_. Passing - True is the same as specifying ``'-v'`` in ``args``. +if not _ASTROPY_SETUP_: + __all__ += ['test'] - pastebin : {'failed','all',None}, optional - Convenience option for turning on py.test_ pastebin output. Set to - ``'failed'`` to upload info for failed tests, or ``'all'`` to upload - info for all tests. - - remote_data : bool, optional - Controls whether to run tests marked with @remote_data. These - tests use online data and are not run by default. Set to True to - run these tests. - - pep8 : bool, optional - Turn on PEP8 checking via the `pytest-pep8 plugin - `_ and disable normal - tests. Same as specifying ``'--pep8 -k pep8'`` in ``args``. - - pdb : bool, optional - Turn on PDB post-mortem analysis for failing tests. Same as - specifying ``'--pdb'`` in ``args``. - - coverage : bool, optional - Generate a test coverage report. The result will be placed in - the directory htmlcov. - - open_files : bool, optional - Fail when any tests leave files open. Off by default, because - this adds extra run time to the test suite. Requires the - `psutil `_ package. - - parallel : int, optional - When provided, run the tests in parallel on the specified - number of CPUs. If parallel is negative, it will use the all - the cores on the machine. Requires the - `pytest-xdist `_ plugin - installed. Only available when using Astropy 0.3 or later. - - kwargs - Any additional keywords passed into this function will be passed - on to the astropy test runner. This allows use of test-related - functionality implemented in later versions of astropy without - explicitly updating the package template. + import os + from astropy.tests.runner import TestRunner - """ - test_runner = _get_test_runner() - return test_runner.run_tests( - package=package, test_path=test_path, args=args, - plugins=plugins, verbose=verbose, pastebin=pastebin, - remote_data=remote_data, pep8=pep8, pdb=pdb, - coverage=coverage, open_files=open_files, **kwargs) + test = TestRunner.make_test_runner_in(os.path.dirname(__file__)) -if not _ASTROPY_SETUP_: # noqa - import os from warnings import warn from astropy.config.configuration import ( update_default_config, @@ -129,10 +46,10 @@ def test(package=None, test_path=None, args=None, plugins=None, if os.path.isfile(config_template): try: update_default_config( - __package__, config_dir, version=__version__) + __package__, config_dir, version=__version__, rootname='dkist') except TypeError as orig_error: try: - update_default_config(__package__, config_dir) + update_default_config(__package__, config_dir, rootname='dkist') except ConfigurationDefaultMissingError as e: wmsg = (e.args[0] + " Cannot install default profile. If you are " diff --git a/dkist/config/__init__.py b/dkist/config/__init__.py new file mode 100644 index 000000000..5981e96ed --- /dev/null +++ b/dkist/config/__init__.py @@ -0,0 +1,9 @@ +import astropy.config as astropyconfig + + +class ConfigNamespace(astropyconfig.ConfigNamespace): + rootname = 'dkist' + + +class ConfigItem(astropyconfig.ConfigItem): + rootname = 'dkist' diff --git a/dkist/dkist.cfg b/dkist/dkist.cfg new file mode 100644 index 000000000..6fe94a1da --- /dev/null +++ b/dkist/dkist.cfg @@ -0,0 +1,3 @@ +[io] +## Name of Preferred fits module +# preferred_fits_library = 'astropy' diff --git a/dkist/io/__init__.py b/dkist/io/__init__.py new file mode 100644 index 000000000..2a16db4fd --- /dev/null +++ b/dkist/io/__init__.py @@ -0,0 +1,20 @@ +from .fits import BaseFITSLoader, AstropyFITSLoader +from .dask import BaseFITSArrayContainer, NumpyFITSArrayContainer, DaskFITSArrayContainer + +__all__ = ['BaseFITSLoader', 'AstropyFITSLoader', 'BaseFITSArrayContainer', + 'NumpyFITSArrayContainer', 'DaskFITSArrayContainer', 'conf'] + + +import dkist.config as _config + + +class Conf(_config.ConfigNamespace): + """ + Configuration Parameters for the IO Package. + """ + + preferred_fits_library = _config.ConfigItem('astropy', + "Name of the preferred FITS module.") + + +conf = Conf() diff --git a/dkist/io/fits.py b/dkist/io/fits.py index 77b04aff1..a6e1bedb0 100644 --- a/dkist/io/fits.py +++ b/dkist/io/fits.py @@ -8,6 +8,9 @@ from astropy.io import fits +__all__ = ['BaseFITSLoader', 'AstropyFITSLoader'] + + class BaseFITSLoader(metaclass=abc.ABCMeta): def __init__(self, externalarray):