Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docs template so that it builds #392

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions containers/test-template/test-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ script="'${script_name}' tests/data tests/result participant -c1 --skip-bids-val
case "$method" in
"setuptools" )
python -m venv .venv
.venv/bin/python -m pip install .
# if [ -d /src ]; then
# .venv/bin/python -m pip install /src
# fi
.venv/bin/python -m pip install --no-color .
PATH=".venv/bin:$PATH" eval "$script"
;;
"poetry" )
poetry install
poetry install --no-ansi
eval "poetry run $script"
;;
"hatch" )
Expand All @@ -28,6 +25,12 @@ case "$method" in
pdm install
eval "pdm run $script"
;;
"docs" )
python -m venv .venv
.venv/bin/python -m pip install .
.venv/bin/python -m pip install -r docs/requirements.txt
.venv/bin/sphinx-build docs build/docs -W
;;
* )
>&2 echo "Invalid method"
exit 1
Expand Down
160 changes: 160 additions & 0 deletions snakebids/project_template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ author = "{{full_name}}"
extensions = [
"sphinx_rtd_theme",
"sphinxarg.ext",
"myst_parser",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -54,4 +55,4 @@ html_theme = "sphinx_rtd_theme"
# 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"]
# html_static_path = ["_static"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Installation
# Installation

Install from github with pip:

Expand All @@ -8,7 +8,7 @@ pip install -e git+https://github.com/{{github}}/{{name_slug}}#egg={{name_slug}}

Note: you can re-run this command to re-install with the latest version

## Running the app
# Running the app

Do a dry-run first (`-n`) and simply print (`-p`) what would be run:

Expand All @@ -24,7 +24,7 @@ Run the app, using all cores::

If any workflow rules require containers, then run with the `--use-singularity` option.

## Generating a report
# Generating a report

After your processing is complete, you can use snakemake's `--report` feature to generate
an HTML report. This report will include a graph of all the jobs run, with clickable nodes
Expand All @@ -38,13 +38,13 @@ To generate a report, run:
{{name_slug}} /path/to/bids/dir /path/to/output/dir participant --report
```

## Compute Canada Instructions
# Compute Canada Instructions

### Setting up a dev environment
## Setting up a dev environment

Here are some instructions to get your python environment set-up on graham to run {{name_slug}}:

# Create a virtualenv and activate it:
### Create a virtualenv and activate it:

```bash
cd $SCRATCH
Expand All @@ -53,9 +53,9 @@ virtualenv venv_{{name_slug}}
source venv_{{name_slug}}/bin/activate
```

# Follow the steps above to install from github repository
### Follow the steps above to install from github repository

### Install job submission helpers
## Install job submission helpers

Snakemake can submit jobs with SLURM, but you need to set-up a Snakemake profile to enable this. The Khan lab has a
snakemake profile that is configured for graham but is customizable upon install, please see `cc-slurm <https://github.com/khanlab/cc-slurm>` for more info.
Expand All @@ -64,7 +64,7 @@ If you don't need Snakemake to parallelize jobs across different nodes, you can

These are used in the instructions below.

### Running jobs on Compute Canada
## Running jobs on Compute Canada

In an interactive job (for testing):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```{toctree}
:maxdepth: 1
:caption: Contents:
:caption: "Contents:"
```

```{toctree}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
docutils<0.18
sphinx-argparse
sphinx_rtd_theme
snakebids=={{ snakebids_version }}
myst-parser
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Command line interface
# Command line interface

```{argparse}
:filename: ../{{ name_slug }}/run.py
:func: get_parser
:ref: {{ name_slug }}.run.get_parser
:prog: {{ name_slug }}
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Snakemake Command line interface
# Snakemake Command line interface

```{argparse}
:module: snakemake
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@


def get_parser():
"""Exposes parser for sphinx doc generation, cwd is the docs dir"""
app = SnakeBidsApp("../{{ name_slug }}")
"""Exposes parser for sphinx doc generation, cwd is the docs dir."""
app = SnakeBidsApp(Path(__file__).resolve().parent) # to get repository root
return app.parser


def main():
"""Run the app."""
app = SnakeBidsApp(
Path(__file__).resolve().parent, # to get repository root
plugins=[BidsValidator()],
Expand Down
8 changes: 6 additions & 2 deletions snakebids/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,18 @@ def decorator(func: Callable[_P, _T]) -> Callable[_P, _T]:
@ft.wraps(func)
def wrapper(*args: _P.args, **kwargs: _P.kwargs):
try:
sp.run(["docker"], check=True)
sp.run(["docker"], check=True, capture_output=True)
except (sp.CalledProcessError, FileNotFoundError):
pytest.fail(
"docker is not available on this machine. To skip docker tests, "
"use '-m \"not docker\"'"
)
try:
sp.run(["docker", "image", "inspect", container], check=True)
sp.run(
["docker", "image", "inspect", container],
capture_output=True,
check=True,
)
except sp.CalledProcessError as err:
if not (
match := re.match(r"snakebids/([\w\-]+)\:[a-zA-Z0-9\-]+", container)
Expand Down
Loading
Loading