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
61 changes: 0 additions & 61 deletions .github/workflows/codacy.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Lint

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

jobs:
lint:
name: ruff + black
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --extra dev

# --output-format=github renders findings as inline PR annotations,
# which is the part of the Codacy integration worth keeping.
- name: Run ruff
run: uv run ruff check --output-format=github src tests

- name: Run black
run: uv run black --check --diff src tests
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Keep ruff and black revs in step with the versions in the dev extra of
# pyproject.toml. Drift between them produces the "passes locally, fails in
# CI" failure mode.
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.11
hooks:
- id: ruff-check
# No --fix: this package uses deliberate registration-only imports
# (e.g. models/proposal.py's `partner # noqa: F401`) that F401's
# autofix would silently delete. Report-only also matches the
# check-only Lint workflow.
# Match the Lint workflow, which checks src and tests only.
# alembic/ migrations are historical and deliberately unlinted.
files: ^(src|tests)/

- repo: https://github.com/psf/black
rev: 25.12.0
hooks:
- id: black
files: ^(src|tests)/

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
# Vendored Bokeh-generated HTML fixtures; rewriting them on every
# regeneration produces a phantom whitespace-only diff.
exclude: ^examples/data/uploader/
- id: end-of-file-fixer
# Same vendored fixtures as trailing-whitespace above.
exclude: ^examples/data/uploader/
- id: check-yaml
# mkdocs-material's config uses !!python/name: tags, which
# yaml.safe_load cannot construct.
exclude: ^mkdocs\.yml$
- id: check-toml
- id: check-added-large-files
# Uploader example fixtures (e.g. ppp_figure_*.html) legitimately
# exceed the default 500kb limit and are committed on purpose.
exclude: ^examples/data/uploader/
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ If you want to install the package under the Python library directory, you can e

The installation process will install some command-line tools under the directory where your Python executable is located.

### Development setup

If you are going to contribute, install the development dependencies and enable the pre-commit hooks:

```console
python3 -m pip install -e ".[dev]"
pre-commit install
```

The hooks run `ruff` and `black` on the files you stage, plus whitespace and syntax checks. CI runs `ruff` and `black` over all of `src` and `tests`; run `pre-commit run --all-files` to check the whole tree the way CI does.


## Usage Examples

Expand Down
2 changes: 1 addition & 1 deletion alembic/local_test/alembic/README
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Generic single-database configuration.
Generic single-database configuration.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""baseline

Revision ID: 6407841f5938
Revises:
Revises:
Create Date: 2022-05-11 16:21:57.324356

"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""initial revision

Revision ID: 33e97fab1034
Revises:
Revises:
Create Date: 2022-05-12 10:37:08.039899

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Revises: 065b74905fb6
Create Date: 2024-04-17 10:09:59.291914

