This repository has been archived by the owner on Jul 6, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,063 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
SPHINXOPTS = | ||
SPHINXBUILD = sphinx-build | ||
SPHINXPROJ = sct_dbtool | ||
SOURCEDIR = source | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=source | ||
set BUILDDIR=build | ||
set SPHINXPROJ=sct_dbtool | ||
|
||
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.http://sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% | ||
|
||
:end | ||
popd |
Empty file.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file does only contain a selection of the most common options. For a | ||
# full list see the documentation: | ||
# http://www.sphinx-doc.org/en/master/config | ||
|
||
# -- 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('.')) | ||
|
||
import sct_dbtool | ||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
project = 'sct_dbtool' | ||
copyright = '2018, Christian S. Perone' | ||
author = 'Christian S. Perone' | ||
|
||
# The short X.Y version | ||
version = sct_dbtool.__version__ | ||
# The full version, including alpha/beta/rc tags | ||
release = sct_dbtool.__version__ | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# If your documentation needs a minimal Sphinx version, state it here. | ||
# | ||
# needs_sphinx = '1.0' | ||
|
||
# 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.ext.autodoc', | ||
'sphinx.ext.viewcode', | ||
] | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
# The suffix(es) of source filenames. | ||
# You can specify multiple suffix as a list of string: | ||
# | ||
# source_suffix = ['.rst', '.md'] | ||
source_suffix = '.rst' | ||
|
||
# The master toctree document. | ||
master_doc = 'index' | ||
|
||
# The language for content autogenerated by Sphinx. Refer to documentation | ||
# for a list of supported languages. | ||
# | ||
# This is also used if you do content translation via gettext catalogs. | ||
# Usually you set "language" from the command line for these cases. | ||
language = None | ||
|
||
# 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 = [] | ||
|
||
# The name of the Pygments (syntax highlighting) style to use. | ||
pygments_style = 'sphinx' | ||
|
||
|
||
# -- 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' | ||
|
||
# Theme options are theme-specific and customize the look and feel of a theme | ||
# further. For a list of options available for each theme, see the | ||
# documentation. | ||
# | ||
html_theme_options = { | ||
'github_user': 'neuropoly', | ||
'github_repo': 'sct_testing_management', | ||
'github_button': True, | ||
'github_banner': False, | ||
'logo_name': True, | ||
} | ||
|
||
# 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'] | ||
|
||
# Custom sidebar templates, must be a dictionary that maps document names | ||
# to template names. | ||
# | ||
# The default sidebars (for documents that don't match any pattern) are | ||
# defined by theme itself. Builtin themes are using these templates by | ||
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', | ||
# 'searchbox.html']``. | ||
# | ||
# html_sidebars = {} | ||
html_sidebars = { | ||
'**': [ | ||
'about.html', | ||
'navigation.html', | ||
'relations.html', | ||
'searchbox.html', | ||
'donate.html', | ||
] | ||
} | ||
|
||
html_scaled_image_link = False | ||
|
||
# -- Options for HTMLHelp output --------------------------------------------- | ||
|
||
# Output file base name for HTML help builder. | ||
htmlhelp_basename = 'sct_dbtooldoc' | ||
|
||
|
||
# -- Options for LaTeX output ------------------------------------------------ | ||
|
||
latex_elements = { | ||
# The paper size ('letterpaper' or 'a4paper'). | ||
# | ||
# 'papersize': 'letterpaper', | ||
|
||
# The font size ('10pt', '11pt' or '12pt'). | ||
# | ||
# 'pointsize': '10pt', | ||
|
||
# Additional stuff for the LaTeX preamble. | ||
# | ||
# 'preamble': '', | ||
|
||
# Latex figure (float) alignment | ||
# | ||
# 'figure_align': 'htbp', | ||
} | ||
|
||
# Grouping the document tree into LaTeX files. List of tuples | ||
# (source start file, target name, title, | ||
# author, documentclass [howto, manual, or own class]). | ||
latex_documents = [ | ||
(master_doc, 'sct_dbtool.tex', 'sct\\_dbtool Documentation', | ||
'Christian S. Perone', 'manual'), | ||
] | ||
|
||
|
||
# -- Options for manual page output ------------------------------------------ | ||
|
||
# One entry per manual page. List of tuples | ||
# (source start file, name, description, authors, manual section). | ||
man_pages = [ | ||
(master_doc, 'sct_dbtool', 'sct_dbtool Documentation', | ||
[author], 1) | ||
] | ||
|
||
|
||
# -- Options for Texinfo output ---------------------------------------------- | ||
|
||
# Grouping the document tree into Texinfo files. List of tuples | ||
# (source start file, target name, title, author, | ||
# dir menu entry, description, category) | ||
texinfo_documents = [ | ||
(master_doc, 'sct_dbtool', 'sct_dbtool Documentation', | ||
author, 'sct_dbtool', 'One line description of project.', | ||
'Miscellaneous'), | ||
] | ||
|
||
|
||
# -- Extension configuration ------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
Introduction | ||
============================================================================== | ||
This is the documentation for the command-line tool `sct_dbtool`. This tool | ||
will apply custom checks into each item of the MRI database. | ||
|
||
Installation | ||
------------------------------------------------------------------------------ | ||
To install it, clone the repository and install with:: | ||
|
||
pip install . | ||
|
||
If you want, you can create a python environment with Anaconda:: | ||
|
||
conda create -n dbtoolenv python=3.6 | ||
source activate dbtoolenv | ||
|
||
Before installing it. | ||
|
||
Configuration | ||
------------------------------------------------------------------------------ | ||
Before running the tool, it must be configured with the database credentials, | ||
in order to do that, just execute the following command below:: | ||
|
||
sct_dbtool setup | ||
|
||
And then answer the questions about the credentials for the Web Management | ||
system. | ||
|
||
How to use it | ||
------------------------------------------------------------------------------ | ||
To use it, just run the following command:: | ||
|
||
sct_dbtool sanity ../duke/sct_testing/large | ||
|
||
Where the last parameter is the path to where the database files are. After | ||
running it, the tool will generate a output report called `report.html` that | ||
can be opened on any browser. | ||
|
||
Implementing more checks | ||
------------------------------------------------------------------------------ | ||
All sanity checks are implemented in :py:mod:`sct_dbtool.sanity` module. All | ||
sanity checks should inherit from the class | ||
:py:class:`.sanity.SanityCheck`. An example is the checking | ||
:py:class:`.sanity.CheckEmptyDemographics` that will check | ||
if the demographics field is present in each item of the database, | ||
the code is shown below: | ||
|
||
.. code-block:: python | ||
class CheckEmptyDemographics(SanityCheck): | ||
def __init__(self, db_path: str): | ||
super().__init__("warning", db_path) | ||
def check(self, item: Dict): | ||
if "demographic" not in item: | ||
self.add_diagnostic("Demographic field not present.", item) | ||
return | ||
if item["demographic"] is None: | ||
self.add_diagnostic("Demographic field is empty.", item) | ||
As you can see, the class inherits from :py:class:`.sanity.SanityCheck` | ||
and it implements two methods: | ||
|
||
* :py:meth:`__init__()`: this is the class constructor, you should just | ||
specify the category of the check, which can be *warning*, *error* or | ||
*info*. And call the base class constructor with this argument | ||
and the `db_path` argument; | ||
|
||
* :py:meth:`check()`: this is the method that implements the check itself. | ||
The `item` argument is a Python dictionary with the database item data. | ||
In the example above, we're just checking if the "demographic" field | ||
is present in this dictionary, and if not, it will call the method | ||
:py:meth:`.SanityCheck.add_diagnostic()` that will add a new diagnostic | ||
message for this item with a custom message. | ||
|
||
After adding a new class, the tool will automatically use this new | ||
class to check every database item in the next run of the `sct_dbtool sanity` | ||
checking. It will also add this class name as filter in the report as | ||
well as all diagnostic messages generated by this checking. | ||
|
||
If you need to refer any file in the file system, as used by other checks | ||
to check if the file mentioned in the database is present in the file system, | ||
you can just use the :py:attr:`.SanityCheck.db_path` object attribute, that contains | ||
the path of the file system that was passed as argument to the `sct_dbtool`. | ||
|
||
Please check other examples in the module :py:mod:`sct_dbtool.sanity` for more information. | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.. sct_dbtool documentation master file, created by | ||
sphinx-quickstart on Sat Jul 7 12:30:25 2018. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
SCT DB Tool documentation | ||
========================================= | ||
This is the website for the SCT DB Tool documentation. SCT DB Tool is an application | ||
that contains tools such as sanity checking for the MRI database. | ||
|
||
.. image:: _static/screenshot.png | ||
:align: center | ||
:scale: 80% | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
:caption: Contents: | ||
|
||
getstarted | ||
modules | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
API Documentation | ||
=============================================================================== | ||
|
||
All modules above listed are under the "sct_dbtool" namespace. | ||
|
||
Contents: | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
|
||
|
||
:mod:`sct_dbtool.api` -- Server API | ||
------------------------------------------------------------------------------- | ||
.. automodule:: sct_dbtool.api | ||
:members: | ||
|
||
|
||
:mod:`sct_dbtool.sanity` -- Sanity Checks | ||
------------------------------------------------------------------------------- | ||
.. automodule:: sct_dbtool.sanity | ||
:members: | ||
|
||
:mod:`sct_dbtool.setup` -- CLI setup entry-point | ||
------------------------------------------------------------------------------- | ||
.. automodule:: sct_dbtool.setup | ||
:members: | ||
|
||
:mod:`sct_dbtool.main` -- Main CLI entry-point | ||
------------------------------------------------------------------------------- | ||
.. automodule:: sct_dbtool.main | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__author__ = 'Christian S. Perone' | ||
__version__ = '0.1' |
Oops, something went wrong.