From 60c5ed3f177a5bf5e4815a47c08283589a6b0412 Mon Sep 17 00:00:00 2001 From: Maximilian Linhoff Date: Tue, 6 Dec 2022 11:12:55 +0100 Subject: [PATCH] Fix editable installs by switching to src layout, fixes #162 --- .github/workflows/ci.yml | 6 +++ eventsource_subclasses.py | 5 ++ pyproject.toml | 5 +- setup.cfg | 48 ++++++++++++++++-- setup.py | 21 +------- .../ctapipe_io_lst}/__init__.py | 0 .../ctapipe_io_lst}/_dev_version/__init__.py | 0 src/ctapipe_io_lst/_version.py | 5 ++ .../ctapipe_io_lst}/anyarray_dtypes.py | 0 .../ctapipe_io_lst}/calibration.py | 0 .../ctapipe_io_lst}/constants.py | 0 .../ctapipe_io_lst}/containers.py | 0 .../ctapipe_io_lst}/event_time.py | 0 .../ctapipe_io_lst}/multifiles.py | 0 .../ctapipe_io_lst}/pointing.py | 0 .../resources/LSTCam.camgeom.fits.gz | Bin .../resources/no_corrections_pulse_LST.dat | 0 ...ampled_pulse_LST_8dynode_pix6_20200204.dat | 0 .../resources/calibration.Run2462.0000.hdf5 | Bin .../drs4_pedestal.Run2460.0000.fits.gz | Bin .../tests/resources/first_caps.hdf5 | Bin .../ctapipe_io_lst}/tests/test_calib.py | 9 ++-- .../ctapipe_io_lst}/tests/test_event_time.py | 0 .../tests/test_lsteventsource.py | 0 .../ctapipe_io_lst}/tests/test_multifile.py | 0 .../ctapipe_io_lst}/tests/test_pointing.py | 0 .../ctapipe_io_lst}/tests/test_stage1.py | 9 ++-- .../ctapipe_io_lst}/tests/test_version.py | 0 .../ctapipe_io_lst}/version.py | 0 29 files changed, 78 insertions(+), 30 deletions(-) create mode 100644 eventsource_subclasses.py rename {ctapipe_io_lst => src/ctapipe_io_lst}/__init__.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/_dev_version/__init__.py (100%) create mode 100644 src/ctapipe_io_lst/_version.py rename {ctapipe_io_lst => src/ctapipe_io_lst}/anyarray_dtypes.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/calibration.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/constants.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/containers.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/event_time.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/multifiles.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/pointing.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/resources/LSTCam.camgeom.fits.gz (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/resources/no_corrections_pulse_LST.dat (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/resources/oversampled_pulse_LST_8dynode_pix6_20200204.dat (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/resources/calibration.Run2462.0000.hdf5 (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/resources/drs4_pedestal.Run2460.0000.fits.gz (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/resources/first_caps.hdf5 (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/test_calib.py (94%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/test_event_time.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/test_lsteventsource.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/test_multifile.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/test_pointing.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/test_stage1.py (91%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/tests/test_version.py (100%) rename {ctapipe_io_lst => src/ctapipe_io_lst}/version.py (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbe72463..d407e5ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,6 +50,12 @@ jobs: pip install pytest-cov "git+https://github.com/cta-observatory/ctapipe@$CTAPIPE_VERSION" git describe --tags + - name: Test Plugin + shell: bash -l {0} + run: | + # check the LSTEventSource is available for LST + python eventsource_subclasses.py | grep LSTEventSource + - name: Download test data env: TEST_DATA_USER: ${{ secrets.test_data_user }} diff --git a/eventsource_subclasses.py b/eventsource_subclasses.py new file mode 100644 index 00000000..3ddaeac2 --- /dev/null +++ b/eventsource_subclasses.py @@ -0,0 +1,5 @@ +from ctapipe.io import EventSource +from ctapipe.core import non_abstract_children + +for cls in non_abstract_children(EventSource): + print(cls.__name__) diff --git a/pyproject.toml b/pyproject.toml index 16a5dd9f..99157694 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ [build-system] -requires = ["setuptools >= 40.6.0", "wheel", "setuptools_scm[toml]>=3.4"] +requires = ["setuptools >= 64.0.3", "setuptools_scm[toml]>=3.4"] build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +write_to = "src/ctapipe_io_lst/_version.py" diff --git a/setup.cfg b/setup.cfg index 6624af1a..2065e0db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,16 +3,58 @@ name = ctapipe_io_lst description = ctapipe plugin for reading LST prototype files long_description = file: README.md long_description_content_type = text/markdown; charset=UTF-8; variant=GFM -author = LST Consortium -author_email = cassol@cppm.in2p3.fr +author = CTA LST Project +author_email = maximilian.linhoff@tu-dortmund.de license = MIT +project_urls = + Bug Tracker = https://github.com/cta-observatory/ctapipe_io_lst/issues + Source Code = https://github.com/cta-observatory/ctapipe_io_lst + +classifiers = + Development Status :: 4 - Beta + License :: OSI Approved :: MIT License + Intended Audience :: Science/Research + Topic :: Scientific/Engineering :: Astronomy + Topic :: Scientific/Engineering :: Physics + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + + +[options] +packages = find: +package_dir = + = src +python_requires = >=3.8 +zip_safe = False +install_requires= + astropy~=5.0 + ctapipe~=0.17.0 + protozfits~=2.0 + numpy>=1.20 + +[options.package_data] +* = resources/* + +[options.packages.find] +exclude = + ctapipe_io_lst._dev_version + +[options.extras_require] +tests = + pytest +dev = + setuptools_scm[toml] +all = + %(tests)s + %(dev)s [tool:pytest] minversion = 3.0 addopts = -v - [aliases] test = pytest diff --git a/setup.py b/setup.py index 7934fb30..8bf1ba93 100755 --- a/setup.py +++ b/setup.py @@ -1,19 +1,2 @@ -from setuptools import setup, find_packages -import os - -setup( - packages=find_packages(exclude=["ctapipe_io_lst._dev_version"]), - use_scm_version={"write_to": os.path.join("ctapipe_io_lst", "_version.py")}, - python_requires=">=3.8", - install_requires=[ - 'astropy~=5.0', - 'ctapipe~=0.17.0', - 'protozfits~=2.0', - 'setuptools_scm', - 'numpy>=1.20' - ], - package_data={ - 'ctapipe_io_lst': ['resources/*'], - }, - tests_require=['pytest'], -) +from setuptools import setup +setup() diff --git a/ctapipe_io_lst/__init__.py b/src/ctapipe_io_lst/__init__.py similarity index 100% rename from ctapipe_io_lst/__init__.py rename to src/ctapipe_io_lst/__init__.py diff --git a/ctapipe_io_lst/_dev_version/__init__.py b/src/ctapipe_io_lst/_dev_version/__init__.py similarity index 100% rename from ctapipe_io_lst/_dev_version/__init__.py rename to src/ctapipe_io_lst/_dev_version/__init__.py diff --git a/src/ctapipe_io_lst/_version.py b/src/ctapipe_io_lst/_version.py new file mode 100644 index 00000000..14dde87d --- /dev/null +++ b/src/ctapipe_io_lst/_version.py @@ -0,0 +1,5 @@ +# coding: utf-8 +# file generated by setuptools_scm +# don't change, don't track in version control +__version__ = version = '0.19a1.dev1+g3796a1c2.d20221206' +__version_tuple__ = version_tuple = (0, 19, 'dev1', 'g3796a1c2.d20221206') diff --git a/ctapipe_io_lst/anyarray_dtypes.py b/src/ctapipe_io_lst/anyarray_dtypes.py similarity index 100% rename from ctapipe_io_lst/anyarray_dtypes.py rename to src/ctapipe_io_lst/anyarray_dtypes.py diff --git a/ctapipe_io_lst/calibration.py b/src/ctapipe_io_lst/calibration.py similarity index 100% rename from ctapipe_io_lst/calibration.py rename to src/ctapipe_io_lst/calibration.py diff --git a/ctapipe_io_lst/constants.py b/src/ctapipe_io_lst/constants.py similarity index 100% rename from ctapipe_io_lst/constants.py rename to src/ctapipe_io_lst/constants.py diff --git a/ctapipe_io_lst/containers.py b/src/ctapipe_io_lst/containers.py similarity index 100% rename from ctapipe_io_lst/containers.py rename to src/ctapipe_io_lst/containers.py diff --git a/ctapipe_io_lst/event_time.py b/src/ctapipe_io_lst/event_time.py similarity index 100% rename from ctapipe_io_lst/event_time.py rename to src/ctapipe_io_lst/event_time.py diff --git a/ctapipe_io_lst/multifiles.py b/src/ctapipe_io_lst/multifiles.py similarity index 100% rename from ctapipe_io_lst/multifiles.py rename to src/ctapipe_io_lst/multifiles.py diff --git a/ctapipe_io_lst/pointing.py b/src/ctapipe_io_lst/pointing.py similarity index 100% rename from ctapipe_io_lst/pointing.py rename to src/ctapipe_io_lst/pointing.py diff --git a/ctapipe_io_lst/resources/LSTCam.camgeom.fits.gz b/src/ctapipe_io_lst/resources/LSTCam.camgeom.fits.gz similarity index 100% rename from ctapipe_io_lst/resources/LSTCam.camgeom.fits.gz rename to src/ctapipe_io_lst/resources/LSTCam.camgeom.fits.gz diff --git a/ctapipe_io_lst/resources/no_corrections_pulse_LST.dat b/src/ctapipe_io_lst/resources/no_corrections_pulse_LST.dat similarity index 100% rename from ctapipe_io_lst/resources/no_corrections_pulse_LST.dat rename to src/ctapipe_io_lst/resources/no_corrections_pulse_LST.dat diff --git a/ctapipe_io_lst/resources/oversampled_pulse_LST_8dynode_pix6_20200204.dat b/src/ctapipe_io_lst/resources/oversampled_pulse_LST_8dynode_pix6_20200204.dat similarity index 100% rename from ctapipe_io_lst/resources/oversampled_pulse_LST_8dynode_pix6_20200204.dat rename to src/ctapipe_io_lst/resources/oversampled_pulse_LST_8dynode_pix6_20200204.dat diff --git a/ctapipe_io_lst/tests/resources/calibration.Run2462.0000.hdf5 b/src/ctapipe_io_lst/tests/resources/calibration.Run2462.0000.hdf5 similarity index 100% rename from ctapipe_io_lst/tests/resources/calibration.Run2462.0000.hdf5 rename to src/ctapipe_io_lst/tests/resources/calibration.Run2462.0000.hdf5 diff --git a/ctapipe_io_lst/tests/resources/drs4_pedestal.Run2460.0000.fits.gz b/src/ctapipe_io_lst/tests/resources/drs4_pedestal.Run2460.0000.fits.gz similarity index 100% rename from ctapipe_io_lst/tests/resources/drs4_pedestal.Run2460.0000.fits.gz rename to src/ctapipe_io_lst/tests/resources/drs4_pedestal.Run2460.0000.fits.gz diff --git a/ctapipe_io_lst/tests/resources/first_caps.hdf5 b/src/ctapipe_io_lst/tests/resources/first_caps.hdf5 similarity index 100% rename from ctapipe_io_lst/tests/resources/first_caps.hdf5 rename to src/ctapipe_io_lst/tests/resources/first_caps.hdf5 diff --git a/ctapipe_io_lst/tests/test_calib.py b/src/ctapipe_io_lst/tests/test_calib.py similarity index 94% rename from ctapipe_io_lst/tests/test_calib.py rename to src/ctapipe_io_lst/tests/test_calib.py index bec7fe33..7e848a42 100644 --- a/ctapipe_io_lst/tests/test_calib.py +++ b/src/ctapipe_io_lst/tests/test_calib.py @@ -14,13 +14,14 @@ test_data = Path(os.getenv('LSTCHAIN_TEST_DATA', 'test_data')) test_r0_path = test_data / 'real/R0/20200218/LST-1.1.Run02008.0000_first50.fits.fz' test_r0_calib_path = test_data / 'real/R0/20200218/LST-1.1.Run02006.0004.fits.fz' -test_calib_path = test_data / 'real/monitoring/PixelCalibration/LevelA/calibration/20200218/v0.8.2.post2.dev48+gb1343281/calibration_filters_52.Run02006.0000.h5' -test_drs4_pedestal_path = test_data / 'real/monitoring/PixelCalibration/LevelA/drs4_baseline/20200218/v0.8.2.post2.dev48+gb1343281/drs4_pedestal.Run02005.0000.h5' -test_time_calib_path = test_data / 'real/monitoring/PixelCalibration/LevelA/drs4_time_sampling_from_FF/20191124/v0.8.2.post2.dev48+gb1343281/time_calibration.Run01625.0000.h5' test_missing_module_path = test_data / 'real/R0/20210215/LST-1.1.Run03669.0000_first50.fits.fz' test_r0_gainselected_path = test_data / 'real/R0/20200218/LST-1.1.Run02008.0000_first50_gainselected.fits.fz' - +calib_version = "ctapipe-v0.17" +calib_path = test_data / 'real/monitoring/PixelCalibration/Cat-A/' +test_calib_path = calib_path / f'calibration/20200218/{calib_version}/calibration_filters_52.Run02006.0000.h5' +test_drs4_pedestal_path = calib_path / f'drs4_baseline/20200218/{calib_version}/drs4_pedestal.Run02005.0000.h5' +test_time_calib_path = calib_path / f'drs4_time_sampling_from_FF/20191124/{calib_version}/time_calibration.Run01625.0000.h5' def test_get_first_capacitor(): diff --git a/ctapipe_io_lst/tests/test_event_time.py b/src/ctapipe_io_lst/tests/test_event_time.py similarity index 100% rename from ctapipe_io_lst/tests/test_event_time.py rename to src/ctapipe_io_lst/tests/test_event_time.py diff --git a/ctapipe_io_lst/tests/test_lsteventsource.py b/src/ctapipe_io_lst/tests/test_lsteventsource.py similarity index 100% rename from ctapipe_io_lst/tests/test_lsteventsource.py rename to src/ctapipe_io_lst/tests/test_lsteventsource.py diff --git a/ctapipe_io_lst/tests/test_multifile.py b/src/ctapipe_io_lst/tests/test_multifile.py similarity index 100% rename from ctapipe_io_lst/tests/test_multifile.py rename to src/ctapipe_io_lst/tests/test_multifile.py diff --git a/ctapipe_io_lst/tests/test_pointing.py b/src/ctapipe_io_lst/tests/test_pointing.py similarity index 100% rename from ctapipe_io_lst/tests/test_pointing.py rename to src/ctapipe_io_lst/tests/test_pointing.py diff --git a/ctapipe_io_lst/tests/test_stage1.py b/src/ctapipe_io_lst/tests/test_stage1.py similarity index 91% rename from ctapipe_io_lst/tests/test_stage1.py rename to src/ctapipe_io_lst/tests/test_stage1.py index 8694d82e..39a9adab 100644 --- a/ctapipe_io_lst/tests/test_stage1.py +++ b/src/ctapipe_io_lst/tests/test_stage1.py @@ -12,12 +12,15 @@ test_data = Path(os.getenv('LSTCHAIN_TEST_DATA', 'test_data')) test_r0_path = test_data / 'real/R0/20200218/LST-1.1.Run02008.0000_first50.fits.fz' -test_calib_path = test_data / 'real/monitoring/PixelCalibration/LevelA/calibration/20200218/v0.8.2.post2.dev48+gb1343281/calibration_filters_52.Run02006.0000.h5' -test_drs4_pedestal_path = test_data / 'real/monitoring/PixelCalibration/LevelA/drs4_baseline/20200218/v0.8.2.post2.dev48+gb1343281/drs4_pedestal.Run02005.0000.h5' -test_time_calib_path = test_data / 'real/monitoring/PixelCalibration/LevelA/drs4_time_sampling_from_FF/20191124/v0.8.2.post2.dev48+gb1343281/time_calibration.Run01625.0000.h5' test_drive_report = test_data / 'real/monitoring/DrivePositioning/drive_log_20200218.txt' test_run_summary = test_data / 'real/monitoring/RunSummary/RunSummary_20200218.ecsv' +calib_version = "ctapipe-v0.17" +calib_path = test_data / 'real/monitoring/PixelCalibration/Cat-A/' +test_calib_path = calib_path / f'calibration/20200218/{calib_version}/calibration_filters_52.Run02006.0000.h5' +test_drs4_pedestal_path = calib_path / f'drs4_baseline/20200218/{calib_version}/drs4_pedestal.Run02005.0000.h5' +test_time_calib_path = calib_path / f'drs4_time_sampling_from_FF/20191124/{calib_version}/time_calibration.Run01625.0000.h5' + def test_stage1(tmp_path): """Test the ctapipe stage1 tool can read in LST real data using the event source""" diff --git a/ctapipe_io_lst/tests/test_version.py b/src/ctapipe_io_lst/tests/test_version.py similarity index 100% rename from ctapipe_io_lst/tests/test_version.py rename to src/ctapipe_io_lst/tests/test_version.py diff --git a/ctapipe_io_lst/version.py b/src/ctapipe_io_lst/version.py similarity index 100% rename from ctapipe_io_lst/version.py rename to src/ctapipe_io_lst/version.py