Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #51: implement pipeline switching in back end #55

Merged
merged 52 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f31854a
fixes #51: connecting to swin model
Feb 7, 2024
fee54a5
fixes #51: incorporate pipelines_endpoints in CACHE
Feb 8, 2024
4f14091
fixes #51: add request_factory function to bring a standard to call m…
Feb 8, 2024
d76412e
fixes #51: add models_Utils.py
Feb 9, 2024
af23ffa
fixes #51: Update model_utilitary_functions import
Feb 12, 2024
10be9d7
fixes #51: update result parsing and add default pipeline
Feb 12, 2024
18d604a
fixes #51: update inference_request to call swin in loop
Feb 13, 2024
1864483
fixes #51: Add documentation to image_slicing and swin_result_parser …
Feb 13, 2024
188b5cd
fixes #51: Standardize headers with azureml-model-deployment being ma…
Feb 14, 2024
7ee4204
fixes #51: updates devcontainer
Feb 14, 2024
7b6d470
fixes #51: Refactor swin_result_parser function to add all result to …
Feb 14, 2024
8975122
fixes #51: Add workflow.yml with following jobs: standard, lint test,…
Feb 14, 2024
f5013ec
fixes #51: Refactor inference result processing and add test file for…
Feb 16, 2024
82c2058
fixes #51: Update doc to include input and output of inference request
Feb 20, 2024
a92c1b7
fixes #51: add function to retrieve pipeline info from blob storage
Feb 26, 2024
0bb2e2b
fixes #51: correct lint error
Feb 26, 2024
d1e4268
fixes #51: Add manuel test case in testing.md
Feb 27, 2024
ef931b4
fixes #51: Add test get pipeline info unsuccessful
Feb 28, 2024
f33b541
fixes #51: Add get pipeline info successful test
Feb 28, 2024
3e41fb5
fixes #51: Update sequence diagram to reflect change in code
Feb 28, 2024
1699d9c
fixes #51: Add inferences request automatic test
Feb 29, 2024
e581703
fixes #51: Add documentation to pipeline function
Mar 1, 2024
e340108
fixes #51: Add inference request test
Mar 1, 2024
471bcc5
fixes #51: change from loop to asyncio.run
Mar 1, 2024
69006ee
fixes #51: implement Ricky reviews
Mar 6, 2024
8d89da6
fixes #51: implement William's reviews
Mar 6, 2024
c0a097f
fixes #51: raise ConnectionStringError in insert_new_version_pipeline
Mar 6, 2024
fb65e76
Update .github/workflows/workflows.yml
Mar 7, 2024
9ec9d76
fixes #51: removes run_test.py
Mar 7, 2024
1289291
fixes ##51: add print statement to log the result from models
Mar 7, 2024
65b2268
fixes #51: change to pipeline insertion script
Mar 8, 2024
c9b47cf
fixes #51: add explanation for `box` value
Mar 14, 2024
3783d9c
fixes #51: update size length
Mar 25, 2024
58b4d44
fixes #51: Add get_blob_client
Mar 26, 2024
50b2e1b
issue #51: Implement Ricky's review
Apr 3, 2024
c619e11
Add CODEOWNERS file
SonOfLope Mar 6, 2024
f8e9ea2
fixes #64: Increase MAX_CONTENT_LENGTH (#66)
Apr 3, 2024
342aba5
fixes #51: Add todo
Apr 3, 2024
cac2883
issue #51: Add default value to MAX_CONTENT_LENGTH
Apr 3, 2024
dd6e6c2
issue #51: Update doc
Apr 4, 2024
8e3f6c5
fixes #70: Refactor the README Sequence Diagram in Mermaid (#72)
Apr 5, 2024
d9ffdfb
issue #51: update .env.template file
Apr 8, 2024
4db261c
Merge branch 'main' into 51-implementing-2-models
Apr 8, 2024
9c161d0
issue #51: fixing markdown lint
Apr 8, 2024
f4060e1
issue #51: Add logging for tracking user in inference request
Apr 8, 2024
abffb0b
Merge branch 'main' into 51-implementing-2-models
Apr 8, 2024
4870244
issue #51: correct test to include color
Apr 8, 2024
683bf6a
issue #51: Modify /inf endpoint to receive area_ratio and color_forma…
Apr 8, 2024
ba720b0
Update docs/nachet-inference-documentation.md
Apr 9, 2024
2287e31
Update docs/nachet-inference-documentation.md
Apr 9, 2024
fa7a89f
Update docs/nachet-inference-documentation.md
Apr 9, 2024
c305214
Update docs/nachet-model-documentation.md
Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
"features": {
"ghcr.io/devcontainers/features/azure-cli:1": {},
"ghcr.io/devcontainers/features/azure-cli:1": {}
},

