aletrn commited on
Commit
0aed5b2
1 Parent(s): 56998a8

[doc] add frontend README.md, update python README.md

Browse files
Files changed (2) hide show
  1. README.md +25 -5
  2. static/README.md +17 -27
README.md CHANGED
@@ -8,6 +8,10 @@ pinned: false
8
  license: mit
9
  ---
10
 
 
 
 
 
11
  ## Segment Anything models
12
 
13
  It's possible to prepare the model files using <https://github.com/vietanhdev/samexporter/> or using the ones
@@ -49,7 +53,7 @@ Test it with curl using a json payload:
49
 
50
  ```bash
51
  URL=http://localhost:7860/infer_samgis
52
- curl -d@./events/payload_point_eolie.json -H 'accept: application/json' ${URL}
53
  ```
54
 
55
  or better visiting the swagger page on <http://localhost:7860/docs>
@@ -80,7 +84,7 @@ 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
@@ -88,10 +92,26 @@ curl -d@./events/payload_point_eolie.json -H 'accept: application/json' ${URL}
88
  Login on aws ECR with the correct aws profile (change the example `example-docker-namespace/` repository url with the one from
89
  the [ECR push command instructions page](https://eu-west-1.console.aws.amazon.com/ecr/repositories/)).
90
 
91
- ### Dependencies installation and local tests
 
 
 
 
 
 
 
 
92
 
93
- The docker build process needs only the base dependency group plus the `aws_lambda` or `fastapi` optional one.
94
- Install also the `test` and/or `docs` groups if needed.
 
 
 
 
 
 
 
 
95
 
96
  ### Tests
97
 
 
8
  license: mit
9
  ---
10
 
11
+ # About this README
12
+
13
+ I tested these instructions on MacOS, but should work on linux as well.
14
+
15
  ## Segment Anything models
16
 
17
  It's possible to prepare the model files using <https://github.com/vietanhdev/samexporter/> or using the ones
 
53
 
54
  ```bash
55
  URL=http://localhost:7860/infer_samgis
56
+ curl -d@./events/payload_point_eolie.json -H 'content-type: application/json' ${URL}
57
  ```
58
 
59
  or better visiting the swagger page on <http://localhost:7860/docs>
 
84
 
85
  ```bash
86
  URL=http://localhost:8080/2015-03-31/functions/function/invocations
87
+ curl -d@./events/payload_point_eolie.json -H 'content-type: application/json' ${URL}
88
  ```
89
 
90
  ### Publish the aws lambda docker image
 
92
  Login on aws ECR with the correct aws profile (change the example `example-docker-namespace/` repository url with the one from
93
  the [ECR push command instructions page](https://eu-west-1.console.aws.amazon.com/ecr/repositories/)).
94
 
95
+ ### Dependencies installation, local execution and local tests
96
+
97
+ The docker build process needs only the base dependency group plus the `aws_lambda` or `fastapi` optional one (right now I use almost only the `fastapi` version). Install also the `test` and/or `docs` groups if needed.
98
+
99
+ #### Local execution
100
+
101
+ If you need to use the SPA frontend follow the frontend instruction [here](/static/README.md).
102
+
103
+ You can run the local server using this python command:
104
 
105
+ ```python
106
+ uvicorn wrappers.fastapi_wrapper:app --host 127.0.0.1 --port 7860
107
+ ```
108
+
109
+ Change the port and/or the host ip if needed. Test it with curl using a json payload:
110
+
111
+ ```bash
112
+ URL=http://localhost:7860/infer_samgis
113
+ curl -d@./events/payload_point_eolie.json -H 'content-type: application/json' ${URL}
114
+ ```
115
 
116
  ### Tests
117
 
static/README.md CHANGED
@@ -1,36 +1,26 @@
1
- # ml-tornidor
2
 
3
- ## Local development
4
 
5
- Since I use Cloudflare pages as hosting for this project there are some required steps to do before it's possible to start a local development environment. This project needs to wrap the node commands with the `npx wrangler [...]` utility to emulate a Cloudflare Worker function. Because this worker function is under auth which use some env variables I to write these env variables inline. Every time I changed or added needed some variables I also needed to update the `npx wrangler` command. To avoid this I prepared a js script, executed by [Deno](https://deno.land/), that read the env variables from the `.env` file composing the command:
6
 
7
- 1. prepare the .env file copying the template.env file
8
- 2. run the local environment using the command `pnpm dev` or `deno run -A runner.js`
9
 
10
- In case of new or updated packages Deno installs the dependencies at the first execution. Do it with a execution without the `npx wrangler` wrapper:
11
 
12
- ```bash
13
- deno run -A --node-modules-dir npm:vite
14
- ```
15
-
16
- In case of problem:
17
-
18
- 1. try executing again the command `deno run -A --node-modules-dir npm:vite`
19
-
20
- If this don't solve the problems try to
21
-
22
- 1. delete the node_modules folder
23
- 2. reinstall the npm packages with `pnpm install`
24
- 3. Run again the local development server, this time with the standard command
25
-
26
- Before to commit try also to build using
27
-
28
- ```bash
29
  pnpm build
 
30
  ```
31
 
32
- Then run the preview (change the example variables):
33
 
34
- ```bash
35
- npx wrangler pages dev --binding VITE_AUTH0_DOMAIN="example-auth0.eu.auth0.com" API_URL="https://example-aws.execute-api.eu-west-1.amazonaws.com/localhost/lambda-ml-fastsam-api" VITE_AUTH0_AUDIENCE="http://localhost-ml-lambda/" API_DOMAIN=example-aws.execute-api.eu-west-1.amazonaws.com CORS_ALLOWED_DOMAIN=http://localhost:8788 VITE_SATELLITE_NAME="tile-provider.image-type" -- pnpm preview
36
- ```
 
 
 
 
1
+ # SamGIS frontend
2
 
3
+ This is the [SPA](https://wikipedia.org/wiki/Single-page_application) frontend for [SamGIS](https://github.com/trincadev/samgis-be).
4
 
5
+ ## Requirements
6
 
7
+ 1. a recent nodejs version (I'm using nodejs 20 now)
8
+ 2. `pnpm`
9
 
10
+ Then execute from this folder (`static/`):
11
 
12
+ ```nodejs
13
+ npm install -g pnpm
14
+ pnpm install
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  pnpm build
16
+ pnpm tailwindcss -i $PWD/src/input.css -o $PWD/dist/output.css
17
  ```
18
 
19
+ ## Dependencies
20
 
21
+ - [driver.js](https://github.com/trincadev/driver.js/)
22
+ - [leaflet](https://leafletjs.com/)
23
+ - [tailwind](https://tailwindcss.com/)
24
+ - [typescript](https://www.typescriptlang.org/)
25
+ - [vuejs](https://vuejs.org/)
26
+ - [vite](https://vitejs.dev/)