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

fix #60: Creating pipeline insertion module #65

Merged
merged 90 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
3fbf0e7
fixes #51: connecting to swin model
Feb 7, 2024
04df34e
fixes #51: connecting seed detector to swin
Feb 7, 2024
f833979
fixes #51: refactor exception
Feb 8, 2024
8ebec41
fixes #51: incorporate pipelines_endpoints in CACHE
Feb 8, 2024
f3ab024
fixes #51: add request_factory function to bring a standard to call m…
Feb 8, 2024
e8f7b60
fixes #51: add models_Utils.py
Feb 9, 2024
4748844
fixes #51: Update model_utilitary_functions import
Feb 12, 2024
f19b63b
fixes #51: update result parsing and add default pipeline
Feb 12, 2024
40c298b
fixes #51: update inference_request to call swin in loop
Feb 13, 2024
1e77768
fixes #51: Add documentation to image_slicing and swin_result_parser …
Feb 13, 2024
ddd8553
fixes #51: Standardize headers with azureml-model-deployment being ma…
Feb 14, 2024
92353ad
fixes #51: updates devcontainer
Feb 14, 2024
dc95875
fixes #51: Refactor swin_result_parser function to add all result to …
Feb 14, 2024
7ff78cb
fixes #51: Change model_utilitary_function to model_request module an…
Feb 14, 2024
73ceff9
fixes #51: fix bug with request import
Feb 14, 2024
4502f3b
fixes #51: Add workflow.yml with following jobs: standard, lint test,…
Feb 14, 2024
b030591
fixes #51: Add repo-standard, markdown-check, and yaml-check workflow…
Feb 14, 2024
61f0324
fixes #51: correct failed check from workflows
Feb 14, 2024
9e43553
fixes #51: correct typo in testing.md and workflows.yml
Feb 14, 2024
ac07bc8
delete .MD file
Feb 14, 2024
266217b
fixes #51: Refactor inference result processing and add test file for…
Feb 16, 2024
aff08a3
fixes #51: add model_module module
Feb 16, 2024
84f9403
fixes #51: Add type 3 model to inference request
Feb 20, 2024
44a3227
fixes #51: change model type
Feb 20, 2024
5dd5621
fixes #51: Update doc to include input and output of inference request
Feb 20, 2024
cbd900e
Fixes #51: uptdate doc
Feb 21, 2024
753757b
fixes #51: Add model documentation for the backend
Feb 22, 2024
d72aac9
fixes #51: Change the categories model name
Feb 22, 2024
3e0ca86
fixes #51: implement model module request inference function
Feb 23, 2024
63dddec
fixes #51: add function to retrieve pipeline info from blob storage
Feb 26, 2024
1d3514e
fixes #51: Add script to upload to blob storage json file containing …
Feb 26, 2024
4f3166c
#fixes #51: update documentation on pipeline
Feb 26, 2024
1f14dab
fixes #51: correct lint error
Feb 27, 2024
f8805f4
fixes #51: correct lint error
Feb 27, 2024
384930e
Update nachet-inference-documentation.md to reflect code change
Feb 27, 2024
070f5bc
fixes #51: Add manuel test case in testing.md
Feb 27, 2024
6785da1
Correct lint error
Feb 27, 2024
3cddb43
fixes #51: Add test get pipeline info unsuccessful
Feb 28, 2024
4a4a731
fixes #51: Add get pipeline info successful test
Feb 28, 2024
13b78d4
fixes #51: Update sequence diagram to reflect change in code
Feb 28, 2024
6d63d20
fixes #51: Update sequence diagram
Feb 28, 2024
16e2193
fixes #51: Update doc string
Feb 28, 2024
3fcc61d
fixes #51: update README and TESTING
Feb 29, 2024
c57c822
fixes #51: Add inferences request automatic test
Feb 29, 2024
ea80c9c
fixes #51: correcting markdown lint
Mar 1, 2024
6651708
fixes #51: Add documentation to pipeline function
Mar 1, 2024
60482b3
fixes #51: Add inference request test
Mar 1, 2024
46aadb9
fixes #51: inference test with Quart.test_client
Mar 1, 2024
d94fb95
fixes #51: Correct lint ruff error and tests
Mar 1, 2024
cbfe42c
fixes #51: change from loop to asyncio.run
Mar 1, 2024
0101d40
fixes #51: Correct trailing whitespace and EOF.
Mar 4, 2024
a9375ff
fixes #51: implement Ricky reviews
Mar 6, 2024
216cf5e
fixes #51: implement William's reviews
Mar 6, 2024
2b2100f
fixes #51: fixes lint
Mar 6, 2024
c56569a
fixes #51: raise ConnectionStringError in insert_new_version_pipeline
Mar 6, 2024
f449137
Update .github/workflows/workflows.yml
Mar 7, 2024
0f50e07
Update .github/workflows/workflows.yml
Mar 7, 2024
269e321
fixes #51: removes run_test.py
Mar 7, 2024
098cc29
fixes #51 remove literal path
Mar 7, 2024
4985ad2
fixes ##51: add print statement to log the result from models
Mar 7, 2024
587732e
fixes #51: change to pipeline insertion script
Mar 8, 2024
29d2233
fixes #51: Move insert_new_version_pipeline to pipelines_version_inse…
Mar 14, 2024
11c8b97
fixes #51: add explanation for `box` value
Mar 14, 2024
8bd5685
Add red box image
Mar 14, 2024
dd7d752
fixes #60:
Mar 14, 2024
274b051
fixes #60: correct yaml
Mar 14, 2024
3f741a7
fixes #60: template yaml fix
Mar 14, 2024
64dd55e
fixes #60: template lint error
Mar 14, 2024
77982e9
fixes #60: template fix
Mar 14, 2024
2d22557
fixes #60: try copilot fix
Mar 14, 2024
67ff50f
fixes #60: Add unittest
Mar 19, 2024
276f56c
fixes #60: correct typo in template
Mar 19, 2024
82d2f6c
fixes #60: Correct lint error
Mar 19, 2024
29aaaa6
fixes #60: Add EOF
Mar 19, 2024
7df0e16
fixes #60: Implement grammar correction
Mar 20, 2024
9e8671e
fixes #60: Add environment variable check
Mar 20, 2024
cfd27e6
fixes #60: update environment variables readme
Mar 21, 2024
10b723f
fixes #60: remove act from devcontainer
Mar 25, 2024
91f1b46
fixes #60: Correct Markdown lint error
Mar 25, 2024
f8710c7
#Issue 60: Add a default key for pipeline
Apr 2, 2024
155b96e
issue #60: Modify tests to check error message
Apr 2, 2024
1ce2caa
issue #60: Create Fernet Key and Blob Service Client in main
Apr 3, 2024
9cf2d57
issue #60: update tests
Apr 3, 2024
b4c40dc
issue #60: Merge branch 'main' into 60-pipeline-version-insertion-module
Apr 10, 2024
ca1ec07
issue #60: add warning for image environment variable
Apr 10, 2024
c910abf
iisue #60: Change to image validation
Apr 10, 2024
662af44
issue #60: remove legacy folder
Apr 10, 2024
f3c5558
issue #60: Eliminate catching generic exceptions
Apr 11, 2024
7df50f0
issue #65: Move CONSTANT to upper function
Apr 11, 2024
9124f99
fixes #60: Move pipeline related files into
Apr 15, 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
5 changes: 2 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"name": "Python 3",
// 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": {},
},
"features": {},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand All @@ -25,6 +23,7 @@
"GitHub.vscode-pull-request-github",
"ms-python.python",
"ms-python.black-formatter",
"stkb.rewrap"
]
}
}
Expand Down
7 changes: 5 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
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=
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 "---"

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.*
59 changes: 43 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# nachet-backend

## High level sequence diagram

![SD_1 drawio (2)](https://github.com/ai-cfia/nachet-backend/assets/19809069/272f37dc-f4ec-449b-ba82-950c54b9f856)

**Details**
### Details

- The backend was built with the [Quart](http://pgjones.gitlab.io/quart/) framework
- Quart is an asyncio reimplementation of Flask
Expand All @@ -12,36 +13,62 @@
- Inference results from model endpoint are directly handled in `model_inference/inference.py`

****

### 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:
```

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:
```

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.
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_DATA**: Url to access nachet-data repository
- **NACHET_BLOB_PIPELINE_NAME**: The name of the blob containing the pipeline.
- **NACHET_BLOB_PIPELINE_VERSION**: The version of the file containing the
pipeline used.
- **NACHET_BLOB_PIPELINE_DECRYPTION_KEY**: The key to decrypt sensible data from
the models.

#### DEPRECATED

- **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_SUBSCRIPTION_ID**: Was used to retrieve models metadata
- **NACHET_WORKSPACE**: Was used to retrieve models metadata
- **NACHET_RESOURCE_GROUP**: Was used to retrieve models metadata
- **NACHET_MODEL**: Was used to retrieve models metadata

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

### DEPLOYING NACHET

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 quart 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 quart 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