alessandro trinca tornidor commited on
Commit
0914710
1 Parent(s): b00385f

[feat] prepare entire docker build with nvidia GPU on hf space cloning https://huggingface.co/spaces/aletrn/samgis

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .coveragerc +9 -0
  2. .dockerignore +16 -0
  3. .gitignore +278 -0
  4. .idea/.gitignore +3 -0
  5. .idea/inspectionProfiles/profiles_settings.xml +6 -0
  6. .idea/vcs.xml +6 -0
  7. Dockerfile +173 -0
  8. LICENSE.txt +21 -0
  9. README.md +124 -4
  10. dockerfiles/apt_preferences_debian +9 -0
  11. dockerfiles/apt_preferences_ubuntu +9 -0
  12. dockerfiles/debian.sources +17 -0
  13. dockerfiles/dockerfile-fastapi-fastsam-api +1 -0
  14. dockerfiles/dockerfile-lambda-fastsam-api +36 -0
  15. dockerfiles/dockerfile-lisa-base +140 -0
  16. dockerfiles/dockerfile-lisa-predictions +45 -0
  17. dockerfiles/dockerfile-samgis-base +132 -0
  18. dockerfiles/ubuntu.sources +18 -0
  19. docs/.gitignore +0 -0
  20. docs/Changelog.md +37 -0
  21. docs/Makefile +20 -0
  22. docs/_static/.gitignore +0 -0
  23. docs/brief_project_presentation.md +20 -0
  24. docs/conf.py +72 -0
  25. docs/external_links.rst +5 -0
  26. docs/external_links_md.md +2 -0
  27. docs/index.rst +27 -0
  28. docs/make.bat +35 -0
  29. docs/modules.rst +7 -0
  30. docs/openapi.rst +11 -0
  31. docs/other_resources.rst +9 -0
  32. docs/samgis.io.rst +53 -0
  33. docs/samgis.prediction_api.rst +21 -0
  34. docs/samgis.rst +20 -0
  35. docs/samgis.utilities.rst +29 -0
  36. docs/specs/openapi.yaml +177 -0
  37. events/colico_point_rectangle_output.json +1 -0
  38. events/colico_prompt1.json +5 -0
  39. events/example_output.json +19 -0
  40. events/payload_lisa_teglio.json +5 -0
  41. events/payload_multiprompt_api_request_body.json +48 -0
  42. events/payload_multiprompt_api_response_body_failure.json +1 -0
  43. events/payload_multiprompt_api_response_body_success.json +8 -0
  44. events/payload_point.json +14 -0
  45. events/payload_point2.json +14 -0
  46. events/payload_point_eolie.json +24 -0
  47. events/payload_point_error_int_str.json +62 -0
  48. events/payload_point_rectangle_colico.json +48 -0
  49. events/payload_rectangle.json +12 -0
  50. events/payloads_body_base64.json +52 -0
