diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8df852f..3bcb2d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,9 +32,6 @@ jobs: # - macos-latest # - windows-latest include: - - name: python 3.9 - toxenv: py39 - python-version: 3.9 - name: python 3.10 toxenv: py310 @@ -44,6 +41,10 @@ jobs: toxenv: py311 python-version: 3.11 + - name: python 3.12 + toxenv: py312 + python-version: 3.12 + steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/CHANGES.rst b/CHANGES.rst index e1bb2a6..85eb88e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,14 @@ +1.1.1 (unreleased) +================== + +installation +------------ +- Set minimum python version to 3.10, include py312 in test suite, replace deprecated pkg_resources with importlib.metadata [#73] +- Set minimum tensorflow version to 2.16.1 [#73] +- Pre-trained neural networks updated for compatibility with Keras 3 [#73] +- Dockerfile images now use debian bookworm [#73] + + 1.1.0 (2024-04-09) ================== diff --git a/MANIFEST.IN b/MANIFEST.IN index 071ac4f..d32e564 100644 --- a/MANIFEST.IN +++ b/MANIFEST.IN @@ -8,6 +8,3 @@ include *.md # Include the license file include LICENSE - -# Include setup.py -include setup.py \ No newline at end of file diff --git a/README.md b/README.md index 5c8d091..62a797b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # spacekit -[![Powered by Astropy](http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat)](http://www.astropy.org) ![GitHub license](https://img.shields.io/github/license/spacetelescope/spacekit?color=black) [![CodeFactor](https://www.codefactor.io/repository/github/spacetelescope/spacekit/badge)](https://www.codefactor.io/repository/github/spacetelescope/spacekit) +[![Build Status](https://github.com/spacetelescope/spacekit/workflows/ci/badge.svg?branch=main)](https://github.com/spacetelescope/spacekit/actions) +[![Powered by STScI Badge](https://img.shields.io/badge/powered%20by-STScI-blue.svg?colorA=707170&colorB=3e8ddd&style=flat)](http://www.stsci.edu) +[![Powered by Astropy](http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat)](http://www.astropy.org) +[![DOI](https://zenodo.org/badge/11169350.svg)](https://zenodo.org/badge/latestdoi/11169350) Astronomical Data Science and Machine Learning Toolkit diff --git a/docker/images/dashboard_image/Dockerfile b/docker/images/dashboard_image/Dockerfile index 2c171cc..76db7b6 100644 --- a/docker/images/dashboard_image/Dockerfile +++ b/docker/images/dashboard_image/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bullseye-slim +FROM debian:bookworm-slim ENV DEV_HOME=/home/developer RUN apt update && \ diff --git a/docs/requirements.txt b/docs/requirements.txt index 0fe8551..33aca6a 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,15 +1,15 @@ -setuptools==69.2.0 +setuptools==70.2.0 Sphinx==6.2.1 sphinx-automodapi==0.17.0 -sphinx_rtd_theme==1.2.2 +sphinx_rtd_theme==2.0.0 matplotlib==3.8.4 tensorflow==2.13.0 numpy==1.24.3 numpydoc==1.7.0 -astropy==5.3.1 +astropy==6.1.1 pydot==2.0.0 graphviz==0.20.3 -astroquery==0.4.6 +astroquery==0.4.7 boto3==1.28.7 plotly==5.20.0 progressbar==2.5 diff --git a/pyproject.toml b/pyproject.toml index 49b6c70..0917f43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools>=42", + "setuptools>=61.2", "wheel" ] build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index d81134c..671ff8f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = spacekit -version = 1.1.0 +version = 1.1.1rc1 author = Ru Keïn author_email = rkein@stsci.edu license = MIT @@ -16,27 +16,28 @@ project_urls = Documentation = https://spacekit.readthedocs.io Tracker = https://github.com/spacetelescope/spacekit/issues classifiers= - Programming Language :: Python :: 3 + Intended Audience :: Science/Research + Topic :: Scientific/Engineering :: Astronomy License :: OSI Approved :: MIT License + Programming Language :: Python :: 3 Operating System :: OS Independent - Development Status :: 3 - Alpha - Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 [options] zip_safe = False packages = find: include_package_data = True -python_requires = >=3.7 +python_requires = >=3.10 setup_requires = - setuptools >=42 + setuptools >=61.2 install_requires = - tensorflow<2.16 + tensorflow>=2.16.1 astropy boto3 - numpy>=1.19 + numpy>=1.22 pandas scikit-learn>=1.3.2 diff --git a/spacekit/__init__.py b/spacekit/__init__.py index 94ef3bf..883bebb 100644 --- a/spacekit/__init__.py +++ b/spacekit/__init__.py @@ -1,8 +1,8 @@ -from pkg_resources import get_distribution, DistributionNotFound +import importlib.metadata try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: + __version__ = importlib.metadata.version(__name__) +except importlib.metadata.PackageNotFoundError: pass # package is not installed # def reload(mod): diff --git a/spacekit/builder/architect.py b/spacekit/builder/architect.py index fd37449..8f9e0b6 100644 --- a/spacekit/builder/architect.py +++ b/spacekit/builder/architect.py @@ -21,7 +21,6 @@ MaxPool3D, GlobalAveragePooling3D, ) - from tensorflow.keras.metrics import RootMeanSquaredError as RMSE from spacekit.generator.augment import augment_data, augment_image from spacekit.analyzer.track import stopwatch @@ -86,7 +85,7 @@ def load_saved_model( """Load saved keras model from local disk (located at the ``model_path`` attribute) or a pre-trained model from spacekit.skopes.trained_networks (if ``model_path`` attribute is None). Example for ``compile_params``: ``dict(loss="binary_crossentropy",metrics=["accuracy"],\ - optimizer=Adam(learning_rate=optimizers.schedules.ExponentialDecay(lr=1e-4, \ + optimizer=Adam(learning_rate=optimizers.schedules.ExponentialDecay(1e-4, \ decay_steps=100000, decay_rate=0.96, staircase=True)))`` Parameters @@ -328,7 +327,7 @@ def set_callbacks(self, patience=15): list [callbacks.ModelCheckpoint, callbacks.EarlyStopping] """ - model_name = str(self.model.name_scope().rstrip("/")) + model_name = str(self.model.name) checkpoint_cb = callbacks.ModelCheckpoint( f"{model_name}_checkpoint.h5", save_best_only=True ) @@ -362,7 +361,7 @@ def save_model(self, weights=True, output_path=".", keras_archive=True, parent_d save model using new (preferred) keras archive format, by default True """ if self.name is None: - self.name = str(self.model.name_scope().rstrip("/")) + self.name = str(self.model.name) datestamp = dt.datetime.now().isoformat().split("T")[0] model_name = f"{self.name}_{datestamp}" else: @@ -440,7 +439,7 @@ def batch_fit(self): tf.keras.model.history Keras training history """ - model_name = str(self.model.name_scope().rstrip("/").upper()) + model_name = str(self.model.name).upper() self.log.info("FITTING MODEL...") validation_data = ( (self.X_test, self.y_test) if self.X_test is not None else None @@ -483,7 +482,7 @@ def fit(self, params=None): """ if params is not None: self.fit_params(**params) - model_name = str(self.model.name_scope().rstrip("/").upper()) + model_name = str(self.model.name).upper() self.log.info("FITTING MODEL...") validation_data = ( (self.X_test, self.y_test) if self.X_test is not None else None @@ -983,7 +982,7 @@ def batch(self): for i in range(self.batch_size): xa[i] = augment_data(xa[i]) xb[i] = augment_image(xb[i]) - yield [xa, xb], yb + yield (xa, xb), yb class BuilderCNN2D(Builder): diff --git a/spacekit/builder/trained_networks/hst_cal.zip b/spacekit/builder/trained_networks/hst_cal.zip index 1b3e7ce..d091fc8 100644 Binary files a/spacekit/builder/trained_networks/hst_cal.zip and b/spacekit/builder/trained_networks/hst_cal.zip differ diff --git a/spacekit/builder/trained_networks/jwst_cal.zip b/spacekit/builder/trained_networks/jwst_cal.zip index adc9783..fba077b 100644 Binary files a/spacekit/builder/trained_networks/jwst_cal.zip and b/spacekit/builder/trained_networks/jwst_cal.zip differ diff --git a/spacekit/builder/trained_networks/svm_align.zip b/spacekit/builder/trained_networks/svm_align.zip index 89525be..cd6102c 100644 Binary files a/spacekit/builder/trained_networks/svm_align.zip and b/spacekit/builder/trained_networks/svm_align.zip differ diff --git a/spacekit/datasets/meta.py b/spacekit/datasets/meta.py index ee19a3c..b307859 100644 --- a/spacekit/datasets/meta.py +++ b/spacekit/datasets/meta.py @@ -1,12 +1,12 @@ calcloud = { - "uri": "https://zenodo.org/record/10895592/files", + "uri": "https://zenodo.org/record/11169350/files", "data": { "2022-02-14": { "fname": "hst_cal_std_2022-02-14.zip?download=1", - "hash": "e9375c65feb413a660cb737a9a8a3a73", + "hash": "3ca674b0d81e98e319f6e80d78ce8db8", "desc": "data, model and training results", "key": "2022-02-14-1644848448", - "size": "11.4MB", + "size": "9.7MB", }, "2021-11-04": { "fname": "hst_cal_std_2021-11-04.zip?download=1", @@ -32,29 +32,29 @@ }, "model": { "fname": "hst_cal.zip", - "hash": "ffe7d00504ad5d6ebc79488abe612474", + "hash": "acb07516b9385ce7182577ef7216ae75", "desc": "hst calcloud resource prediction models", "key": "hst_cal", - "size": "385.42kB", + "size": "385.47kB", }, } svm = { - "uri": "https://zenodo.org/record/10895592/files", + "uri": "https://zenodo.org/record/11169350/files", "data": { "2022-02-14": { "fname": "hst_drz_svm_2022-02-14.zip?download=1", - "hash": "3d6ade5510cc7aad4c2c45329c0751fe", + "hash": "2660e4457b19ce01b625d7a668d04e89", "desc": "latest model, data and training results", "key": "2022-02-14-1644850390", - "size": "18MB", + "size": "5MB", }, "2022-01-30": { "fname": "hst_drz_svm_2022-01-30.zip?download=1", - "hash": "9ad9b95c20b82877f1ea7b0fa64b10a1", + "hash": "370fdbdb8d2b45b2ded998dbcc6927a5", "desc": "updated model, data and training results", "key": "2022-01-30-1643523529", - "size": "18MB", + "size": "5MB", }, "2022-01-16": { "fname": "hst_drz_svm_2022-01-16.zip?download=1", @@ -80,7 +80,7 @@ }, "model": { "fname": "svm_align.zip", - "hash": "af3b019cc3079cb29fd01bae58e9560d", + "hash": "c98492b1e729407c72a69d2c739232be", "desc": "hst svm alignment prediction models", "key": "svm_align", "size": "4.92MB", @@ -89,7 +89,7 @@ jwst_cal = { - "uri": "https://zenodo.org/record/10895592/files", + "uri": "https://zenodo.org/record/11169350/files", "data": { "2023-08-02": { "fname": "", @@ -101,16 +101,16 @@ }, "model": { "fname": "jwst_cal.zip", - "hash": "f3b6dbcc3fc92a6f806f5b5464e68c02", + "hash": "c2c6764bcf1092e993d061be43075e3d", "desc": "JWST Calibration Processing Resource Prediction Models", "key": "jwst_cal", - "size": "1.5MB", + "size": "526.89kB", }, } k2 = { - "uri": "https://zenodo.org/record/10895592/files", + "uri": "https://zenodo.org/record/11169350/files", "data": { "test": { "fname": "k2-exo-flux-ts-test.csv.zip?download=1", @@ -142,19 +142,19 @@ "calcloud": { "basepath": "spacekit.builder.trained_networks", "fname": "hst_cal.zip", - "hash": "f3422c98d93520898e10d068a1e434dd5caf40e632760687df377c1b2bccff57", - "size": "385.42kB", + "hash": "3dcfd4760154dee890f7943e237e679a43eef82d3c0838ff62ecf17e4c3702fb", + "size": "385.47kB", }, "svm": { "basepath": "spacekit.builder.trained_networks", "fname": "svm_align.zip", - "hash": "577a87fab157fdadc657af0dcd67b55af2d89d855d5597bd96671b20ff135636", + "hash": "cda062ba768374802e4e8b919c0dcce79ce3b72e29004cc09601a67da454b008", "size": "4.92MB", }, "jwst_cal": { "basepath": "spacekit.builder.trained_networks", "fname": "jwst_cal.zip", - "hash": "b61d0281fd149e2b0ffcded81ba54b24b479c5b7191072be2bfb59464d779187", - "size": "1.5MB", + "hash": "31142d47e5fc31650b49edb44dfa3db5f1d09380864b9560e2dded456723dfe6", + "size": "526.89kB", }, } diff --git a/tests/data_plugin.py b/tests/data_plugin.py index a358c3c..c454f08 100644 --- a/tests/data_plugin.py +++ b/tests/data_plugin.py @@ -43,7 +43,7 @@ def pytest_configure(config): tmp_path_factory = TempPathFactory( config.option.basetemp, trace=config.trace.get("tmpdir"), _ispytest=True ) - data_uri = "https://zenodo.org/record/10895592/files/pytest_data.tgz?download=1" + data_uri = "https://zenodo.org/record/11169350/files/pytest_data.tgz?download=1" basepath = tmp_path_factory.getbasetemp() target_path = os.path.join(basepath, "pytest_data.tgz") with open(target_path, "wb") as f: diff --git a/tox.ini b/tox.ini index 8f956f3..c229d52 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] isolated_build = True envlist = - py3{9,10,11} + py3{10,11,12} check-{style,security} pep517 #test{,-oldestdeps,-devdeps}