From 6d938c1bb5a4f9e74379ed1b39d069714d1e8464 Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Mon, 20 Oct 2025 10:15:34 -1000 Subject: [PATCH 1/8] Update repo * Move build settings over to `pyproject.toml`. * Remove unused files. --- .isort.cfg | 3 - environment.yaml | 18 ------ pyproject.toml | 85 ++++++++++++++++++++++++--- setup.cfg | 129 ----------------------------------------- setup.py | 21 ------- tests/conftest.py | 10 ---- tests/test_skeleton.py | 25 -------- tox.ini | 84 --------------------------- 8 files changed, 77 insertions(+), 298 deletions(-) delete mode 100644 .isort.cfg delete mode 100644 environment.yaml delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 tests/conftest.py delete mode 100644 tests/test_skeleton.py delete mode 100644 tox.ini diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 072151f..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[settings] -profile = black -known_first_party = panoptes diff --git a/environment.yaml b/environment.yaml deleted file mode 100644 index 0e005b2..0000000 --- a/environment.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: panoptes-data -channels: - - https://conda.anaconda.org/conda-forge -dependencies: - - astropy - - numpy - - pandas - - pip - - pydantic - - pydantic-settings - - python-dateutil - - rich[jupyter] - - tabulate - - tqdm - - typer - - pip: - - . - - panoptes-utils[images] diff --git a/pyproject.toml b/pyproject.toml index f6935d6..5a56de4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,78 @@ [build-system] -# AVOID CHANGING REQUIRES: IT WILL BE UPDATED BY PYSCAFFOLD! -requires = ["setuptools>=46.1.0", "setuptools_scm[toml]>=5", "wheel"] -build-backend = "setuptools.build_meta" - -[tool.setuptools_scm] -# For smarter version schemes and other configuration options, -# check out https://github.com/pypa/setuptools_scm -version_scheme = "no-guess-dev" +requires = ["hatchling>=1.18", "hatch-vcs>=0.3"] +build-backend = "hatchling.build" + +[project] +name = "panoptes-data" +description = "Tools for working with PANOPTES data." +readme = "README.md" +requires-python = ">=3.12" +license = { file = "LICENSE.txt" } +authors = [ + { name = "Wilfred Tyler Gee", email = "wtylergee@gmail.com" }, +] +keywords = ["astronomy", "panoptes", "data"] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +dependencies = [ + "astropy", + "numpy", + "pandas", + "panoptes-utils[images]", + "pydantic", + "pydantic-settings", + "python-dateutil", + "rich[jupyter]", + "tabulate", + "tqdm", + "typer", +] +dynamic = ["version"] + +[project.urls] +Documentation = "https://projectpanoptes.org/" +Source = "https://github.com/panoptes/panoptes-data/" +Download = "https://pypi.org/project/panoptes-data/#files" + +[project.scripts] +panoptes-data = "panoptes.data.utils.cli.main:app" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build] +include = ["src/panoptes/**", "README.md", "LICENSE.txt"] + +[tool.hatch.build.targets.wheel] +packages = ["src/panoptes"] + +[tool.hatch.envs.default] +dependencies = [ + "ruff>=0.5.0" +] +[tool.hatch.envs.default.scripts] +lint = "ruff check ." +lint-fix = "ruff check --fix ." +fmt = "ruff format ." +fmt-check = "ruff format --check ." + +[tool.ruff] +line-length = 100 +target-version = "py312" +src = ["src"] + +[tool.ruff.lint] +select = ["E", "W", "F", "I"] +extend-ignore = ["E203", "W503"] + +[tool.pytest.ini_options] +addopts = ["--cov", "panoptes.data", "--cov-report", "term-missing", "--verbose"] +norecursedirs = ["dist", "build", ".tox"] +testpaths = ["tests"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 871b3c6..0000000 --- a/setup.cfg +++ /dev/null @@ -1,129 +0,0 @@ -# This file is used to configure your project. -# Read more about the various options under: -# https://setuptools.pypa.io/en/latest/userguide/declarative_config.html -# https://setuptools.pypa.io/en/latest/references/keywords.html - -[metadata] -name = panoptes-data -description = Tools for working with PANOPTES data. -author = Wilfred Tyler Gee -author_email = wtylergee@gmail.com -license = MIT -license_files = LICENSE.txt -long_description = file: README.md -long_description_content_type = text/markdown; charset=UTF-8 -url = https://github.com/panoptes/panoptes-data -# Add here related links, for example: -project_urls = - Documentation = https://projectpanoptes.org/ - Source = https://github.com/panoptes/panoptes-data/ - Download = https://pypi.org/project/panoptes-data/#files - -# Change if running only on Windows, Mac or Linux (comma-separated) -platforms = any - -# Add here all kinds of additional classifiers as defined under -# https://pypi.org/classifiers/ -classifiers = - Development Status :: 4 - Beta - Programming Language :: Python - - -[options] -zip_safe = False -include_package_data = True -package_dir = - =src - -# Require a min/specific Python version (comma-separated conditions) -# python_requires = >=3.8 - -# Add here dependencies of your project (line-separated), e.g. requests>=2.2,<3.0. -# Version specifiers like >=2.2,<3.0 avoid problems due to API changes in -# new major versions. This works if the required packages follow Semantic Versioning. -# For more information, check out https://semver.org/. -install_requires = - importlib-metadata; python_version<"3.8" - astropy - numpy - pandas - panoptes-utils[images] - pip - pydantic - pydantic-settings - python-dateutil - rich[jupyter] - tabulate - tqdm - typer - -[options.packages.find] -where = src -exclude = - tests - -[options.extras_require] -# Add here additional requirements for extra features, to install with: -# `pip install panoptes-data[PDF]` like: -# PDF = ReportLab; RXP - -# Add here test requirements (semicolon/line-separated) -testing = - setuptools - pytest - pytest-cov - tox - -[options.entry_points] -console_scripts = - panoptes-data = panoptes.data.utils.cli.main:app - -[tool:pytest] -# Specify command line options as you would do when invoking pytest directly. -# e.g. --cov-report html (or xml) for html/xml output or --junitxml junit.xml -# in order to write a coverage file that can be read by Jenkins. -# CAUTION: --cov flags may prohibit setting breakpoints while debugging. -# Comment those flags to avoid this pytest issue. -addopts = - --cov panoptes.data --cov-report term-missing - --verbose -norecursedirs = - dist - build - .tox -testpaths = tests -# Use pytest markers to select/deselect specific tests -# markers = -# slow: mark tests as slow (deselect with '-m "not slow"') -# system: mark end-to-end system tests - -[devpi:upload] -# Options for the devpi: PyPI server and packaging tool -# VCS export must be deactivated since we are using setuptools-scm -no_vcs = 1 -formats = bdist_wheel - -[flake8] -# Some sane defaults for the code style checker flake8 -max_line_length = 100 -extend_ignore = E203, W503 -# ^ Black-compatible -# E203 and W503 have edge cases handled by black -exclude = - .tox - build - dist - .eggs - docs/conf.py - -[pyscaffold] -# PyScaffold's parameters when the project was created. -# This will be used when updating. Do not change! -version = 4.5 -package = data -extensions = - github_actions - markdown - namespace - pre_commit -namespace = panoptes diff --git a/setup.py b/setup.py deleted file mode 100644 index 6dd5e6a..0000000 --- a/setup.py +++ /dev/null @@ -1,21 +0,0 @@ -""" - Setup file for panoptes-data. - Use setup.cfg to configure your project. - - This file was generated with PyScaffold 4.5. - PyScaffold helps you to put up the scaffold of your new Python project. - Learn more under: https://pyscaffold.org/ -""" -from setuptools import setup - -if __name__ == "__main__": - try: - setup(use_scm_version={"version_scheme": "no-guess-dev"}) - except: # noqa - print( - "\n\nAn error occurred while building the project, " - "please ensure you have the most updated version of setuptools, " - "setuptools_scm and wheel with:\n" - " pip install -U setuptools setuptools_scm wheel\n\n" - ) - raise diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100644 index ca1ac2a..0000000 --- a/tests/conftest.py +++ /dev/null @@ -1,10 +0,0 @@ -""" - Dummy conftest.py for data. - - If you don't know what this is for, just leave it empty. - Read more about conftest.py under: - - https://docs.pytest.org/en/stable/fixture.html - - https://docs.pytest.org/en/stable/writing_plugins.html -""" - -# import pytest diff --git a/tests/test_skeleton.py b/tests/test_skeleton.py deleted file mode 100644 index 6b2ec86..0000000 --- a/tests/test_skeleton.py +++ /dev/null @@ -1,25 +0,0 @@ -import pytest - -from panoptes.data.skeleton import fib, main - -__author__ = "Wilfred Tyler Gee" -__copyright__ = "Wilfred Tyler Gee" -__license__ = "MIT" - - -def test_fib(): - """API Tests""" - assert fib(1) == 1 - assert fib(2) == 1 - assert fib(7) == 13 - with pytest.raises(AssertionError): - fib(-10) - - -def test_main(capsys): - """CLI Tests""" - # capsys is a pytest fixture that allows asserts against stdout/stderr - # https://docs.pytest.org/en/stable/capture.html - main(["7"]) - captured = capsys.readouterr() - assert "The 7-th Fibonacci number is 13" in captured.out diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 73304b2..0000000 --- a/tox.ini +++ /dev/null @@ -1,84 +0,0 @@ -# Tox configuration file -# Read more under https://tox.wiki/ -# THIS SCRIPT IS SUPPOSED TO BE AN EXAMPLE. MODIFY IT ACCORDING TO YOUR NEEDS! - -[tox] -minversion = 3.24 -envlist = default -isolated_build = True - - -[testenv] -description = Invoke pytest to run automated tests -setenv = - TOXINIDIR = {toxinidir} -passenv = - HOME -extras = - testing -commands = - pytest {posargs} - - -# # To run `tox -e lint` you need to make sure you have a -# # `.pre-commit-config.yaml` file. See https://pre-commit.com -# [testenv:lint] -# description = Perform static analysis and style checks -# skip_install = True -# deps = pre-commit -# passenv = -# HOMEPATH -# PROGRAMDATA -# commands = -# pre-commit run --all-files {posargs:--show-diff-on-failure} - - -[testenv:{build,clean}] -description = - build: Build the package in isolation according to PEP517, see https://github.com/pypa/build - clean: Remove old distribution files and temporary build artifacts (./build and ./dist) -# https://setuptools.pypa.io/en/stable/build_meta.html#how-to-use-it -skip_install = True -changedir = {toxinidir} -deps = - build: build[virtualenv] -commands = - clean: python -c 'import shutil; [shutil.rmtree(p, True) for p in ("build", "dist", "docs/_build")]' - clean: python -c 'import pathlib, shutil; [shutil.rmtree(p, True) for p in pathlib.Path("src").glob("*.egg-info")]' - build: python -m build {posargs} - - -[testenv:{docs,doctests,linkcheck}] -description = - docs: Invoke sphinx-build to build the docs - doctests: Invoke sphinx-build to run doctests - linkcheck: Check for broken links in the documentation -setenv = - DOCSDIR = {toxinidir}/docs - BUILDDIR = {toxinidir}/docs/_build - docs: BUILD = html - doctests: BUILD = doctest - linkcheck: BUILD = linkcheck -deps = - -r {toxinidir}/docs/requirements.txt - # ^ requirements.txt shared with Read The Docs -commands = - sphinx-build --color -b {env:BUILD} -d "{env:BUILDDIR}/doctrees" "{env:DOCSDIR}" "{env:BUILDDIR}/{env:BUILD}" {posargs} - - -[testenv:publish] -description = - Publish the package you have been developing to a package index server. - By default, it uses testpypi. If you really want to publish your package - to be publicly accessible in PyPI, use the `-- --repository pypi` option. -skip_install = True -changedir = {toxinidir} -passenv = - # See: https://twine.readthedocs.io/en/latest/ - TWINE_USERNAME - TWINE_PASSWORD - TWINE_REPOSITORY -deps = twine -commands = - python -m twine check dist/* - python -m twine upload {posargs:--repository {env:TWINE_REPOSITORY:testpypi}} dist/* From e9aaa6d657ae1fc8f3ef3b258948919cf2e5a232 Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Mon, 20 Oct 2025 10:32:16 -1000 Subject: [PATCH 2/8] * Remove `ImagePathInfo` from repo and use the one from `panoptes-utils`. * ruff & lint --- docs/conf.py | 4 +- pyproject.toml | 4 - src/panoptes/data/images.py | 138 ---------------------------- src/panoptes/data/observations.py | 2 +- src/panoptes/data/search.py | 11 +-- src/panoptes/data/settings.py | 19 ---- src/panoptes/data/utils/cli/main.py | 17 ++-- 7 files changed, 16 insertions(+), 179 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3420a0c..5904d6f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,8 +8,8 @@ # serve to show the default. import os -import sys import shutil +import sys # -- Path setup -------------------------------------------------------------- @@ -52,7 +52,7 @@ apidoc.main(args) except Exception as e: - print("Running `sphinx-apidoc` failed!\n{}".format(e)) + print(f"Running `sphinx-apidoc` failed!\n{e}") # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 5a56de4..79c1586 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,10 +68,6 @@ line-length = 100 target-version = "py312" src = ["src"] -[tool.ruff.lint] -select = ["E", "W", "F", "I"] -extend-ignore = ["E203", "W503"] - [tool.pytest.ini_options] addopts = ["--cov", "panoptes.data", "--cov-report", "term-missing", "--verbose"] norecursedirs = ["dist", "build", ".tox"] diff --git a/src/panoptes/data/images.py b/src/panoptes/data/images.py index 11861e5..a0de7b5 100644 --- a/src/panoptes/data/images.py +++ b/src/panoptes/data/images.py @@ -1,15 +1,4 @@ -from dataclasses import dataclass -from datetime import datetime from enum import IntEnum, auto -from pathlib import Path -from typing import Union - -from astropy.time import Time -from dateutil.parser import parse as parse_date -from panoptes.utils.images import fits as fits_utils -from panoptes.utils.time import flatten_time - -from panoptes.data.settings import PATH_MATCHER class ImageStatus(IntEnum): @@ -29,130 +18,3 @@ class ImageStatus(IntEnum): MATCHED = auto() EXTRACTING = auto() EXTRACTED = auto() - - -@dataclass -class ImagePathInfo: - """Parse the location path for an image. - - This is a small dataclass that offers some convenience methods for dealing - with a path based on the image id. - - This would usually be instantiated via `path`: - - ..doctest:: - - >>> from panoptes.data.images import ImagePathInfo - >>> bucket_path = 'gs://panoptes-images-background/PAN012/Hd189733/358d0f/20180824T035917/20180824T040118.fits' - >>> path_info = ImagePathInfo(path=bucket_path) - - >>> path_info.id - 'PAN012_358d0f_20180824T035917_20180824T040118' - - >>> path_info.unit_id - 'PAN012' - - >>> path_info.sequence_id - 'PAN012_358d0f_20180824T035917' - - >>> path_info.sequence_time -