.coveragerc ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ [run]
2
+ source = samgis
3
+ omit = ./venv/*,__version__.py,*tests*,*apps.py,*manage.py,*__init__.py,*migrations*,*asgi*,*wsgi*,*admin.py,*urls.py,./tests/*
4
+
5
+ [report]
6
+ omit = ./venv/*,*tests*,*apps.py,*manage.py,*__init__.py,*migrations*,*asgi*,*wsgi*,*admin.py,*urls.py,./tests/*
7
+
8
+ exclude_lines =
9
+ if __name__ == .__main__.:
.dockerignore ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ venv/
2
+ *.pyc
3
+ __cache__
4
+ .idea
5
+ tmp/
6
+ .env*
7
+ __pycache__
8
+ .DS_Store
9
+ .pytest_cache
10
+ node_modules
11
+ dist
12
+ static/node_modules
13
+ static/dist
14
+ static/.env*
15
+ .coverage
16
+ .git
.gitignore ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Created by https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode
3
+
4
+ ### Linux ###
5
+ *~
6
+
7
+ # temporary files which can be created if a process still has a handle open of a deleted file
8
+ .fuse_hidden*
9
+
10
+ # KDE directory preferences
11
+ .directory
12
+
13
+ # Linux trash folder which might appear on any partition or disk
14
+ .Trash-*
15
+
16
+ # .nfs files are created when an open file is removed but is still being accessed
17
+ .nfs*
18
+
19
+ ### OSX ###
20
+ *.DS_Store
21
+ .AppleDouble
22
+ .LSOverride
23
+
24
+ # Icon must end with two \r
25
+ Icon
26
+
27
+ # Thumbnails
28
+ ._*
29
+
30
+ # Files that might appear in the root of a volume
31
+ .DocumentRevisions-V100
32
+ .fseventsd
33
+ .Spotlight-V100
34
+ .TemporaryItems
35
+ .Trashes
36
+ .VolumeIcon.icns
37
+ .com.apple.timemachine.donotpresent
38
+
39
+ # Directories potentially created on remote AFP share
40
+ .AppleDB
41
+ .AppleDesktop
42
+ Network Trash Folder
43
+ Temporary Items
44
+ .apdisk
45
+
46
+ # CMake
47
+ cmake-build-debug/
48
+
49
+ # Ruby plugin and RubyMine
50
+ /.rakeTasks
51
+
52
+ # Crashlytics plugin (for Android Studio and IntelliJ)
53
+ com_crashlytics_export_strings.xml
54
+ crashlytics.properties
55
+ crashlytics-build.properties
56
+ fabric.properties
57
+
58
+ ### Python ###
59
+ # Byte-compiled / optimized / DLL files
60
+ __pycache__/
61
+ *.py[cod]
62
+ *$py.class
63
+
64
+ # C extensions
65
+ *.so
66
+
67
+ # Distribution / packaging
68
+ .Python
69
+ build/
70
+ develop-eggs/
71
+ dist/
72
+ downloads/
73
+ eggs/
74
+ .eggs/
75
+ lib/
76
+ lib64/
77
+ parts/
78
+ sdist/
79
+ var/
80
+ wheels/
81
+ *.egg-info/
82
+ .installed.cfg
83
+ *.egg
84
+
85
+ # PyInstaller
86
+ # Usually these files are written by a python script from a template
87
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
88
+ *.manifest
89
+ *.spec
90
+
91
+ # Installer logs
92
+ pip-log.txt
93
+ pip-delete-this-directory.txt
94
+
95
+ # Unit test / coverage reports
96
+ htmlcov/
97
+ .tox/
98
+ .coverage
99
+ .coverage.*
100
+ .cache
101
+ .pytest_cache/
102
+ nosetests.xml
103
+ coverage.xml
104
+ *.cover
105
+ .hypothesis/
106
+
107
+ # Translations
108
+ *.mo
109
+ *.pot
110
+
111
+ # Flask stuff:
112
+ instance/
113
+ .webassets-cache
114
+
115
+ # Scrapy stuff:
116
+ .scrapy
117
+
118
+ # Sphinx documentation
119
+ docs/_build/doctrees/*
120
+ docs/_build/html/*
121
+
122
+ # PyBuilder
123
+ target/
124
+
125
+ # Jupyter Notebook
126
+ .ipynb_checkpoints
127
+
128
+ # pyenv
129
+ .python-version
130
+
131
+ # celery beat schedule file
132
+ celerybeat-schedule.*
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .env*
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+
160
+ ### VisualStudioCode ###
161
+ .vscode/*
162
+ !.vscode/settings.json
163
+ !.vscode/tasks.json
164
+ !.vscode/launch.json
165
+ !.vscode/extensions.json
166
+ .history
167
+
168
+ ### Windows ###
169
+ # Windows thumbnail cache files
170
+ Thumbs.db
171
+ ehthumbs.db
172
+ ehthumbs_vista.db
173
+
174
+ # Folder config file
175
+ Desktop.ini
176
+
177
+ # Recycle Bin used on file shares
178
+ $RECYCLE.BIN/
179
+
180
+ # Windows Installer files
181
+ *.cab
182
+ *.msi
183
+ *.msm
184
+ *.msp
185
+
186
+ # Windows shortcuts
187
+ *.lnk
188
+
189
+ # Build folder
190
+
191
+ */build/*
192
+
193
+ # custom
194
+ *.ori
195
+ tmp
196
+ nohup.out
197
+ /tests/events.tar
198
+ function_dump_*.json
199
+
200
+ # onnx models
201
+ *.onnx
202
+
203
+ # End of https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode
204
+
205
+ ## .idea files
206
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
207
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
208
+
209
+ # User-specific stuff
210
+ .idea/**/workspace.xml
211
+ .idea/**/tasks.xml
212
+ .idea/**/usage.statistics.xml
213
+ .idea/**/dictionaries
214
+ .idea/**/shelf
215
+
216
+ # Generated files
217
+ .idea/**/contentModel.xml
218
+
219
+ # Sensitive or high-churn files
220
+ .idea/**/dataSources/
221
+ .idea/**/dataSources.ids
222
+ .idea/**/dataSources.local.xml
223
+ .idea/**/sqlDataSources.xml
224
+ .idea/**/dynamic.xml
225
+ .idea/**/uiDesigner.xml
226
+ .idea/**/dbnavigator.xml
227
+
228
+ # Gradle
229
+ .idea/**/gradle.xml
230
+ .idea/**/libraries
231
+
232
+ # Gradle and Maven with auto-import
233
+ # When using Gradle or Maven with auto-import, you should exclude module files,
234
+ # since they will be recreated, and may cause churn. Uncomment if using
235
+ # auto-import.
236
+ # .idea/modules.xml
237
+ .idea/*.iml
238
+ # .idea/modules
239
+
240
+ # CMake
241
+ cmake-build-*/
242
+
243
+ # Mongo Explorer plugin
244
+ .idea/**/mongoSettings.xml
245
+
246
+ # File-based project format
247
+ *.iws
248
+
249
+ # IntelliJ
250
+ out/
251
+
252
+ # mpeltonen/sbt-idea plugin
253
+ .idea_modules/
254
+
255
+ # JIRA plugin
256
+ atlassian-ide-plugin.xml
257
+
258
+ # Cursive Clojure plugin
259
+ .idea/replstate.xml
260
+
261
+ # Crashlytics plugin (for Android Studio and IntelliJ)
262
+ com_crashlytics_export_strings.xml
263
+ crashlytics.properties
264
+ crashlytics-build.properties
265
+ fabric.properties
266
+
267
+ # Editor-based Rest Client
268
+ .idea/httpRequests
269
+
270
+ # Android studio 3.1+ serialized cache file
271
+ .idea/caches/build_file_checksums.ser
272
+
273
+ # Sonarlint plugin
274
+ .idea/sonarlint
275
+ /.idea/modules.xml
276
+
277
+ # node_modules
278
+ node_modules
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
Dockerfile ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Include global ARGs at the dockerfile top
2
+ ARG ARCH="x86_64"
3
+ ARG LAMBDA_TASK_ROOT="/var/task"
4
+ ARG FASTAPI_STATIC="${LAMBDA_TASK_ROOT}/static"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ARG POETRY_NO_INTERACTION=1
7
+ ARG POETRY_VIRTUALENVS_IN_PROJECT=1
8
+ ARG POETRY_VIRTUALENVS_CREATE=1
9
+ ARG POETRY_CACHE_DIR=/tmp/poetry_cache
10
+
11
+
12
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as builder_global
13
+
14
+ LABEL authors="alessandro@trinca.tornidor.com"
15
+
16
+ ARG ARCH
17
+ ARG LAMBDA_TASK_ROOT
18
+ ARG PYTHONPATH
19
+ ARG POETRY_NO_INTERACTION
20
+ ARG POETRY_VIRTUALENVS_IN_PROJECT
21
+ ARG POETRY_VIRTUALENVS_CREATE
22
+ ARG POETRY_CACHE_DIR
23
+ ARG DEPENDENCY_GROUP
24
+
25
+ RUN echo "ARCH: $ARCH ..."
26
+
27
+ RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
28
+ RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
29
+ RUN test -n ${DEPENDENCY_GROUP:?}
30
+ RUN echo "python DEPENDENCY_GROUP: ${DEPENDENCY_GROUP} ..."
31
+ RUN echo "arg dep:"
32
+
33
+ # Set working directory to function root directory
34
+ WORKDIR ${LAMBDA_TASK_ROOT}
35
+ COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
36
+
37
+ RUN cat /etc/lsb-release
38
+ # avoid segment-geospatial exception caused by missing libGL.so.1 library
39
+ RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
40
+
41
+ RUN apt update && apt upgrade -y && apt install -y libgl1 curl python3-pip git-lfs && apt clean
42
+ COPY ./dockerfiles/apt_preferences_ubuntu /etc/apt/preferences
43
+ COPY ./dockerfiles/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources
44
+ #RUN echo "run update noble..."
45
+ #RUN apt update
46
+ #RUN apt update && apt install -t noble zlib1g -y
47
+ RUN git lfs install
48
+ RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
49
+
50
+ RUN ls -l /etc/apt/sources* /etc/apt/preferences*
51
+
52
+ # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
53
+ RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
54
+
55
+ RUN which poetry && poetry --version && poetry config --list
56
+ RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
57
+ RUN poetry config installer.max-workers 7
58
+ RUN echo "# poetry config --list #" && poetry config --list
59
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
60
+ #RUN . ${LAMBDA_TASK_ROOT}/.venv/bin/activate && ${LAMBDA_TASK_ROOT}/.venv/bin/python --version && ${LAMBDA_TASK_ROOT}/.venv/bin/python -m pip install pip wheel setuptools --upgrade
61
+ RUN poetry run python -m pip install pip wheel setuptools --upgrade
62
+ RUN poetry install --with ${DEPENDENCY_GROUP} --no-root -vvv
63
+
64
+
65
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as runtime
66
+
67
+ ARG ARCH
68
+ ARG LAMBDA_TASK_ROOT
69
+
70
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
71
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
72
+
73
+ RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
74
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
75
+ RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
76
+ RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
77
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
78
+ RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
79
+ COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
80
+
81
+ RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
82
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
83
+ RUN ls -lA ${LAMBDA_TASK_ROOT}/
84
+
85
+
86
+ ### conditional section
87
+ FROM node:20-slim AS node_fastapi
88
+
89
+ ARG DEPENDENCY_GROUP
90
+ ENV PNPM_HOME="/pnpm"
91
+ ENV PATH="$PNPM_HOME:$PATH"
92
+
93
+ RUN corepack enable
94
+
95
+ COPY ./static /appnode
96
+ WORKDIR /appnode
97
+ # RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then echo "pnpm store path:" && pnpm store path; fi
98
+
99
+
100
+ FROM node_fastapi AS node_prod_deps
101
+
102
+ ARG DEPENDENCY_GROUP
103
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
104
+ pnpm install --prod --frozen-lockfile; else \
105
+ echo "DEPENDENCY_GROUP 1: ${DEPENDENCY_GROUP} ..."; fi
106
+ # here multiple conditions concatenated to avoid failing on check
107
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi; fi
108
+
109
+
110
+ FROM node_fastapi AS node_build
111
+
112
+ ARG DEPENDENCY_GROUP
113
+ ARG VITE__MAP_DESCRIPTION
114
+ ARG VITE__SAMGIS_SPACE
115
+ RUN echo "VITE__MAP_DESCRIPTION:" ${VITE__MAP_DESCRIPTION}
116
+ RUN echo "VITE__SAMGIS_SPACE:" ${VITE__SAMGIS_SPACE}
117
+
118
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
119
+ pnpm install --frozen-lockfile; else \
120
+ echo "DEPENDENCY_GROUP 2: ${DEPENDENCY_GROUP} ..."; fi
121
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then pnpm build; fi
122
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
123
+ pnpm tailwindcss -i /appnode/src/input.css -o /appnode/dist/output.css; fi
124
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi; fi
125
+
126
+
127
+ FROM runtime
128
+ ARG FASTAPI_STATIC
129
+ RUN mkdir ${FASTAPI_STATIC}
130
+
131
+ COPY ./machine_learning_models ${LAMBDA_TASK_ROOT}/machine_learning_models
132
+ COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
133
+ COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
134
+
135
+
136
+ # Include global arg in this stage of the build
137
+ ARG LAMBDA_TASK_ROOT="/var/task"
138
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
139
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
140
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
141
+ ENV IS_AWS_LAMBDA=""
142
+
143
+ # Set working directory to function root directory
144
+ WORKDIR ${LAMBDA_TASK_ROOT}
145
+
146
+ COPY samgis ${LAMBDA_TASK_ROOT}/samgis
147
+ COPY wrappers ${LAMBDA_TASK_ROOT}/wrappers
148
+
149
+ RUN ls -l /usr/bin/which
150
+ RUN /usr/bin/which python
151
+ RUN python -v
152
+ RUN echo "PYTHONPATH: ${PYTHONPATH}."
153
+ RUN echo "PATH: ${PATH}."
154
+ RUN echo "LAMBDA_TASK_ROOT: ${LAMBDA_TASK_ROOT}."
155
+ RUN ls -l ${LAMBDA_TASK_ROOT}
156
+ RUN ls -ld ${LAMBDA_TASK_ROOT}
157
+ RUN ls -l ${LAMBDA_TASK_ROOT}/machine_learning_models
158
+ RUN python -c "import sys; print(sys.path)"
159
+ RUN python -c "import cv2"
160
+ RUN python -c "import fastapi"
161
+ RUN python -c "import geopandas"
162
+ RUN python -c "import loguru"
163
+ RUN python -c "import onnxruntime"
164
+ RUN python -c "import rasterio"
165
+ RUN python -c "import uvicorn"
166
+ RUN df -h
167
+ RUN ls -l ${LAMBDA_TASK_ROOT}/samgis/
168
+ RUN ls -l ${LAMBDA_TASK_ROOT}/wrappers/
169
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/
170
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/dist
171
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/node_modules
172
+
173
+ CMD ["uvicorn", "wrappers.fastapi_wrapper:app", "--host", "0.0.0.0", "--port", "7860"]
LICENSE.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Alessandro Trinca Tornidor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,10 +1,130 @@
1
  ---
