Skip to content

Commit

Permalink
Merge pull request #263 from lsst/tickets/DM-46273
Browse files Browse the repository at this point in the history
DM-46273: Add Python packaging with ResourcePath support
  • Loading branch information
JeremyMcCormick authored Oct 17, 2024
2 parents d4c58f7 + 36463ca commit 606de20
Show file tree
Hide file tree
Showing 8 changed files with 783 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ jobs:
run: |
python -m pip install --upgrade pip uv
uv pip install --system -r requirements.txt
uv pip install --system pytest
- name: Install sdm_schemas
run: uv pip install --system --no-deps .

- name: Run Python tests
run: pytest

- name: Log in to Docker Hub
uses: docker/login-action@v1
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ datalink/columns-principal.yaml
datalink/*.zip

.scratch

# Python build
build
python/lsst_sdm_schemas.egg-info
__pycache__
2 changes: 2 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Copyright 2010-2024 The Board of Trustees of the Leland Stanford Junior University, through SLAC National Accelerator Laboratory
Copyright 2010-2024 Association of Universities for Research in Astronomy, Inc. (AURA)
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[build-system]
requires = ["setuptools", "lsst-versions >= 1.3.0"]
build-backend = "setuptools.build_meta"

[project]
name = "lsst-sdm-schemas"
description = "Science Data Model (SDM) Schemas for Rubin Observatory"
license = {text = "GNU General Public License v3 or later (GPLv3+)"}
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.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Astronomy"
]
keywords = ["lsst"]
dependencies = [
"lsst-felis @ git+http://github.com/lsst/felis.git@main",
"click",
"pyyaml",
"psycopg2",
"pymysql",
"cryptography"
]
requires-python = ">=3.11.0"
dynamic = ["version"]

[project.urls]
Homepage = "https://sdm-schemas.lsst.io"
Source = "https://github.com/lsst/sdm_schemas"

[project.optional-dependencies]
test = [
"pytest >= 3.2"
]

[tool.setuptools]
zip-safe = true
license-files = ["COPYRIGHT", "LICENSE"]

[tool.setuptools.packages.find]
where = ["python"]

[tool.setuptools.package-data]
"lsst.sdm_schemas" = ["schemas/*.yaml"]
Empty file.
1 change: 1 addition & 0 deletions python/lsst/sdm_schemas/schemas
43 changes: 43 additions & 0 deletions tests/test_schema_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This file is part of sdm_schemas.
#
# 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/>.

import unittest
import importlib.resources
import yaml

from felis.datamodel import Schema


class SchemaResourceTestCase(unittest.TestCase):
"""Test reading of schema data from a resource."""

def test_read_resource(self) -> None:
"""Test that schema data can be read from a resource."""
resource = importlib.resources.files("lsst.sdm_schemas.schemas").joinpath(
"dp02_dc2.yaml"
)
raw_data = resource.read_text()
data = yaml.safe_load(raw_data)
Schema.model_validate(data)


if __name__ == "__main__":
unittest.main()

0 comments on commit 606de20

Please sign in to comment.