alessandro trinca tornidor commited on
Commit
0831531
·
1 Parent(s): 219079c

doc: update changelog, openapi specs, conf and content documentation

Browse files
docs/Changelog.md CHANGED
@@ -1,6 +1,34 @@
1
  # Changelog
2
 
3
- ## Version 1.11.9 - 1.11.19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  Bugfix only
6
 
 
1
  # Changelog
2
 
3
+ ## Version 1.12.1
4
+
5
+ - ci: update requirements.txt with the updated, installed dependency versions
6
+ - ci: revert to dockerfiles based on python debian/trixie image
7
+ - ci: remove old dockerfiles for AWS, add alpine-linux base dockerfile
8
+ - ci: update base dockerfile version to 1.12.1
9
+ - doc: update changelog, openapi specs, conf and content documentation
10
+ - chore: update samgis-web==1.3.1, pytest and docs dependencies
11
+ - chore: rollback to onnxruntime as direct dependency
12
+
13
+ ## Version 1.12.0 (Not released)
14
+
15
+ - test: refactored test execution
16
+ - test: avoid using assert construct
17
+ - ci: now dockerfiles are based on alpine linux
18
+ - ci: move onnxruntime dependency requirement to a optional group, preparing alpine linux docker image
19
+ - feat: add a python script (scripts/client_health.py) to perform the health check avoiding curl use
20
+ - chore: refactor pyproject.toml, max python version is 3.13
21
+
22
+ ## Version 1.11.14 - 1.11.19
23
+
24
+ Bugfix only
25
+
26
+ ## Version 1.11.13
27
+
28
+ - test: fix test case condition about the number of shapely geometries created from the samgis post
29
+ - feat: remove ButtonMapSendRequest used in desktop mode to avoid wrong references on driver.js tour
30
+
31
+ ## Version 1.11.9 - 1.11.12
32
 
33
  Bugfix only
34
 
docs/conf.py CHANGED
@@ -5,27 +5,34 @@
5
 
6
  # -- Project information -----------------------------------------------------
7
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
- import os
9
- import sys
10
  import tomllib
 
11
 
12
 
13
  project = 'SamGIS'
14
 
15
  # -- General configuration ---------------------------------------------------
16
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
17
- sys.path.insert(0, os.path.abspath('..'))
18
 
19
- # Pull general sphinx project info from pyproject.toml
20
- # Modified from https://stackoverflow.com/a/75396624/1304076
21
- with open("../pyproject.toml", "rb") as f:
22
  toml = tomllib.load(f)
23
 
24
- pyproject = toml["tool"]["poetry"]
25
  version = pyproject["version"]
26
  release = version
27
- authors_list = [author for author in pyproject["authors"]]
28
- author = ", ".join(authors_list) if len(authors_list) > 1 else authors_list[0]
 
 
 
 
 
 
 
 
 
 
29
  copyright = f"2023-now {author}"
30
 
