-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of PPDB classes and CLI tools.
The main purpose of this package id to implement management tools for PDDB, including tools for migration of APDB data to PPDB. Regular clients will access PDDB either via SQL or using TAP services. What is implemented on thi ticket: - Added base Ppdb class with factory methods, and its SQL implementation. - Two CLI tools - `ppdb-cli` for general commands and `ppdb-replication` for replication-related stuff. - Efficient bulk insert methods for Postgres.
- Loading branch information
Showing
33 changed files
with
2,042 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Check Python formatting | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
call-workflow: | ||
uses: lsst/rubin_workflows/.github/workflows/formatting.yaml@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
name: lint | ||
|
||
on: | ||
- push | ||
- pull_request | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
call-workflow: | ||
uses: lsst/rubin_workflows/.github/workflows/lint.yaml@main | ||
ruff: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Install | ||
run: pip install -r <(curl https://raw.githubusercontent.com/lsst/linting/main/requirements.txt) | ||
|
||
- name: Run linter | ||
run: flake8 | ||
- uses: actions/checkout@v3 | ||
- uses: chartboost/ruff-action@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Run mypy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
call-workflow: | ||
uses: lsst/rubin_workflows/.github/workflows/mypy.yaml@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
--- | ||
name: Check that 'main' is not merged into the development branch | ||
|
||
on: pull_request | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Lint YAML Files | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
call-workflow: | ||
uses: lsst/rubin_workflows/.github/workflows/yamllint.yaml@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-yaml | ||
args: | ||
- "--unsafe" | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/psf/black-pre-commit-mirror | ||
rev: 24.2.0 | ||
hooks: | ||
- id: black | ||
# It is recommended to specify the latest version of Python | ||
# supported by your project here, or alternatively use | ||
# pre-commit's default_language_version, see | ||
# https://pre-commit.com/#top_level-default_language_version | ||
language_version: python3.11 | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
name: isort (python) | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.3.1 | ||
hooks: | ||
- id: ruff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- python -*- | ||
from lsst.sconsUtils import scripts | ||
|
||
scripts.BasicSConscript.shebang() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env python | ||
|
||
from lsst.dax.ppdb.cli import ppdb_cli | ||
|
||
if __name__ == "__main__": | ||
ppdb_cli.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env python | ||
|
||
from lsst.dax.ppdb.cli import ppdb_replication | ||
|
||
if __name__ == "__main__": | ||
ppdb_replication.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[mypy] | ||
ignore_errors = False | ||
warn_unused_configs = True | ||
warn_redundant_casts = True | ||
ignore_missing_imports = False | ||
disallow_untyped_defs = True | ||
disallow_incomplete_defs = True | ||
|
||
[mypy-astropy.*] | ||
ignore_missing_imports = True | ||
|
||
[mypy-lsst.daf.*] | ||
ignore_missing_imports = True | ||
|
||
[mypy-lsst.sphgeom] | ||
ignore_missing_imports = True | ||
|
||
[mypy-lsst.dax.ppdb.*] | ||
ignore_missing_imports = False | ||
ignore_errors = False | ||
disallow_untyped_defs = True | ||
disallow_incomplete_defs = True | ||
strict_equality = True | ||
warn_unreachable = True | ||
warn_unused_ignores = True | ||
|
||
[mypy-lsst.dax.ppdb.version] | ||
ignore_errors = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
[build-system] | ||
requires = ["setuptools", "lsst-versions >= 1.3.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "lsst-dax-ppdb" | ||
description = "Prompt Products Database for LSST AP pipeline." | ||
license = {text = "GPLv3+ License"} | ||
readme = "README.md" | ||
authors = [ | ||
{name="Rubin Observatory Data Management", email="[email protected]"}, | ||
] | ||
classifiers = [ | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Topic :: Scientific/Engineering :: Astronomy", | ||
] | ||
keywords = ["lsst"] | ||
dependencies = [ | ||
"astropy", | ||
"numpy", | ||
"pandas", | ||
"pyyaml >= 5.1", | ||
"sqlalchemy", | ||
"felis", | ||
"lsst-utils", | ||
"lsst-resources", | ||
"lsst-dax-apdb", | ||
] | ||
dynamic = ["version"] | ||
|
||
[project.urls] | ||
"Homepage" = "https://github.com/lsst/dax_ppdb" | ||
|
||
[project.optional-dependencies] | ||
test = [ | ||
"pytest >= 3.2", | ||
"pytest-openfiles >= 0.5.0" | ||
] | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["python"] | ||
|
||
[tool.setuptools] | ||
zip-safe = true | ||
license-files = ["COPYRIGHT", "LICENSE"] | ||
|
||
[tool.setuptools.package-data] | ||
"lsst.dax.ppdb" = ["py.typed"] | ||
|
||
[tool.setuptools.dynamic] | ||
version = { attr = "lsst_versions.get_lsst_version" } | ||
|
||
[tool.black] | ||
line-length = 110 | ||
target-version = ["py311"] | ||
|
||
[tool.isort] | ||
profile = "black" | ||
line_length = 110 | ||
|
||
[tool.lsst_versions] | ||
write_to = "python/lsst/dax/ppdb/version.py" | ||
|
||
[tool.ruff] | ||
exclude = [ | ||
"__init__.py", | ||
"doc/conf.py", | ||
] | ||
line-length = 110 | ||
target-version = "py311" | ||
|
||
[tool.ruff.lint] | ||
ignore = [ | ||
"N802", | ||
"N803", | ||
"N806", | ||
"N812", | ||
"N815", | ||
"N816", | ||
"N999", | ||
"D107", | ||
"D105", | ||
"D102", | ||
"D104", | ||
"D100", | ||
"D200", | ||
"D205", | ||
"D400", | ||
] | ||
select = [ | ||
"E", # pycodestyle | ||
"F", # pycodestyle | ||
"N", # pep8-naming | ||
"W", # pycodestyle | ||
"D", # pydocstyle | ||
] | ||
extend-select = [ | ||
"RUF100", # Warn about unused noqa | ||
] | ||
|
||
[tool.ruff.lint.pycodestyle] | ||
max-doc-length = 79 | ||
|
||
[tool.ruff.lint.pydocstyle] | ||
convention = "numpy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# This file is part of dax_ppdb | ||
# | ||
# Developed for the LSST Data Management System. | ||
# This product includes software developed by the LSST Project | ||
# (https://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
from __future__ import annotations | ||
|
||
__all__ = ["config_type_for_name", "ppdb_type", "ppdb_type_for_name"] | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from .config import PpdbConfig | ||
from .sql import PpdbSql | ||
|
||
|
||
def ppdb_type(config: PpdbConfig) -> type[PpdbSql]: | ||
"""Return Ppdb class matching Ppdb configuration type. | ||
Parameters | ||
---------- | ||
config : `PpdbConfig` | ||
Configuration object, sub-class of PpdbConfig. | ||
Returns | ||
------- | ||
type : `type` [`Ppdb`] | ||
Subclass of `Ppdb` class. | ||
Raises | ||
------ | ||
TypeError | ||
Raised if type of ``config`` does not match any known types. | ||
""" | ||
from .sql import PpdbSqlConfig | ||
|
||
if type(config) is PpdbSqlConfig: | ||
from .sql import PpdbSql | ||
|
||
return PpdbSql | ||
|
||
raise TypeError(f"Unknown type of config object: {type(config)}") | ||
|
||
|
||
def ppdb_type_for_name(type_name: str) -> type[PpdbSql]: | ||
"""Return Ppdb class matching type name. | ||
Parameters | ||
---------- | ||
type_name : `str` | ||
Short type name of Ppdb implement, for now only "sql" is supported. | ||
Returns | ||
------- | ||
type : `type` [`Ppdb`] | ||
Subclass of `Ppdb` class. | ||
Raises | ||
------ | ||
TypeError | ||
Raised if ``type_name`` does not match any known types. | ||
""" | ||
if type_name == "sql": | ||
from .sql import PpdbSql | ||
|
||
return PpdbSql | ||
|
||
raise TypeError(f"Unknown type name: {type_name}") | ||
|
||
|
||
def config_type_for_name(type_name: str) -> type[PpdbConfig]: | ||
"""Return PpdbConfig class matching type name. | ||
Parameters | ||
---------- | ||
type_name : `str` | ||
Short type name of Ppdb implement, for now only "sql" is supported. | ||
Returns | ||
------- | ||
type : `type` [`Ppdb`] | ||
Subclass of `PpdbConfig` class. | ||
Raises | ||
------ | ||
TypeError | ||
Raised if ``type_name`` does not match any known types. | ||
""" | ||
if type_name == "sql": | ||
from .sql import PpdbSqlConfig | ||
|
||
return PpdbSqlConfig | ||
|
||
raise TypeError(f"Unknown type name: {type_name}") |
Empty file.
Oops, something went wrong.