// Features to add to the dev container. More info: https://containers.dev/features.
Expand All @@ -25,6 +25,7 @@
"GitHub.vscode-pull-request-github",
"ms-python.python",
"ms-python.black-formatter",
"stkb.rewrap"
]
}
}
Expand Down
9 changes: 3 additions & 6 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
NACHET_AZURE_STORAGE_CONNECTION_STRING=
NACHET_MODEL_ENDPOINT_REST_URL=
NACHET_MODEL_ENDPOINT_ACCESS_KEY=
NACHET_DATA=
NACHET_SUBSCRIPTION_ID=
NACHET_RESOURCE_GROUP=
NACHET_WORKSPACE=
NACHET_MODEL=
NACHET_BLOB_PIPELINE_NAME=
NACHET_BLOB_PIPELINE_VERSION=
NACHET_BLOB_PIPELINE_DECRYPTION_KEY=
NACHET_MAX_CONTENT_LENGTH=
22 changes: 0 additions & 22 deletions .github/workflows/build-push-docker.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Docker build and push to ghcr.io/ai-cfia and lint test

Check warning on line 1 in .github/workflows/workflows.yml

View workflow job for this annotation

GitHub Actions / yaml-check / yaml-lint-check

1:1 [document-start] missing document start "---"

Check warning on line 1 in .github/workflows/workflows.yml

View workflow job for this annotation

GitHub Actions / yaml-check / yaml-lint-check

1:1 [document-start] missing document start "---"

on:
pull_request:
types:
- opened
- closed
- synchronize

jobs:
lint-test:
uses:
ai-cfia/github-workflows/.github/workflows/workflow-lint-test-python.yml@main
secrets: inherit

deploy:
uses:
ai-cfia/github-workflows/.github/workflows/workflow-build-push-container-github-registry.yml@main
with:
container-name: ${{ github.event.repository.name }}
tag: ${{ github.sha }}
registry: ghcr.io/ai-cfia
secrets: inherit

repo-standard:
uses:
ai-cfia/github-workflows/.github/workflows/workflow-repo-standards-validation.yml@main
secrets: inherit

markdown-check:
uses:
ai-cfia/github-workflows/.github/workflows/workflow-markdown-check.yml@main

yaml-check:
uses:
ai-cfia/github-workflows/.github/workflows/workflow-yaml-check.yml@main
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
.vscode/settings.json
*.pyc
.vscode/settings.json
output.*
output.*
52 changes: 39 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ frontend-->>-Client: display inference res.
backend->>+AzureStorageAPI: (async) upload_inference_result(json)
```

**Details**
### Details

- The backend was built with the [Quart](http://pgjones.gitlab.io/quart/) framework
- Quart is an asyncio reimplementation of Flask
Expand All @@ -41,35 +41,61 @@ backend->>+AzureStorageAPI: (async) upload_inference_result(json)
****

### RUNNING NACHET-BACKEND FROM DEVCONTAINER
When you are developping, you can run the program while in the devcontainer by using this command:
```

When you are developping, you can run the program while in the devcontainer by
using this command:

```bash
hypercorn -b :8080 app:app
```

### RUNNING NACHET-BACKEND AS A DOCKER CONTAINER

If you want to run the program as a Docker container (e.g., for production), use:
```

```bash
docker build -t nachet-backend .
docker run -p 8080:8080 -v $(pwd):/app nachet-backend
```

### TESTING NACHET-BACKEND

To test the program, use this command:
```

```bash
python -m unittest discover -s tests
```

****

### ENVIRONMENT VARIABLES
Start by making a copy of `.env.template` and renaming it `.env`. For the backend to function, you will need to add the missing values:

