From 200416e98e0d21c5b01ac82d48def17f1079b12f Mon Sep 17 00:00:00 2001 From: Quarto GHA Workflow Runner Date: Thu, 18 Jan 2024 14:53:46 +0000 Subject: [PATCH] Built site for gh-pages --- .nojekyll | 2 +- book/developer_notes.html | 28 +++++++++++++++++++++++++--- index.html | 4 ++-- search.json | 20 +++++++++++++++++--- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/.nojekyll b/.nojekyll index 0239075..4c76d49 100644 --- a/.nojekyll +++ b/.nojekyll @@ -1 +1 @@ -11886b27 \ No newline at end of file +7722dd69 \ No newline at end of file diff --git a/book/developer_notes.html b/book/developer_notes.html index 3f6cce3..70f23aa 100644 --- a/book/developer_notes.html +++ b/book/developer_notes.html @@ -307,7 +307,9 @@

Table of contents

@@ -359,9 +361,29 @@

}, ... } +

The function demoland_engine.api.scenario_calc() obeys this schema, and both the FastAPI and the Azure Functions apps simply wrap this function.

-
-

5.2 Azure Functions

+
+

5.2 FastAPI, local

+

One way to run the API is to run it locally or over Docker. To do this, there is a FastAPI app located at api/main.py. First make sure you have the optional dependencies for the FastAPI app installed. Go to the top-level directory of the repo and run

+
python -m pip install .[api]
+

The [api] instructs pip to install the optional dependencies, which can be seen in pyproject.toml.

+

Then, again from the top-level directory, run:

+
uvicorn main:app --app-dir api --port 5178
+

You should now be able to test the API using:

+
curl http://localhost:5178/api/scenario -X POST -d "{\"scenario_json\": {}, \"model_identifier\": \"tyne_and_wear\"}" -v -H 'Content-Type: application/json'
+

(Note that the Content-Type header is mandatory, otherwise FastAPI doesn’t accept the input.)

+
+
+

5.3 FastAPI, over Docker

+

Dockerfile.api provides the specification for running the FastAPI app over Docker. Simply do:

+
docker build . -f Dockerfile.api -t demoland-api
+docker run -it demoland-api
+

The Dockerfile is configured to expose the API on port 80 (which is the default port for HTTP), so you can omit the port number when testing:

+
curl http://localhost/api/scenario -X POST -d "{\"scenario_json\": {}, \"model_identifier\": \"tyne_and_wear\"}" -v -H 'Content-Type: application/json'
+
+
+

5.4 Azure Functions

The code required to deploy this can be found on the azure-functions branch of the engine repository, specifically the function_app.py file.

To deploy a new version of the Azure function, make sure you are a member of the “Land Use Indicator” Azure subscription (the subscription ID is 86307bb0-6d16-4077-b1f7-939370d5289a). If you are not, get Dani to add you.

Then, follow these instructions:

diff --git a/index.html b/index.html index 7fb51d0..3b0fd0a 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - + Land Use Demonstrator