Skip to content

Commit

Permalink
Merge pull request #17 from spirosmaggioros/test_cases
Browse files Browse the repository at this point in the history
Documentation update | Added test cases | Updated docstrings
  • Loading branch information
AlexanderGetka-cbica authored Jul 29, 2024
2 parents cc6b41f + cef6e7d commit 5737c96
Show file tree
Hide file tree
Showing 37 changed files with 2,710 additions and 1,834 deletions.
35 changes: 16 additions & 19 deletions .github/CONTRIBUTE/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
def your_function(param1: type, param2: type, ...) -> return_type:
"""
Describe briefly what your function does
:param param1: Describe what param1 is used for.
:type param1: type of param1
:param param2: Describe what param2 is used for.
:type param2: type of param2
etc.
:return: Explain what your function returns
:rtype: return type of the function
Args:
param1(type): Describe what param1 is used for.
param2(type): Describe what param2 is used for.
etc.
Return:
return_type: Explain what your function returns.
"""
```
- For classes:
Expand All @@ -31,19 +33,14 @@
"""
Describe briefly what your class does
Static attributes:
param1(type): Explain what param1 is used for.
param2(type): Explain what param2 is used for.
etc.
Methods:
func1(param1, param2, ...):
Here you have to explain what func1 does using the tutorial above.
You have to do the same for every function.
Note that you can add more docstrings inside function if you wish.
:param param1: Explain what param1 is used for.
:type param1: type of param1
:param param2: Explain what param2 is used for.
:type param2: type of param2
etc.
"""
def __init__(self, param1: type, param2: type, ...):
def __init__(self, param1: type, param2: type, ...) -> None:
...

def func1(self, param1: type, param2: type, ...) -> return_type:
Expand All @@ -58,4 +55,4 @@

* You can find all the existing model weights at the [mdl](../../spare_scores/mdl/) folder.

* All the code that is used for the documentation is located at the [contents](../../docs/source/) folder and you can manually add more.
* All the code that is used for the documentation is located at the [contents](../../docs/source/) folder and you can manually add more.
40 changes: 40 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Upload Python Package

on: workflow_dispatch

permissions:
contents: read
id-token: write # Allow GitHub to mint tokens

jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest # Can use macos-latest if needed

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install dependencies
run: |
pip install setuptools
pip install twine
pip install wheel
sudo apt-get install jq
- name: Clean previous builds
run: rm -rf dist

- name: Build package
run: python setup.py sdist bdist_wheel

- name: Publish package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
34 changes: 18 additions & 16 deletions .github/workflows/sphinx-docs.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
name: Docs
name: Deploy static cntent to Pages
on:
push:
branches:
- "main"
pull_request:
workflow_dispatch:


branches: ["main"]

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.12'
- name: Activate conda
run: |
conda create -n spare python=3.8
conda run -n spare conda install pip
conda run -n spare pip install spare_scores
- name: Install dependencies
run: |
pip install -e .
pip install sphinx sphinx_rtd_theme sphinx-tabs
pip install sphinx sphinx_rtd_theme sphinx-tabs sphinx_toolbox
- name: Sphinx build
run: |
sphinx-apidoc -o docs spare_scores/
cd docs/
sphinx-apidoc -o ./source ../spare_scores
sphinx-build source _build
make html
cd ..
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3

with:
path: docs/_build
path: docs/_build/html
retention-days: 90

deploy-docs:
Expand All @@ -52,5 +54,5 @@ jobs:
steps:
- name: Deploy artifact to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4

19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/ambv/black
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.11.5
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
args: ["--ignore-missing-imports"]
5 changes: 2 additions & 3 deletions dev-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jsonschema==4.17.3
kiwisolver==1.4.4
matplotlib==3.7.1
msgpack==1.0.5
numpy==1.23.5
numpy==1.26.4
packaging==23.1
pandas==2.0.3
Pillow==9.5.0
Expand All @@ -36,12 +36,11 @@ requests==2.31.0
scikit-learn==0.24.2
scipy==1.8.0
six==1.16.0
-e git+https://github.com/georgeaidinis/spare_score@3055a393e7aad704dd00dd378e45d695d99deebd#egg=spare_scores
threadpoolctl==3.1.0
tomli==2.0.1
torch==2.3.1
typing_extensions==4.7.0
tzdata==2023.3
urllib3==2.0.3
zipp==3.15.0
setuptools==70.3.0
setuptools==59.8.0
4 changes: 2 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
Expand Down
34 changes: 23 additions & 11 deletions docs/source/conf.py → docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,36 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'spare_scores'
copyright = '2023, Ashish Singh'
author = 'Ashish Singh'
release = '0.1'
import os
import sys

sys.path.insert(0, os.path.abspath("../spare_scores/"))

project = "spare-scores"
copyright = "2024, Gyujoon Hwang, George Aidinis"
author = "Gyujoon Hwang, George Aidinis"
release = "2024"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = []

templates_path = ['_templates']
exclude_patterns = []
extensions = [
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.autodoc",
"sphinx_toolbox.sidebar_links",
"sphinx_toolbox.github",
]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

# html_theme = 'alabaster'
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
github_username = "CBICA"
github_repository = "github.com/CBICA/spare_score"

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
20 changes: 20 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. spare-scores documentation master file, created by
sphinx-quickstart on Mon Jul 15 15:13:44 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to spare-scores's documentation!
========================================

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

Indices and tables
==================

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


70 changes: 35 additions & 35 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

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

%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
)

if "%1" == "" goto help

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

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

:end
popd
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

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

%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
)

if "%1" == "" goto help

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

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

:end
popd
7 changes: 7 additions & 0 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spare_scores
============

.. toctree::
:maxdepth: 4

spare_scores
10 changes: 0 additions & 10 deletions docs/source/contents/api.rst

This file was deleted.

Loading

0 comments on commit 5737c96

Please sign in to comment.