Skip to content

Commit

Permalink
Change package layout / modernize installation
Browse files Browse the repository at this point in the history
  • Loading branch information
m-samland committed Apr 2, 2024
1 parent ba7474b commit 02d7dc0
Show file tree
Hide file tree
Showing 30 changed files with 2,487 additions and 751 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ci

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ".[test]"
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest tests
56 changes: 56 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: sphinxdocumentation

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"


- name: Install docs dependencies
run: |
pip install --upgrade pip
pip install -e ".[docs]"
- name: Build docs
working-directory: ./docs
run: |
make html
# uses: ammaraskar/sphinx-action@master
# with:
# docs-folder: "docs/"

# Publish built docs to gh-pages branch.
# ===============================
- name: Commit documentation changes
run: |
git clone https://github.com/ammaraskar/sphinx-action-test.git --branch gh-pages --single-branch gh-pages
cp -r docs/_build/html/* gh-pages/
cd gh-pages
touch .nojekyll
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update documentation" -a || true
# The above command will fail if no changes were present, so we ignore
# that.
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
# ===============================
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -26,6 +27,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
*_version.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -70,6 +72,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/api/

# PyBuilder
target/
Expand Down
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ TRAP is novel algorithm used to detect exoplanets in high-contrast imaging data,
in the time-domain. The main benefit of this new approach is that it works significantly better for companion signals very close to the central star.
For a detailed description please refer to `Samland et al. 2021 <https://ui.adsabs.harvard.edu/abs/2021A%26A...646A..24S/abstract>`_.

TRAP can currently only be installed from source and requires at least Python 3.5 or higher. We recommend using the "pip install" or "pip install -e ." command (if you want to make changes to the code base) in the directory containing the "setup.py" file.
TRAP is using Ray for multiprocessing, we recommend installing it via 'pip install -U "ray[default]"' to get access to the dashboard for monitoring utilities.
TRAP requires at least Python 3.8 or higher (3.12 will be supported soon). The latest version can be installed using "pip install git+https://github.com/m-samland/trap/".
If the user wishes to contribute or change the code, we recommend cloning the repository and using the "pip install -e ." command.

TRAP is using Ray for multiprocessing. If you are using a cluster, please make sure that Ray is installed on the cluster as well.

The package has been tested on Linux/iOS/Windows with the packages provided in any recent version of Conda.
Please provide feedback if there are issues installing the package on your system.

A detailed documentation website is not available at the moment. Please refer to the in-code documentation and the tutorial notebook containing a simple example based on the test data included in the package.
Please make use of the tutorial notebook in the examples folder explaining how to use TRAP. The folder also contains data from the VLT/SPHERE instrument needed for the tutorial.

Dependencies
------------
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
53 changes: 53 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# 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.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


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

project = 'my_package'
copyright = '2022, Author Name'
author = 'Author Name'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx_automodapi.automodapi'
]
numpydoc_show_class_members = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
67 changes: 67 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.. my_package documentation master file, created by
sphinx-quickstart on Tue Mar 22 13:13:41 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to my_package's documentation!
======================================

.. toctree::
:maxdepth: 2
:caption: Contents:


Here is where you can write the documentation for your package.


Usage
=====

.. _installation:

Installation
------------

To use `my_package` you need to install X, Y and Z.


.. _code:

Code
----

Here is an example of describing the use of your function.

To add one to a number you can use the ``my_package.add_one()`` function:

.. py:function:: my_package.add_one(number)
:param number: Should be integer, floating point number or a string.

If ``number`` is not one of these types, an exception will be raised:

.. py:exception:: TypeError
Raised if the input is invalid.

More about how to describe code can be hound
`here <https://www.sphinx-doc.org/en/master/tutorial/describing-code.html>`_


..
The following section creates an index, a list of modules and a
search page.
Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

..
The following will add the signature of the individual functions and pull
their docstrings.
.. automodapi:: my_package.example
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 02d7dc0

Please sign in to comment.