Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@ on:
name: Create GitHub Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
See Changelog for details
draft: false
prerelease: false
deploy:
name: Push Release to PyPi
runs-on: ubuntu-latest
Expand Down
109 changes: 109 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build, test, and publish documentation

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Required permissions for deploying to GitHub Pages
permissions:
contents: write
pages: write

jobs:
test:
name: Run tests and upload coverage
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: "pip-${{ runner.os }}-py-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}"
restore-keys: |
pip-${{ runner.os }}-py-${{ matrix.python-version }}-

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r docs/requirements.txt
pip install -e .
pip install pytest pytest-cov

- name: Run tests with coverage
run: |
pytest --cov=panoptes.data --cov-report=xml:coverage.xml --cov-report=html:htmlcov -q

- name: Upload coverage report (xml)
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml

- name: Upload coverage HTML
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov

build-docs:
name: Build and publish docs
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: "pip-${{ runner.os }}-py-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}"
restore-keys: |
pip-${{ runner.os }}-py-${{ matrix.python-version }}-

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r docs/requirements.txt
pip install -e .

- name: Build docs
working-directory: docs
run: make html

- name: Upload HTML docs artifact
uses: actions/upload-artifact@v4
with:
name: docs-html
path: docs/_build/html

- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_build/html
publish_branch: gh-pages
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Run tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
name: Run test suite
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: "pip-${{ runner.os }}-py-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}"
restore-keys: |
pip-${{ runner.os }}-py-${{ matrix.python-version }}-

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
# Install broad dependencies used by the project/tests
if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi
# Install the package itself
pip install -e .
# Install test tools
pip install pytest pytest-cov

- name: Run tests with coverage
run: |
pytest --cov=panoptes.data --cov-report=xml:coverage.xml --cov-report=term-missing -q

- name: Upload coverage (xml)
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
3 changes: 0 additions & 3 deletions .isort.cfg

This file was deleted.

8 changes: 0 additions & 8 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
Expand Down
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# Changelog

## UNRELEASED

- Modernize the repo to use `pyproject.toml`.
- Update docs.
- Add basic tests.
- Releases are created directly by GitHub Actions.

## Version 0.2.0 (2024-10-08)

- Print length of observations.
- Only apply status filter if given.

## Version 0.1.9 (2024-10-07)

- Do better path matching for image url for new scheme.

## Version 0.1.8 (2024-10-07)

- Merge branch 'main' of github.com:panoptes/panoptes-data

## Version 0.1.7 (2024-04-18)

- Fix image_list for latest processing.

## Version 0.1.6 (2024-04-18)

- Change default bucket for downloading images and also make it a parameter.

## Version 0.1.5 (2024-02-02)

- Fixing release for pypi api tokens.

## Version 0.1.4 (2024-02-02)

- Add GitHub Actions PyPI release workflow.

## Version 0.1.3

- Cleanup of images and observations.
Expand Down Expand Up @@ -44,7 +80,15 @@
- Added basic cli interface for download images and metadata for observations.
- Fixed install dependencies.

## Version 0.0.3 (2022-06-24)

- More cleanup of dependencies for release.

## Version 0.0.2

- Observation search available via ``panoptes.data.search.search_observations``.
- ``ObservationInfo`` for working with observation data and metadata.

## Version 0.0.1 (2022-06-23)

- Fixing setup.
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,29 @@ pip install panoptes-data

## Examples

> See example Jupyter Notebooks in the [`notebooks`](notebooks/) folder.
See the example Jupyter Notebooks in the `notebooks/` directory.

### Finding observations

```py
>>> from panoptes.data.search import search_observations
>>> from panoptes.data.observations import ObservationInfo
from panoptes.data.search import search_observations
from panoptes.data.observations import ObservationInfo

>>> # Find some observations
>>> results = search_observations(by_name='M42')
# Find some observations
results = search_observations(by_name='M42')

>>> # Use last result entry to create ObservationInfo object.
>>> obs_info = ObservationInfo(meta=results.iloc[0])
>>> obs_info.meta
# Use last result entry to create ObservationInfo object.
obs_info = ObservationInfo(meta=results.iloc[0])
print(obs_info.meta)

# Create an ObservationInfo object directly from a sequence_id.
obs_info = ObservationInfo('PAN001_14d3bd_20180113T052325')
# But then there is no metadata:
print(obs_info.meta)
```

```text
Sample output (truncated):

camera_id 14d3bd
camera_lens_serial_number HA0028608
Expand All @@ -43,21 +52,14 @@ time 2018-01-13 05:23:25+00:00
total_exptime 3360.0
unit_id PAN001
Name: 6121, dtype: object

>>> # Create an ObservationInfo object directly from a sequence_id.
>>> obs_info = ObservationInfo('PAN001_14d3bd_20180113T052325')
>>> # But then there is no metadata:
>>> obs_info.meta

{}
```

### Downloading images

The `ObservationInfo` object makes it easy to download the files:

```py
>>> obs_info.download_images()
obs_info.download_images()
```

### Command-line tools
Expand All @@ -67,8 +69,12 @@ There is a simple command line tool that allows for both searching and downloadi
#### Search for observations:

```bash
$ panoptes-data search --name M42 --min-num-images 90
panoptes-data search --name M42 --min-num-images 90
```

Example table output:

```text
| sequence_id | field_name | unit_id | coordinates_mount_ra | coordinates_mount_dec | num_images | exptime | total_exptime | time |
|:------------------------------|:-------------|:----------|-----------------------:|------------------------:|-------------:|----------:|----------------:|:--------------------------|
| PAN022_977c86_20220108T090553 | M42 | PAN022 | 83.8221 | -5.39111 | 95 | 90 | 8550 | 2022-01-08 09:05:53+00:00 |
Expand Down
9 changes: 6 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# serve to show the default.

import os
import sys
import shutil
import sys

# -- Path setup --------------------------------------------------------------

Expand Down Expand Up @@ -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 ---------------------------------------------------

Expand Down Expand Up @@ -105,7 +105,7 @@

# General information about the project.
project = "panoptes-data"
copyright = "2023, Wilfred Tyler Gee"
copyright = "2025, Wilfred Tyler Gee"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -165,6 +165,9 @@
# If this is True, todo emits a warning for each TODO entries. The default is False.
todo_emit_warnings = True

# Mock heavy or optional imports so autodoc can generate docs without them.
autodoc_mock_imports = ["pydantic", "pydantic_settings", "tqdm", "typer"]

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down
Loading