Skip to content

Commit

Permalink
All tests pass, updated github workflow, some doc updates to be finis…
Browse files Browse the repository at this point in the history
…hed later on
  • Loading branch information
astrobc1 committed Jan 8, 2025
1 parent 29d084d commit 6f48214
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 313 deletions.
56 changes: 29 additions & 27 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
branches: [ implement_core_liger_datamodels ]
#pull_request:
#branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
python-version: [3.12]

steps:
- uses: actions/checkout@v4
Expand All @@ -27,32 +27,34 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install libcfitsio
run: sudo apt-get install libcfitsio-dev graphviz pandoc
- name: Install pip dependencies
run: |
python -m pip install -r requirements.txt -r test-requirements.txt
# - name: Install libcfitsio
# run: sudo apt-get install libcfitsio-dev graphviz pandoc
# - name: Install pip dependencies
# run: |
# python -m pip install -r requirements.txt -r test-requirements.txt
- name: Setup CRDS
run: |
git clone --depth 1 https://github.com/oirlab/liger-iris-crds-cache $HOME/crds_cache
- name: Build and install
run: python setup.py build_ext -i && python setup.py install
env:
C_INCLUDE_PATH: /usr/include/cfitsio/
- name: Test
run: source setup_local_crds.sh && make test
- name: Build docs
if: ${{ matrix.python-version==3.11 }}
run: |
python -m pip install -r docs/requirements.txt && cd docs && make html
- name: Deploy
if: ${{ matrix.python-version==3.11 && contains(github.ref, 'master') }}
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: master
folder: docs/_build/html
repository-name: oirlab/liger-iris-pipeline
token: ${{ secrets.PAT }}
#- name: Build and install
#run: python setup.py build_ext -i && python setup.py install
#env:
#C_INCLUDE_PATH: /usr/include/cfitsio/
# - name: Test
# run: source setup_local_crds.sh && make test
# - name: Build docs
# if: ${{ matrix.python-version==3.12 }}
# run: |
# python -m pip install -r docs/requirements.txt && cd docs && make html
# - name: Deploy
# if: ${{ matrix.python-version==3.11 && contains(github.ref, 'master') }}
# uses: JamesIves/github-pages-deploy-action@v4
# with:
# branch: master
# folder: docs/_build/html
# repository-name: oirlab/liger-iris-pipeline
# token: ${{ secrets.PAT }}
# ################################

# the token expires every year, create a new Github Personal Access Token where:
# resource owner is oirlab
# repo is oirlab/liger-iris-pipeline (notice dashes, this is the docs repo)
Expand Down
2 changes: 1 addition & 1 deletion docs/available-steps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Available algorithms
:maxdepth: 2

dq_init/index.rst
background/index.rst
sky_subtraction/index.rst
dark_subtraction/index.rst
normalize/index.rst
pipeline/index.rst
Expand Down
199 changes: 58 additions & 141 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,136 +1,67 @@
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# Configuration file for the Sphinx documentation builder.
#
# Astropy documentation build configuration file.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this file.
#
# All configuration values have a default. Some values are defined in
# the global Astropy configuration which is loaded here before anything else.
# See astropy.sphinx.conf for which values are set there.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('..'))
# IMPORTANT: the above commented section was generated by sphinx-quickstart, but
# is *NOT* appropriate for astropy or Astropy affiliated packages. It is left
# commented out with this explanation to make it clear why this should not be
# done. If the sys.path entry above is added, when the astropy.sphinx.conf
# import occurs, it will import the *source* version of astropy instead of the
# version installed (if invoked as "make html" or directly with sphinx), or the
# version in the build directory (if "python setup.py build_sphinx" is used).
# Thus, any C-extensions that are needed to build the documentation will *not*
# be accessible, and the documentation will not build correctly.

import os
import sys
import datetime
from importlib import import_module

try:
from sphinx_astropy.conf.v1 import * # noqa
except ImportError:
print(
"ERROR: the documentation requires the sphinx-astropy package to be installed"
)
sys.exit(1)

