[docs] add first working sphinx docs build
Browse files- README.md +23 -1
- docs/.gitignore +0 -0
- docs/Makefile +20 -0
- docs/conf.py +70 -0
- docs/index.rst +20 -0
- docs/make.bat +35 -0
- docs/modules.rst +7 -0
- docs/src.prediction_api.rst +29 -0
- docs/src.rst +30 -0
- docs/src.utilities.rst +45 -0
- requirements_docs.txt +1 -0
- src/__init__.py +1 -0
- src/app.py +12 -0
README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
#
|
2 |
|
3 |
## todo
|
4 |
|
@@ -63,3 +63,25 @@ Tests are defined in the `tests` folder in this project. Use PIP to install the
|
|
63 |
```bash
|
64 |
python -m pytest --cov=src --cov-report=term-missing && coverage html
|
65 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SamGIS
|
2 |
|
3 |
## todo
|
4 |
|
|
|
63 |
```bash
|
64 |
python -m pytest --cov=src --cov-report=term-missing && coverage html
|
65 |
```
|
66 |
+
|
67 |
+
## Update the static documentation with sphinx
|
68 |
+
|
69 |
+
Run the sphinx-apidoc: it's a tool for automatic generation of Sphinx sources that, using the autodoc
|
70 |
+
extension, document a whole package in the style of other automatic API documentation tools. See the
|
71 |
+
[documentation page](https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html) for details.
|
72 |
+
Run the command from the project root:
|
73 |
+
|
74 |
+
```bash
|
75 |
+
# missing docs folder
|
76 |
+
sphinx-quickstart -p SamGIS -a "alessandro trinca tornidor" -r 1.0.0 -l python --master index
|
77 |
+
|
78 |
+
# update docs folder
|
79 |
+
sphinx-apidoc -f -o docs src
|
80 |
+
```
|
81 |
+
|
82 |
+
Then it's possible to generate the HTML pages
|
83 |
+
```bash
|
84 |
+
cd docs && make html
|
85 |
+
```
|
86 |
+
|
87 |
+
The static documentation it's now ready at the path `_build/html/index.html`.
|
docs/.gitignore
ADDED
File without changes
|
docs/Makefile
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Minimal makefile for Sphinx documentation
|
2 |
+
#
|
3 |
+
|
4 |
+
# You can set these variables from the command line, and also
|
5 |
+
# from the environment for the first two.
|
6 |
+
SPHINXOPTS ?=
|
7 |
+
SPHINXBUILD ?= sphinx-build
|
8 |
+
SOURCEDIR = .
|
9 |
+
BUILDDIR = _build
|
10 |
+
|
11 |
+
# Put it first so that "make" without argument is like "make help".
|
12 |
+
help:
|
13 |
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
14 |
+
|
15 |
+
.PHONY: help Makefile
|
16 |
+
|
17 |
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
18 |
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
19 |
+
%: Makefile
|
20 |
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
docs/conf.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Configuration file for the Sphinx documentation builder.
|
2 |
+
#
|
3 |
+
# For the full list of built-in configuration values, see the documentation:
|
4 |
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
5 |
+
|
6 |
+
# -- Project information -----------------------------------------------------
|
7 |
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
8 |
+
import os
|
9 |
+
import sys
|
10 |
+
|
11 |
+
project = 'SamGIS'
|
12 |
+
copyright = '2023, alessandro trinca tornidor'
|
13 |
+
author = 'alessandro trinca tornidor'
|
14 |
+
release = '1.0.0'
|
15 |
+
|
16 |
+
# -- General configuration ---------------------------------------------------
|
17 |
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
18 |
+
sys.path.insert(0, os.path.abspath('..'))
|
19 |
+
|
20 |
+
extensions = [
|
21 |
+
'sphinx.ext.autodoc',
|
22 |
+
'sphinx.ext.viewcode',
|
23 |
+
'sphinx.ext.napoleon',
|
24 |
+
# 'sphinx_autodoc_defaultargs'
|
25 |
+
]
|
26 |
+
# Napoleon settings
|
27 |
+
napoleon_google_docstring = True
|
28 |
+
# napoleon_include_init_with_doc = False
|
29 |
+
# napoleon_include_private_with_doc = False
|
30 |
+
# napoleon_include_special_with_doc = True
|
31 |
+
# napoleon_use_admonition_for_examples = False
|
32 |
+
# napoleon_use_admonition_for_notes = False
|
33 |
+
# napoleon_use_admonition_for_references = False
|
34 |
+
# napoleon_use_ivar = False
|
35 |
+
# napoleon_use_param = True
|
36 |
+
# napoleon_use_rtype = True
|
37 |
+
# napoleon_preprocess_types = False
|
38 |
+
# napoleon_type_aliases = None
|
39 |
+
# napoleon_attr_annotations = True
|
40 |
+
|
41 |
+
templates_path = ['_templates']
|
42 |
+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'build/*']
|
43 |
+
|
44 |
+
source_suffix = {
|
45 |
+
'.rst': 'restructuredtext',
|
46 |
+
'.txt': 'restructuredtext',
|
47 |
+
'.md': 'markdown',
|
48 |
+
}
|
49 |
+
|
50 |
+
# default args values
|
51 |
+
rst_prolog = """
|
52 |
+
.. |default| raw:: html
|
53 |
+
|
54 |
+
<div class="default-value-section">""" + \
|
55 |
+
' <span class="default-value-label">Default:</span>'
|
56 |
+
|
57 |
+
# -- Options for HTML output -------------------------------------------------
|
58 |
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
59 |
+
|
60 |
+
html_theme = 'alabaster'
|
61 |
+
html_sidebars = {
|
62 |
+
'**': [
|
63 |
+
'about.html',
|
64 |
+
'navigation.html',
|
65 |
+
'relations.html',
|
66 |
+
'searchbox.html',
|
67 |
+
'donate.html',
|
68 |
+
]
|
69 |
+
}
|
70 |
+
html_static_path = ['_static']
|
docs/index.rst
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. SamGIS documentation master file, created by
|
2 |
+
sphinx-quickstart on Thu Nov 23 21:51:08 2023.
|
3 |
+
You can adapt this file completely to your liking, but it should at least
|
4 |
+
contain the root `toctree` directive.
|
5 |
+
|
6 |
+
Welcome to SamGIS's documentation!
|
7 |
+
==================================
|
8 |
+
|
9 |
+
.. toctree::
|
10 |
+
:maxdepth: 2
|
11 |
+
:caption: Contents:
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
Indices and tables
|
16 |
+
==================
|
17 |
+
|
18 |
+
* :ref:`genindex`
|
19 |
+
* :ref:`modindex`
|
20 |
+
* :ref:`search`
|
docs/make.bat
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@ECHO OFF
|
2 |
+
|
3 |
+
pushd %~dp0
|
4 |
+
|
5 |
+
REM Command file for Sphinx documentation
|
6 |
+
|
7 |
+
if "%SPHINXBUILD%" == "" (
|
8 |
+
set SPHINXBUILD=sphinx-build
|
9 |
+
)
|
10 |
+
set SOURCEDIR=.
|
11 |
+
set BUILDDIR=_build
|
12 |
+
|
13 |
+
%SPHINXBUILD% >NUL 2>NUL
|
14 |
+
if errorlevel 9009 (
|
15 |
+
echo.
|
16 |
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
17 |
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
18 |
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
19 |
+
echo.may add the Sphinx directory to PATH.
|
20 |
+
echo.
|
21 |
+
echo.If you don't have Sphinx installed, grab it from
|
22 |
+
echo.https://www.sphinx-doc.org/
|
23 |
+
exit /b 1
|
24 |
+
)
|
25 |
+
|
26 |
+
if "%1" == "" goto help
|
27 |
+
|
28 |
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
29 |
+
goto end
|
30 |
+
|
31 |
+
:help
|
32 |
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
33 |
+
|
34 |
+
:end
|
35 |
+
popd
|
docs/modules.rst
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
src
|
2 |
+
===
|
3 |
+
|
4 |
+
.. toctree::
|
5 |
+
:maxdepth: 4
|
6 |
+
|
7 |
+
src
|
docs/src.prediction_api.rst
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
src.prediction\_api package
|
2 |
+
===========================
|
3 |
+
|
4 |
+
Submodules
|
5 |
+
----------
|
6 |
+
|
7 |
+
src.prediction\_api.predictors module
|
8 |
+
-------------------------------------
|
9 |
+
|
10 |
+
.. automodule:: src.prediction_api.predictors
|
11 |
+
:members:
|
12 |
+
:undoc-members:
|
13 |
+
:show-inheritance:
|
14 |
+
|
15 |
+
src.prediction\_api.sam\_onnx module
|
16 |
+
------------------------------------
|
17 |
+
|
18 |
+
.. automodule:: src.prediction_api.sam_onnx
|
19 |
+
:members:
|
20 |
+
:undoc-members:
|
21 |
+
:show-inheritance:
|
22 |
+
|
23 |
+
Module contents
|
24 |
+
---------------
|
25 |
+
|
26 |
+
.. automodule:: src.prediction_api
|
27 |
+
:members:
|
28 |
+
:undoc-members:
|
29 |
+
:show-inheritance:
|
docs/src.rst
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
src package
|
2 |
+
===========
|
3 |
+
|
4 |
+
Subpackages
|
5 |
+
-----------
|
6 |
+
|
7 |
+
.. toctree::
|
8 |
+
:maxdepth: 4
|
9 |
+
|
10 |
+
src.prediction_api
|
11 |
+
src.utilities
|
12 |
+
|
13 |
+
Submodules
|
14 |
+
----------
|
15 |
+
|
16 |
+
src.app module
|
17 |
+
--------------
|
18 |
+
|
19 |
+
.. automodule:: src.app
|
20 |
+
:members:
|
21 |
+
:undoc-members:
|
22 |
+
:show-inheritance:
|
23 |
+
|
24 |
+
Module contents
|
25 |
+
---------------
|
26 |
+
|
27 |
+
.. automodule:: src
|
28 |
+
:members:
|
29 |
+
:undoc-members:
|
30 |
+
:show-inheritance:
|
docs/src.utilities.rst
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
src.utilities package
|
2 |
+
=====================
|
3 |
+
|
4 |
+
Submodules
|
5 |
+
----------
|
6 |
+
|
7 |
+
src.utilities.constants module
|
8 |
+
------------------------------
|
9 |
+
|
10 |
+
.. automodule:: src.utilities.constants
|
11 |
+
:members:
|
12 |
+
:undoc-members:
|
13 |
+
:show-inheritance:
|
14 |
+
|
15 |
+
src.utilities.serialize module
|
16 |
+
------------------------------
|
17 |
+
|
18 |
+
.. automodule:: src.utilities.serialize
|
19 |
+
:members:
|
20 |
+
:undoc-members:
|
21 |
+
:show-inheritance:
|
22 |
+
|
23 |
+
src.utilities.type\_hints module
|
24 |
+
--------------------------------
|
25 |
+
|
26 |
+
.. automodule:: src.utilities.type_hints
|
27 |
+
:members:
|
28 |
+
:undoc-members:
|
29 |
+
:show-inheritance:
|
30 |
+
|
31 |
+
src.utilities.utilities module
|
32 |
+
------------------------------
|
33 |
+
|
34 |
+
.. automodule:: src.utilities.utilities
|
35 |
+
:members:
|
36 |
+
:undoc-members:
|
37 |
+
:show-inheritance:
|
38 |
+
|
39 |
+
Module contents
|
40 |
+
---------------
|
41 |
+
|
42 |
+
.. automodule:: src.utilities
|
43 |
+
:members:
|
44 |
+
:undoc-members:
|
45 |
+
:show-inheritance:
|
requirements_docs.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
sphinx
|
src/__init__.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from aws_lambda_powertools import Logger
|
2 |
import os
|
3 |
from pathlib import Path
|
|
|
1 |
+
"""Get machine learning predictions from geodata raster images"""
|
2 |
from aws_lambda_powertools import Logger
|
3 |
import os
|
4 |
from pathlib import Path
|
src/app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import time
|
2 |
from http import HTTPStatus
|
3 |
|
@@ -10,6 +11,17 @@ from src.prediction_api.predictors import samexporter_predict
|
|
10 |
|
11 |
|
12 |
def lambda_handler(event: dict, context: LambdaContext):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
app_logger.info(f"start with aws_request_id:{context.aws_request_id}.")
|
14 |
start_time = time.time()
|
15 |
|
|
|
1 |
+
"""Lambda entry point"""
|
2 |
import time
|
3 |
from http import HTTPStatus
|
4 |
|
|
|
11 |
|
12 |
|
13 |
def lambda_handler(event: dict, context: LambdaContext):
|
14 |
+
"""
|
15 |
+
Handle the request for the serverless backend, dispatch the response.
|
16 |
+
|
17 |
+
Args:
|
18 |
+
event: request content
|
19 |
+
context: request context
|
20 |
+
|
21 |
+
Returns:
|
22 |
+
dict: response from try_return_output() function
|
23 |
+
|
24 |
+
"""
|
25 |
app_logger.info(f"start with aws_request_id:{context.aws_request_id}.")
|
26 |
start_time = time.time()
|
27 |
|