Note:
Note:
Before upgrading the database, I run the following query to avoid the violation of the unique constaint:
```
UPDATE sky SET obj_id = sky_id WHERE version = '20220915';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""add index in obj_id, input_catalog_id, and proposal_id for target table
"""add index in obj_id, input_catalog_id, and proposal_id for target table

Revision ID: 89865530fdf1
Revises: 3923581e4392
Expand Down
Binary file modified diagrams/erdiagram_targetdb_latest.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Some simple examples to work with `targetdb` are provided as follows.
- [Preparation of input data](preparation.md): how to prepare input data for `targetdb`.
- [Useful queries](queries.md): useful queries to work with `targetdb`.
- [Run `targetdb` in a Docker container](docker.md): how to run `targetdb` in a Docker container.
- [Tutorial on preparing PFS openuse](obsproc.md): Workflow to prepare the database content for PFS openuse observations.
- [Tutorial on preparing PFS openuse](obsproc.md): Workflow to prepare the database content for PFS openuse observations.
2 changes: 1 addition & 1 deletion docs/reference/api.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# API Reference

TBD
TBD
4 changes: 2 additions & 2 deletions docs/tbls/public.fluxstd.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@
| ---- | ---------- |
| fluxstd_pkey | CREATE UNIQUE INDEX fluxstd_pkey ON public.fluxstd USING btree (fluxstd_id) |
| uq_obj_id_input_catalog_id_version | CREATE UNIQUE INDEX uq_obj_id_input_catalog_id_version ON public.fluxstd USING btree (obj_id, input_catalog_id, version) |
| ix_fluxstd_input_catalog_fluxstdid | CREATE INDEX ix_fluxstd_input_catalog_fluxstdid ON public.fluxstd USING btree (input_catalog_id, fluxstd_id) |
| ix_fluxstd_version_fluxstdid | CREATE INDEX ix_fluxstd_version_fluxstdid ON public.fluxstd USING btree (version, fluxstd_id) |
| fluxstd_q3c_ang2ipix_idx | CREATE INDEX fluxstd_q3c_ang2ipix_idx ON public.fluxstd USING btree (q3c_ang2ipix(ra, "dec")) |
| ix_fluxstd_version | CREATE INDEX ix_fluxstd_version ON public.fluxstd USING btree (version) |
| fluxstd_q3c_ang2ipix_idx | CREATE INDEX fluxstd_q3c_ang2ipix_idx ON public.fluxstd USING btree (q3c_ang2ipix(ra, "dec")) |
| ix_fluxstd_input_catalog_fluxstdid | CREATE INDEX ix_fluxstd_input_catalog_fluxstdid ON public.fluxstd USING btree (input_catalog_id, fluxstd_id) |

## Relations

Expand Down
2 changes: 1 addition & 1 deletion docs/tbls/public.target.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@
| target_pkey | CREATE UNIQUE INDEX target_pkey ON public.target USING btree (target_id) |
| target_propid_obcode_catid_objid_resolution_key | CREATE UNIQUE INDEX target_propid_obcode_catid_objid_resolution_key ON public.target USING btree (proposal_id, ob_code, input_catalog_id, obj_id, is_medium_resolution) |
| target_propid_obcode_key | CREATE UNIQUE INDEX target_propid_obcode_key ON public.target USING btree (proposal_id, ob_code) |
| target_q3c_ang2ipix_idx | CREATE INDEX target_q3c_ang2ipix_idx ON public.target USING btree (q3c_ang2ipix(ra, "dec")) |
| target_proposal_id_idx | CREATE INDEX target_proposal_id_idx ON public.target USING btree (proposal_id) |
| target_obj_id_input_catalog_id_idx | CREATE INDEX target_obj_id_input_catalog_id_idx ON public.target USING btree (obj_id, input_catalog_id) |
| target_input_catalog_id_idx | CREATE INDEX target_input_catalog_id_idx ON public.target USING btree (input_catalog_id) |
| target_proposal_id_obj_id_idx | CREATE INDEX target_proposal_id_obj_id_idx ON public.target USING btree (proposal_id, obj_id) |
| target_q3c_ang2ipix_idx | CREATE INDEX target_q3c_ang2ipix_idx ON public.target USING btree (q3c_ang2ipix(ra, "dec")) |

## Relations

Expand Down
2 changes: 1 addition & 1 deletion examples/data/filter_names.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ u_sdss,SDSS u filter
g_sdss,SDSS g filter
r_sdss,SDSS r filter
i_sdss,SDSS i filter
z_sdss,SDSS z filter
z_sdss,SDSS z filter
2 changes: 1 addition & 1 deletion examples/data/input_catalogs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ input_catalog_id,input_catalog_name,input_catalog_description,upload_id
1001,sky_hscssp_s21a_wide,Sky positions from S21A HSC-SSP (Wide),
1002,sky_s1,Sky positions from PS1,
1003,sky_gaia,Sky positions from Gaia,
1004,sky_nops1,Sky postionns for regions without PS1 data,
1004,sky_nops1,Sky postionns for regions without PS1 data,
2 changes: 1 addition & 1 deletion examples/data/proposals.csv
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ S24B-QT910,o00010,Wanqiu,He,NaN,7.5,B,5307.25,5307.25,0.0,1,subaru,False
S24B-QT911,o00011,Mao,Zhiying,NaN,10.0,A,5348.05,5348.05,0.0,1,subaru,False
S24B-QT912,o00012,Yuki,Moritani,NaN,9.5,A,350.25,350.25,0.0,1,subaru,False
S24B-QT913,o00013,Vera,Passegger,Maria,7.0,B,263.0,263.0,0.0,1,subaru,False
S24B-QT914,o00014,Miho,Ishigaki,NaN,0.0,F,0.0,0.0,0.0,1,subaru,False
S24B-QT914,o00014,Miho,Ishigaki,NaN,0.0,F,0.0,0.0,0.0,1,subaru,False
1 change: 0 additions & 1 deletion examples/data/targets/example_input_catalogs_current.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
input_catalog_name,input_catalog_description,upload_id,proposal_id,is_classical,is_user_pointing

Loading