# Get configuration information from setup.cfg
from configparser import ConfigParser

conf = ConfigParser()

conf.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")])
setup_cfg = dict(conf.items("metadata"))

# -- General configuration ----------------------------------------------------
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# By default, highlight as Python 3.
highlight_language = "python3"
import liger_iris_pipeline

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.2'

# To perform a Sphinx version check that needs to be more specific than
# major.minor, call `check_sphinx_version("x.y.z")` here.
# check_sphinx_version("1.2.1")
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns.append("_templates")
project = 'Liger IRIS DRS'
copyright = '2025, Bryson Cale, Andrea Zonca, Shelley Wright'
author = 'Bryson Cale, Andrea Zonca, Shelley Wright'

# This is added to the end of RST files - a good place to put substitutions to
# be used globally.
rst_epilog += """
"""

# -- Project information ------------------------------------------------------

# This does not *have* to match the package name, but typically does
project = "liger_iris_pipeline"
author = setup_cfg["author"]
copyright = "{0}, {1}".format(datetime.datetime.now().year, setup_cfg["author"])

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

import_module(setup_cfg["name"])
package = sys.modules[setup_cfg["name"]]

# The short X.Y version.
version = package.__version__.split("-", 1)[0]
# The full version, including alpha/beta/rc tags.
release = package.__version__
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'sphinx_automodapi.automodapi',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.imgmath',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'nbsphinx',
]

# -- Options for HTML output --------------------------------------------------
templates_path = ['_templates']
exclude_patterns = []

# A NOTE ON HTML THEMES
# The global astropy configuration uses a custom theme, 'bootstrap-astropy',
# which is installed along with astropy. A different theme can be used or
# the options for this theme can be modified by overriding some of the
# variables set in the global configuration. The variables set in the
# global configuration are listed below, commented out.
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']

# Add any paths that contain custom themes here, relative to this directory.
# To use a different custom theme, add the directory containing the theme.
# html_theme_path = []

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. To override the custom theme, set this to the
# name of a builtin theme or the name of a custom theme in html_theme_path.
# html_theme = None
# Version
version = liger_iris_pipeline.__version__
# The full version, including alpha/beta/rc tags.
#release = hispecdrp.__version__

html_theme_options = {
"logotext1": "liger_iris_pipeline", # white, semi-bold
"logotext2": "", # orange, light
"logotext3": ":docs", # white, light
}

# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# By default, highlight as Python 3.
highlight_language = "python3"

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
# html_logo = ''
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_templates']

# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = ''
# html_theme_options = {
# "logotext1": "liger_iris_pipeline", # white, semi-bold
# "logotext2": "", # orange, light
# "logotext3": ":docs", # white, light
# }

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
# html_last_updated_fmt = ''

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = "{0} v{1}".format(project, release)
html_title = f"Liger IRIS DRS v{liger_iris_pipeline.__version__}"

# Output file base name for HTML help builder.
htmlhelp_basename = project + "doc"
Expand All @@ -149,22 +80,13 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("index", project.lower(), project + u" Documentation", [author], 1)]
# man_pages = [("index", project.lower(), project + u" Documentation", [author], 1)]


# -- Options for the edit_on_github extension ---------------------------------

if eval(setup_cfg.get("edit_on_github")):
extensions += ["sphinx_astropy.ext.edit_on_github"]

edit_on_github_project = setup_cfg["github_project"]
edit_on_github_branch = "master"

edit_on_github_source_root = ""
edit_on_github_doc_root = "docs"

# -- Resolving issue number to links in changelog -----------------------------
github_issues_url = "https://github.com/{0}/issues/".format(setup_cfg["github_project"])
github_issues_url = "https://github.com/oirlab/liger_iris_pipeline/issues/"

# -- Turn on nitpicky mode for sphinx (to warn about references not found) ----
#
Expand Down Expand Up @@ -192,26 +114,21 @@
# target = target.strip()
# nitpick_ignore.append((dtype, six.u(target)))

intersphinx_mapping = {"jwst": ("https://jwst-pipeline.readthedocs.io/en/latest", None)}