* **NACHET_AZURE_STORAGE_CONNECTION_STRING**: Connection string to access external storage (Azure Blob Storage).
* **NACHET_MODEL_ENDPOINT_REST_URL**: Endpoint to communicate with deployed model for inferencing.
* **NACHET_MODEL_ENDPOINT_ACCESS_KEY**: Key used when consuming online endpoint.
* **NACHET_DATA**: Url to access nachet-data repository
* **NACHET_HEALTH_MESSAGE**: Health check message for the server.
* **NACHET_MAX_CONTENT_LENGTH**: Set the maximum size of the file that can be uploaded to the backend. Needs to be the same size as the `client_max_body_size` [value](https://github.com/ai-cfia/howard/blob/dedee069f051ba743122084fcb5d5c97c2499359/kubernetes/aks/apps/nachet/base/nachet-ingress.yaml#L13) set from the deployment in Howard.
Start by making a copy of `.env.template` and renaming it `.env`. For the
backend to function, you will need to add the missing values:

- **NACHET_AZURE_STORAGE_CONNECTION_STRING**: Connection string to access
external storage (Azure Blob Storage).
- **NACHET_MODEL_ENDPOINT_REST_URL**: Endpoint to communicate with deployed
model for inferencing.
- **NACHET_MODEL_ENDPOINT_ACCESS_KEY**: Key used when consuming online endpoint.
- **NACHET_DATA**: Url to access nachet-data repository
- **NACHET_HEALTH_MESSAGE**: Health check message for the server.
- **NACHET_MAX_CONTENT_LENGTH**: Set the maximum size of the file that can be
uploaded to the backend. Needs to be the same size as the
`client_max_body_size`
[value](https://github.com/ai-cfia/howard/blob/dedee069f051ba743122084fcb5d5c97c2499359/kubernetes/aks/apps/nachet/base/nachet-ingress.yaml#L13)
set from the deployment in Howard.
- **NACHET_SUBSCRIPTION_ID**
- **NACHET_RESOURCE_GROUP**
- **NACHET_WORKSPACE**
- **NACHET_MODEL**
- **NACHET_BLOB_PIPELINE_NAME**
- **NACHET_BLOB_PIPELINE_VERSION**
- **NACHET_BLOB_PIPELINE_DECRYPTION_KEY**

****

### DEPLOYING NACHET
If you need help deploying Nachet for your own needs, please contact us at [email protected].

If you need help deploying Nachet for your own needs, please contact us at
<[email protected]>.
103 changes: 103 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Testing documentation

To start the automatic test, you can use the following command:

```bash
python -m unittest discover -s tests
```

You also have the option to run automatic test in run_test.py or manually test
the functionality with the frontend. [See frontend testing
documentation](https://github.com/ai-cfia/nachet-frontend/blob/main/TESTING.md)

To perform the following test, you will need the frontend repository for the
Nachet Interactive's application. The frontend can be found at: [Nachet Frontend
GitHub Repository](https://github.com/ai-cfia/nachet-frontend).

You will also need the list of the available pipelines. The list can be found
[here](https://github.com/ai-cfia/nachet-backend/blob/51-implementing-2-models/docs/nachet-inference-documentation.md#available-version-of-the-json-file).

---

## Test Case: Populate model selection with pipelines information

**Objective**: Verify that the model selection component gets populated with the
pipeline information.

**Preconditions:**

- [ ] Nachet backend is set up and running. Use the command `hypercorn -b :8080
app:app` to start the quartz server.
- [ ] The environment variables are all set.
- [ ] :exclamation: The frontend is not running yet

**Test Steps:**

1. Start the frontend application
1. Click on the model selection button
1. Validate that the current pipeline is selectable.

**Expected Results:**

- [ ] If a problem occurs while retrieving the data, an error should prevent the
server from starting.
- [ ] If a problem occurs while retrieving the data, but no error was raised,
the model selection component should be empty.
- [ ] If everything went correctly while retrieving the data, the model
selection component should display the pipeline metadata.

**Actual Results:**

- [ ] Describe the actual outcome of the test

**Pass/Fail Criteria:**

- [ ] Pass if the metadata from the available pipeline is displayed.
- [ ] Fail if the metadata from the available pipeline is not displayed and no
error was raised.

---

## Test Case: Inference Request

**Objective**: Verify that the inference request endpoint `/inf` behaves as
expected.

**Preconditions:**

- [ ] Nachet backend is set up and running. Use the command `hypercorn -b :8080
app:app` to start the quartz server.
- [ ] The environment variables are all set.
- [ ] The frontend is running.
- [ ] Start the frontend application
- [ ] Click on the model selection button
- [ ] Validate that the current pipeline is selectable

**Test Steps:**

1. Upload a seed image
1. Select the first model (pipeline)
1. Click on the classify button
1. Wait until the results populated on the canvas
1. Repeat the process for every model (pipeline)

|:boom: Warning| |:--:| |Displaying results from two different models will
overlap and become unreadable.|

**Expected Results:**

- [ ] The data populates both the canvas and the results components with the
prediction data from the model (pipeline).
- [ ] An alert with an error from port 3000 or 8080 is displayed.

**Actual Results:**

- [ ] Describe the actual outcome of the test

**Pass/Fail Criteria:**

- [ ] Pass if the data populates both the canvas and the results components with
the prediction of the model (pipeline).
- [ ] Fail if an alert is displayed with an error message.
- [ ] Fail if the data does not populates the canvas and the results component
- [ ] Fail if the inference is stuck in an infinite loop
Loading
Loading