2
- title: Samgis Lisa On Cuda
3
- emoji: 📉
4
- colorFrom: blue
5
  colorTo: blue
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: SamGIS
3
+ emoji: 🗺️
4
+ colorFrom: red
5
  colorTo: blue
6
  sdk: docker
7
  pinned: false
8
+ license: mit
9
  ---
10
 
11
+ ## Segment Anything models
12
+ It's possible to prepare the model files using https://github.com/vietanhdev/samexporter/ or using the ones
13
+ from https://huggingface.co/aletrn/sam-quantized (copy them within the folder `/machine_learning_models`).
14
+
15
+ ## SamGIS - HuggingFace version
16
+
17
+ The SamGIS HuggingSpace url is https://huggingface.co/spaces/aletrn/samgis.
18
+ Build the docker image this way:
19
+
20
+ ```bash
21
+ # clean any old active containers
22
+ docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
23
+
24
+ # build the base docker image from the repository root folder using ARGs:
25
+ # - DEPENDENCY_GROUP=fastapi used by poetry
26
+ # VITE__MAP_DESCRIPTION, VITE__SAMGIS_SPACE used by 'docker build'
27
+ (
28
+ set -o allexport && source <(cat ./static/.env|grep VITE__) && set +o allexport;
29
+ env|grep VITE__;
30
+ docker build . -f dockerfiles/dockerfile-samgis-base --progress=plain \
31
+ --build-arg DEPENDENCY_GROUP=fastapi \
32
+ --build-arg VITE__MAP_DESCRIPTION=${VITE__MAP_DESCRIPTION} \
33
+ --build-arg VITE__SAMGIS_SPACE=${VITE__SAMGIS_SPACE} \
34
+ --tag registry.gitlab.com/aletrn/gis-prediction
35
+ )
36
+
37
+ # build the image, use the tag "samgis-huggingface"
38
+ docker build . --tag example-docker-namespace/samgis-huggingface --progress=plain
39
+ ```
40
+
41
+ Run the container (keep it on background) and show logs
42
+
43
+ ```bash
44
+ docker run -d --name samgis-huggingface -p 7860:7860 example-docker-namespace/samgis-huggingface; docker logs -f samgis-huggingface
45
+ ```
46
+
47
+ Test it with curl using a json payload:
48
+
49
+ ```bash
50
+ URL=http://localhost:7860/infer_samgis
51
+ curl -d@./events/payload_point_eolie.json -H 'accept: application/json' ${URL}
52
+ ```
53
+
54
+ or better visiting the swagger page on http://localhost:7860/docs
55
+
56
+
57
+ ## SamGIS - lambda AWS version
58
+
59
+ Build the docker image this way:
60
+
61
+ ```bash
62
+ # clean any old active containers
63
+ docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
64
+
65
+ # build the base docker image with the docker aws repository tag
66
+ docker build . -f dockerfiles/dockerfile-samgis-base --build-arg DEPENDENCY_GROUP=aws_lambda \
67
+ --tag example-docker-namespace/samgis-base-aws-lambda --progress=plain
68
+
69
+ # build the final docker image
70
+ docker build . -f dockerfiles/dockerfile-lambda-fastsam-api --tag example-docker-namespace/lambda-fastsam-api --progress=plain
71
+ ```
72
+
73
+ Run the container (keep it on background) and show logs
74
+
75
+ ```bash
76
+ docker run -d --name lambda-fastsam-api -p 8080:8080 lambda-fastsam-api; docker logs -f lambda-fastsam-api
77
+ ```
78
+
79
+ Test it with curl using a json payload:
80
+
81
+ ```bash
82
+ URL=http://localhost:8080/2015-03-31/functions/function/invocations
83
+ curl -d@./events/payload_point_eolie.json -H 'accept: application/json' ${URL}
84
+ ```
85
+
86
+ ### Publish the aws lambda docker image
87
+ Login on aws ECR with the correct aws profile (change the example `example-docker-namespace/` repository url with the one from
88
+ the [ECR push command instructions page](https://eu-west-1.console.aws.amazon.com/ecr/repositories/)).
89
+
90
+ ### Dependencies installation and local tests
91
+ The docker build process needs only the base dependency group plus the `aws_lambda` or `fastapi` optional one.
92
+ Install also the `test` and/or `docs` groups if needed.
93
+
94
+ ### Tests
95
+
96
+ Tests are defined in the `tests` folder in this project. Use PIP to install the test dependencies and run tests.
97
+
98
+ ```bash
99
+ python -m pytest --cov=samgis --cov-report=term-missing && coverage html
100
+ ```
101
+
102
+ ### How to update the static documentation with sphinx
103
+
104
+ This project documentation uses sphinx-apidoc: it's a tool for automatic generation of Sphinx sources that, using the autodoc
105
+ extension, document a whole package in the style of other automatic API documentation tools. See the
106
+ [documentation page](https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html) for details.
107
+ Run the command from the project root:
108
+
109
+ ```bash
110
+ # missing docs folder (run from project root) initialize this way
111
+ cd docs && sphinx-quickstart -p SamGIS -r 1.0.0 -l python --master index
112
+
113
+ # update docs folder (from project root)
114
+ sphinx-apidoc -f -o docs samgis
115
+ ```
116
+
117
+ Then it's possible to generate the HTML pages
118
+
119
+ ```bash
120
+ cd docs && make html && ../
121
+
122
+ # to clean old files
123
+ cd docs && make clean html && cd ../
124
+ ```
125
+
126
+ The static documentation it's now ready at the path `docs/_build/html/index.html`.
127
+
128
+ To create a work in progress openapi json or yaml file use
129
+ - `extract-openapi-fastapi.py`
130
+ - `extract-openapi-lambda.py` (useful to export the json schema request and response from lambda app api)
dockerfiles/apt_preferences_debian ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Explanation: Uninstall or do not install any Debian-originated
2
+ Explanation: package versions other than those in the stable distro
3
+ Package: *
4
+ Pin: release a=stable
5
+ Pin-Priority: 900
6
+
7
+ Package: zlib1g
8
+ Pin: release a=trixie
9
+ Pin-Priority: -10
dockerfiles/apt_preferences_ubuntu ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Explanation: Uninstall or do not install any Debian-originated
2
+ Explanation: package versions other than those in the stable distro
3
+ Package: *
4
+ Pin: release a=stable
5
+ Pin-Priority: 900
6
+
7
+ Package: zlib1g
8
+ Pin: release a=noble
9
+ Pin-Priority: -10
dockerfiles/debian.sources ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Types: deb deb-src
2
+ URIs: http://deb.debian.org/debian
3
+ Suites: bookworm bookworm-updates
4
+ Components: main
5
+ Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
6
+
7
+ Types: deb deb-src
8
+ URIs: http://deb.debian.org/debian-security
9
+ Suites: bookworm-security
10
+ Components: main
11
+ Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
12
+
13
+ Types: deb
14
+ URIs: http://deb.debian.org/debian
15
+ Suites: trixie
16
+ Components: main
17
+ Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
dockerfiles/dockerfile-fastapi-fastsam-api ADDED
@@ -0,0 +1 @@
 
 
1
+ Dockerfile
dockerfiles/dockerfile-lambda-fastsam-api ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM localhost/samgis-base-aws-lambda:latest
2
+
3
+ # Include global arg in this stage of the build
4
+ ARG LAMBDA_TASK_ROOT="/var/task"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
7
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
8
+ ENV IS_AWS_LAMBDA="True"
9
+
10
+ # Set working directory to function root directory
11
+ WORKDIR ${LAMBDA_TASK_ROOT}
12
+ COPY ./samgis ${LAMBDA_TASK_ROOT}/samgis
13
+ COPY ./wrappers ${LAMBDA_TASK_ROOT}/wrappers
14
+
15
+ RUN ls -l /usr/bin/which
16
+ RUN /usr/bin/which python
17
+ RUN python -v
18
+ RUN echo "PYTHONPATH: ${PYTHONPATH}."
19
+ RUN echo "PATH: ${PATH}."
20
+ RUN echo "LAMBDA_TASK_ROOT: ${LAMBDA_TASK_ROOT}."
21
+ RUN ls -l ${LAMBDA_TASK_ROOT}
22
+ RUN ls -ld ${LAMBDA_TASK_ROOT}
23
+ RUN ls -l ${LAMBDA_TASK_ROOT}/machine_learning_models
24
+ RUN python -c "import sys; print(sys.path)"
25
+ RUN python -c "import awslambdaric"
26
+ RUN python -c "import cv2"
27
+ RUN python -c "import geopandas"
28
+ RUN python -c "import onnxruntime"
29
+ RUN python -c "import rasterio"
30
+ RUN df -h
31
+ RUN ls -l /lambda-entrypoint.sh
32
+ RUN ls -l ${LAMBDA_TASK_ROOT}/samgis/
33
+ RUN ls -l ${LAMBDA_TASK_ROOT}/wrappers/
34
+
35
+ ENTRYPOINT ["/lambda-entrypoint.sh"]
36
+ CMD [ "wrappers.lambda_wrapper.lambda_handler" ]
dockerfiles/dockerfile-lisa-base ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Include global ARGs at the dockerfile top
2
+ ARG ARCH="x86_64"
3
+ ARG LAMBDA_TASK_ROOT="/var/task"
4
+ ARG FASTAPI_STATIC="${LAMBDA_TASK_ROOT}/static"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ARG POETRY_NO_INTERACTION=1
7
+ ARG POETRY_VIRTUALENVS_IN_PROJECT=1
8
+ ARG POETRY_VIRTUALENVS_CREATE=1
9
+ ARG POETRY_CACHE_DIR=/tmp/poetry_cache
10
+
11
+
12
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as builder_global
13
+
14
+ LABEL authors="alessandro@trinca.tornidor.com"
15
+
16
+ ARG ARCH
17
+ ARG LAMBDA_TASK_ROOT
18
+ ARG PYTHONPATH
19
+ ARG POETRY_NO_INTERACTION
20
+ ARG POETRY_VIRTUALENVS_IN_PROJECT
21
+ ARG POETRY_VIRTUALENVS_CREATE
22
+ ARG POETRY_CACHE_DIR
23
+ ARG DEPENDENCY_GROUP
24
+
25
+ RUN echo "ARCH: $ARCH ..."
26
+
27
+ RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
28
+ RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
29
+ RUN test -n ${DEPENDENCY_GROUP:?}
30
+ RUN echo "python DEPENDENCY_GROUP: ${DEPENDENCY_GROUP} ..."
31
+ RUN echo "arg dep:"
32
+
33
+ # Set working directory to function root directory
34
+ WORKDIR ${LAMBDA_TASK_ROOT}
35
+ COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
36
+
37
+ RUN cat /etc/lsb-release
38
+ # avoid segment-geospatial exception caused by missing libGL.so.1 library
39
+ RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
40
+
41
+ ADD https://github.com/AkihiroSuda/clone3-workaround/releases/download/v1.0.0/clone3-workaround.x86_64 /clone3-workaround
42
+ RUN chmod 755 /clone3-workaround
43
+ SHELL ["/clone3-workaround","/bin/sh", "-c"]
44
+
45
+ RUN apt update && apt upgrade -y && apt install -y libgl1 curl python3-pip git-lfs && apt clean
46
+ COPY ./dockerfiles/apt_preferences_ubuntu /etc/apt/preferences
47
+ COPY ./dockerfiles/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources
48
+ #RUN echo "run update noble..."
49
+ #RUN apt update
50
+ #RUN apt update && apt install -t noble zlib1g -y
51
+ RUN git lfs install
52
+ RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
53
+
54
+ RUN ls -l /etc/apt/sources* /etc/apt/preferences*
55
+
56
+ # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
57
+ RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
58
+
59
+ RUN which poetry && poetry --version && poetry config --list
60
+ RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
61
+ RUN poetry config installer.max-workers 7
62
+ RUN echo "# poetry config --list #" && poetry config --list
63
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
64
+ #RUN . ${LAMBDA_TASK_ROOT}/.venv/bin/activate && ${LAMBDA_TASK_ROOT}/.venv/bin/python --version && ${LAMBDA_TASK_ROOT}/.venv/bin/python -m pip install pip wheel setuptools --upgrade
65
+ RUN poetry run python -m pip install pip wheel setuptools --upgrade
66
+ RUN poetry install --with ${DEPENDENCY_GROUP} --no-root -vvv
67
+
68
+
69
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as runtime
70
+
71
+ ARG ARCH
72
+ ARG LAMBDA_TASK_ROOT
73
+
74
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
75
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
76
+
77
+ RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
78
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
79
+ RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
80
+ RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
81
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
82
+ RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
83
+ COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
84
+
85
+ RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
86
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
87
+ RUN ls -lA ${LAMBDA_TASK_ROOT}/
88
+
89
+
90
+ ### conditional section
91
+ FROM node:20-slim AS node_fastapi
92
+
93
+ ARG DEPENDENCY_GROUP
94
+ ENV PNPM_HOME="/pnpm"
95
+ ENV PATH="$PNPM_HOME:$PATH"
96
+
97
+ ADD https://github.com/AkihiroSuda/clone3-workaround/releases/download/v1.0.0/clone3-workaround.x86_64 /clone3-workaround
98
+ RUN chmod 755 /clone3-workaround
99
+ SHELL ["/clone3-workaround","/bin/sh", "-c"]
100
+ RUN corepack enable
101
+
102
+ COPY ./static /appnode
103
+ WORKDIR /appnode
104
+ # RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then echo "pnpm store path:" && pnpm store path; fi
105
+
106
+
107
+ FROM node_fastapi AS node_prod_deps
108
+
109
+ ARG DEPENDENCY_GROUP
110
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
111
+ pnpm install --prod --frozen-lockfile; else \
112
+ echo "DEPENDENCY_GROUP 1: ${DEPENDENCY_GROUP} ..."; fi
113
+ # here multiple conditions concatenated to avoid failing on check
114
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi; fi
115
+
116
+
117
+ FROM node_fastapi AS node_build
118
+
119
+ ARG DEPENDENCY_GROUP
120
+ ARG VITE__MAP_DESCRIPTION
121
+ ARG VITE__SAMGIS_SPACE
122
+ RUN echo "VITE__MAP_DESCRIPTION:" ${VITE__MAP_DESCRIPTION}
123
+ RUN echo "VITE__SAMGIS_SPACE:" ${VITE__SAMGIS_SPACE}
124
+
125
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
126
+ pnpm install --frozen-lockfile; else \
127
+ echo "DEPENDENCY_GROUP 2: ${DEPENDENCY_GROUP} ..."; fi
128
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then pnpm build; fi
129
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
130
+ pnpm tailwindcss -i /appnode/src/input.css -o /appnode/dist/output.css; fi
131
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi; fi
132
+
133
+
134
+ FROM runtime
135
+ ARG FASTAPI_STATIC
136
+ RUN mkdir ${FASTAPI_STATIC}
137
+
138
+ COPY ./machine_learning_models ${LAMBDA_TASK_ROOT}/machine_learning_models
139
+ COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
140
+ COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
dockerfiles/dockerfile-lisa-predictions ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM registry.gitlab.com/aletrn/gis-lisa-base:1.2.2
2
+
3
+ # Include global arg in this stage of the build
4
+ ARG LAMBDA_TASK_ROOT="/var/task"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
7
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
8
+ ENV IS_AWS_LAMBDA=""
9
+
10
+ # Set working directory to function root directory
11
+ WORKDIR ${LAMBDA_TASK_ROOT}
12
+
13
+ ADD https://github.com/AkihiroSuda/clone3-workaround/releases/download/v1.0.0/clone3-workaround.x86_64 /clone3-workaround
14
+ RUN chmod 755 /clone3-workaround
15
+ SHELL ["/clone3-workaround","/bin/sh", "-c"]
16
+
17
+ COPY scripts ${LAMBDA_TASK_ROOT}/scripts
18
+ COPY samgis ${LAMBDA_TASK_ROOT}/samgis
19
+ COPY wrappers ${LAMBDA_TASK_ROOT}/wrappers
20
+
21
+ RUN ls -l /usr/bin/which
22
+ RUN /usr/bin/which python
23
+ RUN python -v
24
+ RUN echo "PYTHONPATH: ${PYTHONPATH}."
25
+ RUN echo "PATH: ${PATH}."
26
+ RUN echo "LAMBDA_TASK_ROOT: ${LAMBDA_TASK_ROOT}."
27
+ RUN ls -l ${LAMBDA_TASK_ROOT}
28
+ RUN ls -ld ${LAMBDA_TASK_ROOT}
29
+ RUN ls -l ${LAMBDA_TASK_ROOT}/machine_learning_models
30
+ RUN python -c "import sys; print(sys.path)"
31
+ RUN python -c "import cv2"
32
+ RUN python -c "import fastapi"
33
+ RUN python -c "import geopandas"
34
+ RUN python -c "import loguru"
35
+ RUN python -c "import onnxruntime"
36
+ RUN python -c "import rasterio"
37
+ RUN python -c "import uvicorn"
38
+ RUN df -h
39
+ RUN ls -l ${LAMBDA_TASK_ROOT}/samgis/
40
+ RUN ls -l ${LAMBDA_TASK_ROOT}/wrappers/
41
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/
42
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/dist
43
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/node_modules
44
+
45
+ CMD ["uvicorn", "wrappers.fastapi_wrapper:app", "--host", "0.0.0.0", "--port", "7860"]
dockerfiles/dockerfile-samgis-base ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Include global ARGs at the dockerfile top
2
+ ARG ARCH="x86_64"
3
+ ARG LAMBDA_TASK_ROOT="/var/task"
4
+ ARG FASTAPI_STATIC="${LAMBDA_TASK_ROOT}/static"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ARG POETRY_NO_INTERACTION=1
7
+ ARG POETRY_VIRTUALENVS_IN_PROJECT=1
8
+ ARG POETRY_VIRTUALENVS_CREATE=1
9
+ ARG POETRY_CACHE_DIR=/tmp/poetry_cache
10
+ ARG RIE="https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie"
11
+
12
+
13
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as builder_global
14
+
15
+ ARG ARCH
16
+ ARG LAMBDA_TASK_ROOT
17
+ ARG PYTHONPATH
18
+ ARG POETRY_NO_INTERACTION
19
+ ARG POETRY_VIRTUALENVS_IN_PROJECT
20
+ ARG POETRY_VIRTUALENVS_CREATE
21
+ ARG POETRY_CACHE_DIR
22
+ ARG RIE
23
+ ARG DEPENDENCY_GROUP
24
+ ARG ZLIB1G="http://ftp.it.debian.org/debian/pool/main/z/zlib/zlib1g_1.3.dfsg-3+b1_amd64.deb"
25
+
26
+ RUN echo "ARCH: $ARCH ..."
27
+
28
+ RUN echo "ARG RIE: $RIE ..."
29
+ RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
30
+ RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
31
+ RUN test -n ${DEPENDENCY_GROUP:?}
32
+ RUN echo "python DEPENDENCY_GROUP: ${DEPENDENCY_GROUP} ..."
33
+ RUN echo "arg dep:"
34
+
35
+ # Set working directory to function root directory
36
+ WORKDIR ${LAMBDA_TASK_ROOT}
37
+ COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
38
+
39
+ RUN cat /etc/lsb-release
40
+ # avoid segment-geospatial exception caused by missing libGL.so.1 library
41
+ RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
42
+ RUN apt update && apt install -y libgl1 curl python3-pip && apt clean
43
+ COPY ./dockerfiles/apt_preferences_debian /etc/apt/preferences
44
+ COPY ./dockerfiles/debian.sources /etc/apt/sources.list.d/debian.sources
45
+ RUN apt update && apt install -t trixie zlib1g -y && apt clean
46
+ RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
47
+
48
+ RUN ls -l /etc/apt/sources* /etc/apt/preferences*
49
+ RUN curl -Lo /usr/local/bin/aws-lambda-rie ${RIE}
50
+
51
+ # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
52
+ RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
53
+
54
+ RUN which poetry && poetry --version && poetry config --list
55
+ RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
56
+ RUN echo "# poetry config --list #" && poetry config --list
57
+ RUN poetry install --with ${DEPENDENCY_GROUP} --no-root
58
+
59
+
60
+ FROM python:3.11-slim-bookworm as runtime
61
+
62
+ ARG ARCH
63
+ ARG LAMBDA_TASK_ROOT
64
+
65
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
66
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
67
+
68
+ RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
69
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
70
+ RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
71
+ RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
72
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
73
+ RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
74
+ COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
75
+
76
+ RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
77
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
78
+ RUN ls -lA ${LAMBDA_TASK_ROOT}/
79
+
80
+ COPY --from=builder_global /usr/local/bin/aws-lambda-rie /usr/local/bin/aws-lambda-rie
81
+ RUN chmod +x /usr/local/bin/aws-lambda-rie
82
+ COPY ./scripts/lambda-entrypoint.sh /lambda-entrypoint.sh
83
+ RUN chmod +x /lambda-entrypoint.sh
84
+
85
+
86
+ ### conditional section
87
+ FROM node:20-slim AS node_fastapi
88
+
89
+ ARG DEPENDENCY_GROUP
90
+ ENV PNPM_HOME="/pnpm"
91
+ ENV PATH="$PNPM_HOME:$PATH"
92
+ RUN corepack enable
93
+
94
+ COPY ./static /appnode
95
+ WORKDIR /appnode
96
+ # RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then echo "pnpm store path:" && pnpm store path; fi
97
+
98
+
99
+ FROM node_fastapi AS node_prod_deps
100
+
101
+ ARG DEPENDENCY_GROUP
102
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
103
+ pnpm install --prod --frozen-lockfile; else \
104
+ echo "DEPENDENCY_GROUP 1: ${DEPENDENCY_GROUP} ..."; fi
105
+ # here multiple conditions concatenated to avoid failing on check
106
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi; fi
107
+
108
+
109
+ FROM node_fastapi AS node_build
110
+
111
+ ARG DEPENDENCY_GROUP
112
+ ARG VITE__MAP_DESCRIPTION
113
+ ARG VITE__SAMGIS_SPACE
114
+ RUN echo "VITE__MAP_DESCRIPTION:" ${VITE__MAP_DESCRIPTION}
115
+ RUN echo "VITE__SAMGIS_SPACE:" ${VITE__SAMGIS_SPACE}
116
+
117
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
118
+ pnpm install --frozen-lockfile; else \
119
+ echo "DEPENDENCY_GROUP 2: ${DEPENDENCY_GROUP} ..."; fi
120
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then pnpm build; fi
121
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
122
+ pnpm tailwindcss -i /appnode/src/input.css -o /appnode/dist/output.css; fi
123
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi; fi
124
+
125
+
126
+ FROM runtime
127
+ ARG FASTAPI_STATIC
128
+ RUN mkdir ${FASTAPI_STATIC}
129
+
130
+ COPY ./machine_learning_models ${LAMBDA_TASK_ROOT}/machine_learning_models
131
+ COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
132
+ COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
dockerfiles/ubuntu.sources ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ deb http://it.archive.ubuntu.com/ubuntu/ jammy main universe restricted multiverse
2
+ deb-src http://it.archive.ubuntu.com/ubuntu/ jammy main universe restricted multiverse
3
+
4
+ deb http://security.ubuntu.com/ubuntu jammy-security main universe restricted multiverse
5
+ deb-src http://security.ubuntu.com/ubuntu jammy-security main universe restricted multiverse
6
+
7
+ deb http://it.archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse
8
+ deb-src http://it.archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse
9
+
10
+
11
+ deb http://it.archive.ubuntu.com/ubuntu/ noble main universe restricted multiverse
12
+ deb-src http://it.archive.ubuntu.com/ubuntu/ noble main universe restricted multiverse
13
+
14
+ deb http://security.ubuntu.com/ubuntu noble-security main universe restricted multiverse
15
+ deb-src http://security.ubuntu.com/ubuntu noble-security main universe restricted multiverse
16
+
17
+ deb http://it.archive.ubuntu.com/ubuntu/ noble-updates main universe restricted multiverse
18
+ deb-src http://it.archive.ubuntu.com/ubuntu/ noble-updates main universe restricted multiverse
docs/.gitignore ADDED
File without changes
docs/Changelog.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ ## Version 1.2.2
4
+ - update dependencies version
5
+
6
+ ## Version 1.2.1
7
+ - update dependencies version
8
+
9
+ ## Version 1.2.0
10
+ - code refactor to separate core functionality (instance segmentation) from other code
11
+ - updated test coverage
12
+
13
+ ## Version 1.1.0
14
+ - Added this changelog
15
+ - specific backend branch code uses terrain providers like nextzen and MapBox Terrain-RGB v1
16
+ - update test coverage
17
+ - update python dependencies versions
18
+ - update node dependencies versions
19
+
20
+ ## Version 1.0.2
21
+ - HuggingFace frontend demo: update the navbar url to SamGIS docs
22
+ - add two openapi docs builder scripts
23
+ - update samgis version within docs
24
+ - remove unused package.json
25
+
26
+ ## Version 1.0.1
27
+ - fixed zlib1g security vulnerability in python:3.11-slim-bookworm docker image, see https://security-tracker.debian.org/tracker/CVE-2023-45853
28
+
29
+ ## Version 1.0.0
30
+ First release:
31
+ - user onboarding tour with driver.js
32
+ - code decoupling between the AWS lambda wrapper and the backend...
33
+ - ...now also deployed on this HuggingSpace space demo (here some explanation about adding a SPA vuejs frontend)
34
+ - request input validation using Pydantic
35
+ - support for array prompts (both rectangle and point types)
36
+ - tiles download/merge/crop steps uses contextily by geopandas
37
+ - CSS frontend style with Tailwind
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/_static/.gitignore ADDED
File without changes
docs/brief_project_presentation.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # About this project
2
+
3
+ SamGIS is an attempt to perform [machine learning](https://developer.ibm.com/learningpaths/get-started-artificial-intelligence/ai-basics/ai-beginners-guide) [instance segmentation](https://en.wikipedia.org/wiki/Image_segmentation) on [geospatial data](https://en.wikipedia.org/wiki/Geographic_data_and_information) even without the use of dedicated graphics cards.
4
+ The user interact on a [leaflet](https://leafletjs.com) webmap choosing areas to recognize and a backend responds with a [geojson](https://it.wikipedia.org/wiki/GeoJSON) containing one or more recognized polygons within the initial webmap.
5
+
6
+ The backend perform machine learning inference using a [Segment Anything](https://segment-anything.com) model and [ONNXRuntime](https://onnxruntime.ai) as runtime.
7
+
8
+ Check about implementation details on my [blog](https://trinca.tornidor.com/projects/samgis-segment-anything-applied-to-GIS).
9
+
10
+ # Self-hosted demo
11
+
12
+ You can visit my self-hosted demo [here](https://ml-trinca.tornidor.com).
13
+ Since this demo uses a python container backend hosted on my AWS account I keep it under authentication to prevent abuses.
14
+ [Here](https://docs.ml-trinca.tornidor.com/openapi) the OpenAPI swagger documentation.
15
+
16
+ # HuggingFace Space demo
17
+
18
+ I added also a demo on this [HuggingFace Space](https://huggingface.co/spaces/aletrn/samgis). It's
19
+ possible to find [here](https://aletrn-samgis.hf.space/) the direct space url and
20
+ [here](https://aletrn-samgis.hf.space/docs#/) the OpenAPI swagger documentation.
docs/conf.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-now, alessandro trinca tornidor'
13
+ author = 'alessandro trinca tornidor'
14
+ release = '1.2.2'
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_typehints',
25
+ 'sphinxcontrib.openapi',
26
+ 'myst_parser',
27
+ # 'sphinx_autodoc_defaultargs'
28
+ ]
29
+ # Napoleon settings
30
+ napoleon_google_docstring = True
31
+
32
+ #
33
+ typehints_defaults = "comma"
34
+
35
+ templates_path = ['_templates']
36
+ exclude_patterns = [
37
+ '_build', 'Thumbs.db', '.DS_Store', 'build/*', 'machine_learning_models', 'machine_learning_models/*'
38
+ ]
39
+
40
+ source_suffix = {
41
+ '.rst': 'restructuredtext',
42
+ '.txt': 'restructuredtext',
43
+ '.md': 'markdown',
44
+ }
45
+
46
+ # default args values
47
+ rst_prolog = """
48
+ .. |default| raw:: html
49
+
50
+ <div class="default-value-section">""" + \
51
+ ' <span class="default-value-label">Default:</span>'
52
+
53
+ # -- Options for HTML output -------------------------------------------------
54
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
55
+
56
+ html_theme = 'alabaster'
57
+ html_sidebars = {
58
+ '**': [
59
+ 'about.html',
60
+ 'navigation.html',
61
+ 'relations.html',
62
+ 'searchbox.html',
63
+ 'donate.html',
64
+ ]
65
+ }
66
+ html_static_path = ['_static']
67
+ html_theme_options = {
68
+ "description": "Segment Anything applied to geodata",
69
+ "fixed_sidebar": True,
70
+ "sidebar_collapse": False,
71
+ 'globaltoc_collapse': False
72
+ }
docs/external_links.rst ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ External links
2
+ ==============
3
+
4
+ .. include:: external_links_md.md
5
+ :parser: myst_parser.sphinx_
docs/external_links_md.md ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ - My [SamGIS demo website](https://ml-trinca.tornidor.com)
2
+ - My [personal website](https://trinca.tornidor.com)
docs/index.rst ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ .. include:: brief_project_presentation.md
10
+ :parser: myst_parser.sphinx_
11
+ .. include:: Changelog.md
12
+ :parser: myst_parser.sphinx_
13
+
14
+ .. toctree::
15
+ :maxdepth: 2
16
+ :hidden:
17
+
18
+ modules
19
+ other_resources
20
+
21
+
22
+ Indices and tables documentation
23
+ ================================
24
+
25
+ * :ref:`genindex`
26
+ * :ref:`modindex`
27
+ * :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
+ samgis
2
+ ======
3
+
4
+ .. toctree::
5
+ :maxdepth: 4
6
+
7
+ samgis
docs/openapi.rst ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ OpenAPI Specs
2
+ =============
3
+
4
+ This API is under oauth authentication for the self-hosted version (now it works as a lambda AWS).
5
+ Contact the maintainer/administrator for more info about this.
6
+
7
+ .. openapi:: specs/openapi.yaml
8
+ :paths:
9
+ /lambda-ml-fastsam-api
10
+ :examples:
11
+ :encoding: utf-8
docs/other_resources.rst ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Other resources
2
+ ===============
3
+
4
+ .. toctree::
5
+ :maxdepth: 4
6
+
7
+ external_links
8
+
9
+ openapi
docs/samgis.io.rst ADDED
@@ -0,0 +1,53 @@