latex_elements = {
# Additional stuff for the LaTeX preamble.
"preamble": "".join(
(
"\DeclareUnicodeCharacter{00A0}{ }", # NO-BREAK SPACE
"\DeclareUnicodeCharacter{251C}{+}", # BOX DRAWINGS LIGHT VERTICAL AND RIGHT
"\DeclareUnicodeCharacter{2514}{+}", # BOX DRAWINGS LIGHT UP AND RIGHT
)
),
intersphinx_mapping = {
"jwst": ("https://jwst-pipeline.readthedocs.io/en/latest", None)
}

# Static files
html_static_path = ['_static']
# latex_elements = {
# # Additional stuff for the LaTeX preamble.
# "preamble": "".join(
# (
# "\DeclareUnicodeCharacter{00A0}{ }", # NO-BREAK SPACE
# "\DeclareUnicodeCharacter{251C}{+}", # BOX DRAWINGS LIGHT VERTICAL AND RIGHT
# "\DeclareUnicodeCharacter{2514}{+}", # BOX DRAWINGS LIGHT UP AND RIGHT
# )
# ),
# }

extensions += [
"nbsphinx",
"sphinx.ext.mathjax",
]
nbsphinx_kernel_name = "python3"
nbsphinx_timeout = 600
nbsphinx_allow_errors = False
Expand Down
8 changes: 7 additions & 1 deletion liger_iris_pipeline/associations/association_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,17 @@ def from_product(cls, product : dict):

@classmethod
def from_member(cls, member : str | datamodels.LigerIRISDataModel):
if isinstance(member, str):
expname = member
elif isinstance(member, datamodels.LigerIRISDataModel) and member._filename is not None:
expname = member._filename
else:
expname = member # NOTE: This will break serialization
input_model = datamodels.open(member)
product = {
"members": [
{
"expname": input_model.filename,
"expname": expname,
"exptype": input_model.meta.exposure.type,
},
]
Expand Down
1 change: 1 addition & 0 deletions liger_iris_pipeline/datamodels/model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, init=None, instrument : str | None = None, **kwargs):

# Pass to super if already a datamodel, schema already known
if isinstance(init, LigerIRISDataModel):
self.set_schema_from_instrument(instrument=init.instrument)
super().__init__(init=init, **kwargs)
else:
# Get the schema from instrument name
Expand Down
24 changes: 12 additions & 12 deletions liger_iris_pipeline/datamodels/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ def open(init=None, memmap=False, **kwargs):
Creates a DataModel from a number of different types.
Parameters:
init:
- None: A default data model with no shape
- shape tuple: Initialize with empty data of the given shape
- file path: Initialize from the given file (FITS, JSON or ASDF)
- readable file object: Initialize from the given file object
- astropy.io.fits.HDUList: Initialize from the given `~astropy.io.fits.HDUList`.
- A numpy array: A new model with the data array initialized to what was passed in.
- dict: The object model tree for the data model
memmap: (bool) (Turn memmap of file on or off. (default: False).
kwargs:
validate_arrays (bool): If `True`, arrays will be validated against ndim, max_ndim, and datatype validators in the schemas.
init:
- None: A default data model with no shape
- shape tuple: Initialize with empty data of the given shape
- file path: Initialize from the given file (FITS, JSON or ASDF)
- readable file object: Initialize from the given file object
- astropy.io.fits.HDUList: Initialize from the given `~astropy.io.fits.HDUList`.
- A numpy array: A new model with the data array initialized to what was passed in.
- dict: The object model tree for the data model
memmap: (bool) (Turn memmap of file on or off. (default: False).
kwargs:
validate_arrays (bool): If `True`, arrays will be validated against ndim, max_ndim, and datatype validators in the schemas.
Returns:
LigerIRISDataModel: The specific LigerIRISDataModel instance.
LigerIRISDataModel : The specific LigerIRISDataModel instance.
"""

from .model_base import LigerIRISDataModel
Expand Down
Loading

0 comments on commit 6f48214

Please sign in to comment.