Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/spacetelescope/rad into RAD…
Browse files Browse the repository at this point in the history
…-160_FY24Docs
  • Loading branch information
PaulHuwe committed Dec 2, 2024
2 parents 4daf96b + 48203a1 commit a27d815
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@924441154cf3053034c6513d5e06c69d262fb9a6 # v1.13.0
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@d68193b68216da64eafaa618f53c59f5d271c56e # v1.14.0
with:
upload_to_pypi: ${{ (github.event_name == 'release') && (github.event.action == 'released') }}
secrets:
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ on:

jobs:
test:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@924441154cf3053034c6513d5e06c69d262fb9a6 # v1.13.0
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@d68193b68216da64eafaa618f53c59f5d271c56e # v1.14.0
with:
envs: |
- linux: py310-xdist
- linux: py311-xdist-cov
- linux: py311-xdist
- linux: py312-xdist-cov
coverage: codecov
- linux: py312-xdist
- linux: py313-xdist
roman_datamodels:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@d68193b68216da64eafaa618f53c59f5d271c56e # v1.14.0
with:
envs: |
- linux: roman_datamodels-xdist
7 changes: 4 additions & 3 deletions .github/workflows/ci_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ on:

jobs:
test:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@924441154cf3053034c6513d5e06c69d262fb9a6 # v1.13.0
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@d68193b68216da64eafaa618f53c59f5d271c56e # v1.14.0
if: (github.repository == 'spacetelescope/rad' && (github.event_name == 'schedule' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Weekly CI')))
with:
envs: |
- macos: py310-xdist
- linux: py312-devdeps-xdist
- macos: py311-xdist
- linux: py313-devdeps-xdist
- linux: py311-oldestdeps-xdist
30 changes: 4 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ repos:
- id: check-yaml
args: ["--unsafe"]
- id: check-toml
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: debug-statements
Expand All @@ -19,8 +20,6 @@ repos:
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
Expand All @@ -33,30 +32,9 @@ repos:
additional_dependencies:
- tomli

- repo: https://github.com/asottile/pyupgrade
rev: 'v3.19.0'
hooks:
- id: pyupgrade
args: ["--py38-plus"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.7.4'
rev: 'v0.8.0'
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
hooks:
- id: bandit
args: ["-r", "-ll"]
args: ["--fix", "--show-fixes"]
- id: ruff-format
1 change: 1 addition & 0 deletions changes/516.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added null values to allowed APCORR and ABVEGAOFFSET keyword values.
1 change: 1 addition & 0 deletions changes/520.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump min Python to 3.11 per SPEC 0.
21 changes: 8 additions & 13 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,15 @@
import datetime
import os
import sys
import tomllib
from pathlib import Path

# Ensure documentation examples are deterministically random.
import numpy

if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib

from importlib_metadata import distribution

try:
numpy.random.seed(int(os.environ["SOURCE_DATE_EPOCH"]))
numpy.random.seed(int(os.environ["SOURCE_DATE_EPOCH"])) # noqa: NPY002
except KeyError:
pass

Expand All @@ -59,12 +54,12 @@
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.2'

intersphinx_mapping["pypa-packaging"] = ("https://packaging.python.org/en/latest/", None) # noqa: E501, F405
intersphinx_mapping["asdf"] = ("https://asdf.readthedocs.io/en/latest/", None) # noqa: E501, F405
intersphinx_mapping["asdf-standard"] = ("https://asdf-standard.readthedocs.io/en/latest/", None) # noqa: E501, F405
intersphinx_mapping["asdf-astropy"] = ("https://asdf-astropy.readthedocs.io/en/latest/", None) # noqa: E501, F405
intersphinx_mapping["pytest"] = ("https://docs.pytest.org/en/latest/", None) # noqa: E501, F405
intersphinx_mapping["roman_datamodels"] = ("https://roman-datamodels.readthedocs.io/en/latest/", None) # noqa: E501, F405
intersphinx_mapping["pypa-packaging"] = ("https://packaging.python.org/en/latest/", None) # noqa: F405
intersphinx_mapping["asdf"] = ("https://asdf.readthedocs.io/en/latest/", None) # noqa: F405
intersphinx_mapping["asdf-standard"] = ("https://asdf-standard.readthedocs.io/en/latest/", None) # noqa: F405
intersphinx_mapping["asdf-astropy"] = ("https://asdf-astropy.readthedocs.io/en/latest/", None) # noqa: F405
intersphinx_mapping["pytest"] = ("https://docs.pytest.org/en/latest/", None) # noqa: F405
intersphinx_mapping["roman_datamodels"] = ("https://roman-datamodels.readthedocs.io/en/latest/", None) # noqa: F405

# To perform a Sphinx version check that needs to be more specific than
# major.minor, call `check_sphinx_version("x.y.z")` here.
Expand Down
48 changes: 30 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "rad"
description = "Roman Attribute Dictionary"
requires-python = ">=3.10"
requires-python = ">=3.11"
authors = [
{ name = "STScI", email = "[email protected]" },
]
Expand All @@ -12,7 +12,7 @@ classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = [
"asdf >=2.14.2",
"asdf >=2.15.2",
"asdf-astropy >=0.5.0",
]
dynamic = [
Expand All @@ -28,8 +28,8 @@ file = "LICENSE"

[project.optional-dependencies]
test = [
"pytest>=4.6.0",
"pytest-doctestplus>=0.11.1",
"pytest>=7.0.0",
"pytest-doctestplus>=1.2.1",
"crds>=11.16.16",
]
docs = [
Expand All @@ -41,7 +41,6 @@ docs = [
"graphviz",
"matplotlib",
"docutils",
"tomli; python_version <\"3.11\"",
"importlib-metadata",
"towncrier",
]
Expand All @@ -57,7 +56,6 @@ rad = "rad.integration:get_resource_mappings"
requires = [
"setuptools >=61",
"setuptools_scm[toml] >=3.4",
"wheel",
]
build-backend = "setuptools.build_meta"

Expand All @@ -77,34 +75,48 @@ where = [
]

[tool.pytest.ini_options]
minversion = 4.6
minversion = 7.0
doctest_plus = true
doctest_rst = true
text_file_format = "rst"
addopts = "--show-capture=no"
log_cli_level = "INFO"
xfail_strict = true
addopts = [
"--color=yes", # color test output
"--doctest-rst", # enable doctests
"--strict-config", # fail on unknown config options
"--strict-markers", # fail on unknown markers
"-ra", # Show summary of all failures/errors
]
testpaths = [
"tests",
"src/rad/resources/schemas",
]
filterwarnings = [
"error::ResourceWarning",
"error",
]
asdf_schema_tests_enabled = "true"
asdf_schema_skip_tests = "src/rad/resources/schemas/rad_schema-1.0.0.yaml"
asdf_schema_root = "src/rad/resources/schemas"

[tool.isort]
profile = "black"
filter_files = true
line_length = 130

[tool.black]
line-length = 130
force-exclude = "^/(\n (\n \\.eggs\n | \\.git\n | \\.pytest_cache\n | \\.tox\n )/\n)\n"

[tool.ruff]
line-length = 130

[tool.ruff.lint]
extend-select = [
"UP", # PyUpgrade
"I", # isort
"B", # BugBear
"S", # Bandit
"RUF", # ruff specific
"NPY", # numpy specific
]

[tool.ruff.lint.per-file-ignores]
"tests/**.py" = [
"S101" # Bandit: Use of assert detected (fine in test files)
]

[tool.codespell]
skip = "*.pdf,*.fits,*.asdf,.tox,build,./tags,.git,docs/_build"

Expand Down
1 change: 1 addition & 0 deletions scripts/insert_next_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Insert the next release's changelog header. Prints the version, which
our GitHub Actions workflow uses to generate a commit message.
"""

import re
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions scripts/set_release_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Prints the version, which our GitHub Actions workflow uses to
generate a commit message and release tag.
"""

import re
from datetime import date
from pathlib import Path
Expand Down
7 changes: 1 addition & 6 deletions src/rad/integration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import sys
import importlib.resources as importlib_resources

from asdf.resource import DirectoryResourceMapping

if sys.version_info < (3, 9):
import importlib_resources
else:
import importlib.resources as importlib_resources


def get_resource_mappings():
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ properties:
description: Magnitude difference between the AB and Vega magnitude
systems. Found by calculating the AB magnitude of Vega within
the optical element bandpass.
type: number
anyOf:
- type: number
- type: "null"
required: [abvega_offset]
required: [meta, data]
flowStyle: block
Expand Down
38 changes: 24 additions & 14 deletions src/rad/resources/schemas/reference_files/apcorr-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,49 @@ properties:
title: Aperture Corrections
description: The aperture correction for each enclosed energy
fraction, corresponding to 1 / ee_fractions.
tag: tag:stsci.edu:asdf/core/ndarray-1.*
datatype: float64
exact_datatype: true
ndim: 1
anyOf:
- tag: tag:stsci.edu:asdf/core/ndarray-1.*
datatype: float64
exact_datatype: true
ndim: 1
- type: "null"
ee_fractions:
title: Enclosed Energy Fractions
description: Fractions of the enclosed energy of the PSF at which
to estimate the aperture correction and enclosed energy radii.
tag: tag:stsci.edu:asdf/core/ndarray-1.*
datatype: float64
exact_datatype: true
ndim: 1
anyOf:
- tag: tag:stsci.edu:asdf/core/ndarray-1.*
datatype: float64
exact_datatype: true
ndim: 1
- type: "null"
ee_radii:
title: Enclosed Energy Radii
description: Radius, in pixels, within which the enclosed energy
fractions are met. The indexing matches that of
"ee_fractions".
tag: tag:stsci.edu:asdf/core/ndarray-1.*
datatype: float64
exact_datatype: true
ndim: 1
anyOf:
- tag: tag:stsci.edu:asdf/core/ndarray-1.*
datatype: float64
exact_datatype: true
ndim: 1
- type: "null"
sky_background_rin:
title: Inner Radius for the Sky Background
description: Inner radius, in pixels, to use when estimating the
local sky background within an annulus between this
radius and "sky_background_rout".
type: number
anyOf:
- type: number
- type: "null"
sky_background_rout:
title: Outer Radius for the Sky Background
description: Outer radius, in pixels, to use when estimating the
local sky background within an annulus between this
radius and "sky_background_rin".
type: number
anyOf:
- type: number
- type: "null"
required: [ap_corrections, ee_fractions, ee_radii, sky_background_rin, sky_background_rout]
required: [meta, data]
flowStyle: block
Expand Down
7 changes: 1 addition & 6 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
Test that the asdf library integration is working properly.
"""

import sys

if sys.version_info < (3, 9):
import importlib_resources
else:
import importlib.resources as importlib_resources
import importlib.resources as importlib_resources

import asdf
import pytest
Expand Down
7 changes: 4 additions & 3 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def callback(node):
"missing properties: " + missing_list + "\n"
"extra properties: " + extra_list
)
assert False, message
raise ValueError(message)

asdf.treeutil.walk(schema, callback)
else:
Expand All @@ -111,7 +111,7 @@ def callback(node):
if not required_names.issubset(property_names):
missing_list = ", ".join(required_names - property_names)
message = "required references names that do not exist: " + missing_list
assert False, message
raise ValueError(message)

asdf.treeutil.walk(schema, callback)

Expand Down Expand Up @@ -279,7 +279,8 @@ def test_varchar_length(uri):
"""
schema = asdf.schema.load_schema(uri)

def callback(node, nvarchars={}):
def callback(node, nvarchars=None):
nvarchars = nvarchars or {}
if not isinstance(node, dict):
return
if node.get("type", "") != "string":
Expand Down
Loading

0 comments on commit a27d815

Please sign in to comment.