31
  extensions = [
@@ -39,11 +46,13 @@ extensions = [
39
  ]
40
  # Napoleon settings
41
  napoleon_google_docstring = True
 
42
  typehints_defaults = "comma"
43
 
44
  templates_path = ['_templates']
45
  exclude_patterns = [
46
- '_build', 'Thumbs.db', '.DS_Store', 'build/*', 'machine_learning_models', 'machine_learning_models/*', "sam-quantized/machine_learning_models", "sam-quantized/machine_learning_models/*"
 
47
  ]
48
 
49
  source_suffix = {
 
5
 
6
  # -- Project information -----------------------------------------------------
7
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
 
 
8
  import tomllib
9
+ import pathlib
10
 
11
 
12
  project = 'SamGIS'
13
 
14
  # -- General configuration ---------------------------------------------------
15
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
 
16
 
17
+ toml_path = pathlib.Path(__file__).parent.parent / 'pyproject.toml'
18
+ with open(toml_path, "rb") as f:
 
19
  toml = tomllib.load(f)
20
 
21
+ pyproject = toml["project"]
22
  version = pyproject["version"]
23
  release = version
24
+ authors_list = [a for a in pyproject["authors"]]
25
+ author = ""
26
+ for author_element in authors_list:
27
+ if len(author) > 1:
28
+ author += ", "
29
+ if isinstance(author_element, str):
30
+ author += f"{author_element}"
31
+ else:
32
+ name = author_element.get("name")
33
+ email = author_element.get("email")
34
+ author += f"{name} <{email}>"
35
+
36
  copyright = f"2023-now {author}"
37
 
38
  extensions = [
 
46
  ]
47
  # Napoleon settings
48
  napoleon_google_docstring = True
49
+ # sphinx_autodoc_typehints settings
50
  typehints_defaults = "comma"
51
 
52
  templates_path = ['_templates']
53
  exclude_patterns = [
54
+ '_build', 'Thumbs.db', '.DS_Store', 'build/*', 'machine_learning_models', 'machine_learning_models/*',
55
+ "sam-quantized/machine_learning_models", "sam-quantized/machine_learning_models/*"
56
  ]
57
 
58
  source_suffix = {
docs/external_links_md.md CHANGED
@@ -1,4 +1,4 @@
1
- - My [SamGIS demo website](https://ml-trinca.tornidor.com)
2
- - My [HuggingFace SamGIS demo](https://huggingface.co/spaces/aletrn/samgis)
3
- - My [HuggingFace SamGIS - LISA on CUDA demo](https://huggingface.co/spaces/aletrn/samgis-lisa-on-cuda)
4
  - My [personal website](https://trinca.tornidor.com)
 
1
+ - My [HuggingFace SamGIS direct link space](https://aletrn-samgis.hf.space/)
2
+ - My [HuggingFace SamGIS space](https://huggingface.co/spaces/aletrn/samgis)
3
+ - My [HuggingFace SamGIS space - LISA on CUDA demo](https://huggingface.co/spaces/aletrn/samgis-lisa-on-cuda)
4
  - My [personal website](https://trinca.tornidor.com)
docs/openapi.rst CHANGED
@@ -1,11 +1,10 @@
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
 
1
  OpenAPI Specs
2
  =============
3
 
4
+ The OpenAPI specifications for the SamGIS app.
 
5
 
6
  .. openapi:: specs/openapi.yaml
7
  :paths:
8
+ /infer_samgis
9
  :examples:
10
  :encoding: utf-8
docs/specs/openapi.yaml CHANGED
@@ -4,7 +4,8 @@ info:
4
  description: |-
5
  Segment Anything applied to GIS.
6
  Some useful links:
7
- - [SamGIS online demo](https://ml-trinca.tornidor.com)
 
8
  - [SamGIS documentation](https://docs.ml-trinca.tornidor.com)
9
  - [My blog](https://trinca.tornidor.com)
10
  contact:
@@ -13,7 +14,7 @@ info:
13
  license:
14
  name: MIT License
15
  url: https://opensource.org/license/mit/
16
- version: "1.2.0"
17
  servers:
18
  - url: https://localhost:8000/
19
  tags:
@@ -33,13 +34,21 @@ tags:
33
  externalDocs:
34
  url: https://it.wikipedia.org/wiki/Geographic_information_system
35
  paths:
36
- /lambda-ml-fastsam-api:
 
 
 
 
 
 
 
 
 
 
37
  post:
38
- tags:
39
- - samgis
40
- summary: Make GIS ML predictions
41
  requestBody:
42
- description: input request for GIS ML predictions
43
  content:
44
  application/json:
45
  schema:
@@ -47,131 +56,169 @@ paths:
47
  required: true
48
  responses:
49
  '200':
50
- description: successful operation
51
  content:
52
  application/json:
53
- schema:
54
- $ref: '#/components/schemas/ApiResponseBodySuccess'
55
- '400':
56
- description: Bad request
57
- content:
58
- application/json:
59
- schema:
60
- $ref: '#/components/schemas/ApiResponseBodyFailure'
61
  '422':
62
- description: Unprocessable Entity
63
  content:
64
  application/json:
65
  schema:
66
- $ref: '#/components/schemas/ApiResponseBodyFailure'
67
- '500':
68
- description: Internal Server Error
 
 
 
 
 
69
  content:
70
  application/json:
71
- schema:
72
- $ref: '#/components/schemas/ApiResponseBodyFailure'
73
  components:
74
  schemas:
75
  ApiRequestBody:
76
- required:
77
- - bbox
78
- - prompt
79
- - zoom
80
- type: object
81
  properties:
 
 
 
 
82
  bbox:
83
- type: object
84
- properties:
85
- ne:
86
- type: object
87
- properties:
88
- lat:
89
- type: number
90
- example: 46.180194387028855
91
- lng:
92
- type: number
93
- example: 9.426848938165525
94
- sw:
95
- type: object
96
- properties:
97
- lat:
98
- type: number
99
- example: 46.17511301243843
100
- lng:
101
- type: number
102
- example: 9.415862610040527
103
  prompt:
104
- type: array
105
  items:
106
- type: object
107
- properties:
108
- id:
109
- type: integer
110
- format: int32
111
- example: 448
112
- type:
113
- type: string
114
- example: point
115
- data:
116
- type: object
117
- properties:
118
- lat:
119
- type: number
120
- example: 46.176256754439535
121
- lng:
122
- type: number
123
- example: 9.421805260519237
124
- label:
125
- type: integer
126
- format: int32
127
- example: 1
128
  zoom:
129
- type: integer
130
- format: int32
131
- example: 17
 
132
  source_type:
133
  type: string
134
- example: OpenStreetMap
135
- ApiResponseBodyFailure:
 
 
 
 
136
  type: object
 
 
 
 
 
 
 
137
  properties:
138
- duration_run:
139
- type: number
140
- example: 0.063
141
- message:
142
- type: string
143
- example: Bad Request
144
- request_id:
145
- type: string
146
- example: test_invoke_id
147
- ApiResponseBodySuccess:
148
  type: object
 
 
149
  properties:
150
- n_predictions:
151
- type: integer
152
- format: int32
153
- example: 1
154
- geojson:
155
- type: string
156
- example: '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"raster_val":255.0},"geometry":{"type":"Polygon","coordinates":[[[9.415857195854185,46.17510931936532],[9.426854252815245,46.17510931936532],[9.426854252815245,46.18019812286394],[9.415857195854185,46.18019812286394],[9.415857195854185,46.17510931936532]]]},"id":0},{"type":"Feature","properties":{"raster_val":0.0},"geometry":{"type":"Polygon","coordinates":[[[9.143199920654297,46.30271068141335],[9.495105743408203,46.30271068141335],[9.495105743408203,46.13999860748669],[9.143199920654297,46.13999860748669],[9.143199920654297,46.30271068141335]],[[9.426854252815245,46.17510931936532],[9.426854252815245,46.18019812286394],[9.415857195854185,46.18019812286394],[9.415857195854185,46.17510931936532],[9.426854252815245,46.17510931936532]]]},"id":1}]}'
157
- n_shapes_geojson:
158
- type: integer
159
- format: int32
160
- example: 5
161
- duration_run:
162
  type: number
163
- example: 6.703
164
- message:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  type: string
166
- example: ok
167
- request_id:
168
  type: string
169
- example: test_invoke_id
170
- securitySchemes:
171
- samgis_auth:
172
- type: oauth2
173
- flows:
174
- implicit:
175
- authorizationUrl: https://example.auth0.com/oauth/authorize
176
- scopes:
177
- write:lambda-ml-fastsam-api: Make GIS ML predictions
 
 
 
 
4
  description: |-
5
  Segment Anything applied to GIS.
6
  Some useful links:
7
+ - [SamGIS HuggingFace space direct link](https://huggingface.co/spaces/aletrn/samgis)
8
+ - [SamGIS HuggingFace space](https://huggingface.co/spaces/aletrn/samgis)
9
  - [SamGIS documentation](https://docs.ml-trinca.tornidor.com)
10
  - [My blog](https://trinca.tornidor.com)
11
  contact:
 
14
  license:
15
  name: MIT License
16
  url: https://opensource.org/license/mit/
17
+ version: "1.3.1"
18
  servers:
19
  - url: https://localhost:8000/
20
  tags:
 
34
  externalDocs:
35
  url: https://it.wikipedia.org/wiki/Geographic_information_system
36
  paths:
37
+ /health:
38
+ get:
39
+ summary: Health
40
+ operationId: health_health_get
41
+ responses:
42
+ '200':
43
+ description: Successful Response
44
+ content:
45
+ application/json:
46
+ schema: {}
47
+ /infer_samgis:
48
  post:
49
+ summary: Infer Samgis
50
+ operationId: infer_samgis_infer_samgis_post
 
51
  requestBody:
 
52
  content:
53
  application/json:
54
  schema:
 
56
  required: true
57
  responses:
58
  '200':
59
+ description: Successful Response
60
  content:
61
  application/json:
62
+ schema: {}
 
 
 
 
 
 
 
63
  '422':
64
+ description: Validation Error
65
  content:
66
  application/json:
67
  schema:
68
+ $ref: '#/components/schemas/HTTPValidationError'
69
+ /:
70
+ get:
71
+ summary: Index
72
+ operationId: index__get
73
+ responses:
74
+ '200':
75
+ description: Successful Response
76
  content:
77
  application/json:
78
+ schema: {}
 
79
  components:
80
  schemas:
81
  ApiRequestBody:
 
 
 
 
 
82
  properties:
83
+ id:
84
+ type: string
85
+ title: Id
86
+ default: ''
87
  bbox:
88
+ $ref: '#/components/schemas/RawBBox'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  prompt:
 
90
  items:
91
+ anyOf:
92
+ - $ref: '#/components/schemas/RawPromptPoint'
93
+ - $ref: '#/components/schemas/RawPromptRectangle'
94
+ type: array
95
+ title: Prompt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  zoom:
97
+ anyOf:
98
+ - type: integer
99
+ - type: number
100
+ title: Zoom
101
  source_type:
102
  type: string
103
+ title: Source Type
104
+ default: OpenStreetMap.Mapnik
105
+ debug:
106
+ type: boolean
107
+ title: Debug
108
+ default: false
109
  type: object
110
+ required:
111
+ - bbox
112
+ - prompt
113
+ - zoom
114
+ title: ApiRequestBody
115
+ description: Input request validator type (not yet parsed)
116
+ HTTPValidationError:
117
  properties:
118
+ detail:
119
+ items:
120
+ $ref: '#/components/schemas/ValidationError'
121
+ type: array
122
+ title: Detail
 
 
 
 
 
123
  type: object
124
+ title: HTTPValidationError
125
+ LatLngDict:
126
  properties:
127
+ lat:
 
 
 
 
 
 
 
 
 
 
 
128
  type: number
129
+ title: Lat
130
+ lng:
131
+ type: number
132
+ title: Lng
133
+ type: object
134
+ required:
135
+ - lat
136
+ - lng
137
+ title: LatLngDict
138
+ description: Generic geographic latitude-longitude type
139
+ PromptLabel:
140
+ type: integer
141
+ enum:
142
+ - 0
143
+ - 1
144
+ title: PromptLabel
145
+ description: Valid prompt label type
146
+ PromptPointType:
147
+ type: string
148
+ enum:
149
+ - point
150
+ title: PromptPointType
151
+ description: 'Segment Anything: validation point prompt type'
152
+ PromptRectangleType:
153
+ type: string
154
+ enum:
155
+ - rectangle
156
+ title: PromptRectangleType
157
+ description: 'Segment Anything: validation rectangle prompt type'
158
+ RawBBox:
159
+ properties:
160
+ ne:
161
+ $ref: '#/components/schemas/LatLngDict'
162
+ sw:
163
+ $ref: '#/components/schemas/LatLngDict'
164
+ type: object
165
+ required:
166
+ - ne
167
+ - sw
168
+ title: RawBBox
169
+ description: Input lambda bbox request type (not yet parsed)
170
+ RawPromptPoint:
171
+ properties:
172
+ type:
173
+ $ref: '#/components/schemas/PromptPointType'
174
+ data:
175
+ $ref: '#/components/schemas/LatLngDict'
176
+ label:
177
+ $ref: '#/components/schemas/PromptLabel'
178
+ type: object
179
+ required:
180
+ - type
181
+ - data
182
+ - label
183
+ title: RawPromptPoint
184
+ description: Input lambda prompt request of type 'PromptPointType' - point (not
185
+ yet parsed)
186
+ RawPromptRectangle:
187
+ properties:
188
+ type:
189
+ $ref: '#/components/schemas/PromptRectangleType'
190
+ data:
191
+ $ref: '#/components/schemas/RawBBox'
192
+ type: object
193
+ required:
194
+ - type
195
+ - data
196
+ title: RawPromptRectangle
197
+ description: Input lambda prompt request of type 'PromptRectangleType' - rectangle
198
+ (not yet parsed)
199
+ ValidationError:
200
+ properties:
201
+ loc:
202
+ items:
203
+ anyOf:
204
+ - type: string
205
+ - type: integer
206
+ type: array
207
+ title: Location
208
+ msg:
209
  type: string
210
+ title: Message
211
+ type:
212
  type: string
213
+ title: Error Type
214
+ input:
215
+ title: Input
216
+ ctx:
217
+ type: object
218
+ title: Context
219
+ type: object
220
+ required:
221
+ - loc
222
+ - msg
223
+ - type
224
+ title: ValidationError
scripts/extract-openapi-fastapi.py CHANGED
@@ -3,18 +3,20 @@ import argparse
3
  import json
4
  import logging
5
  import sys
 
6
 
7
  import yaml
8
  from uvicorn.importer import import_from_string
9
 
10
- from app import project_root_folder
11
 
12
 
13
  if __name__ == "__main__": # pragma: no cover
14
  # python scripts/extract-openapi.py fastapi_wrapper:app --app-dir wrappers --out docs/specs/openapi_new.yaml
15
  parser = argparse.ArgumentParser(prog="extract-openapi-fastapi.py")
16
- parser.add_argument("app", help='App import string. Eg. "main:app"', default="main:app")
17
- parser.add_argument("--app-dir", help="Directory containing the app", default=None)
 
18
  args = parser.parse_args()
19
 
20
  if args.app_dir is not None:
 
3
  import json
4
  import logging
5
  import sys
6
+ from pathlib import Path
7
 
8
  import yaml
9
  from uvicorn.importer import import_from_string
10
 
11
+ # from app import project_root_folder
12
 
13
 
14
  if __name__ == "__main__": # pragma: no cover
15
  # python scripts/extract-openapi.py fastapi_wrapper:app --app-dir wrappers --out docs/specs/openapi_new.yaml
16
  parser = argparse.ArgumentParser(prog="extract-openapi-fastapi.py")
17
+ parser.add_argument("app", help='App import string. Eg. "app:app"', default="app:app")
18
+ project_root_folder = Path(__file__).parent.parent
19
+ parser.add_argument("--app-dir", help="Directory containing the app", default=str(project_root_folder))
20
  args = parser.parse_args()
21
 
22
  if args.app_dir is not None: