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

Fixes #76: Enhance Data Storage: Including Model Details in the result.json file #77

Merged
merged 6 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ backend to function, you will need to add the missing values:
accepted by the backend
- **NACHET_VALID_DIMENSION**: Contains the valid dimensions for an image to be
accepted in the backend.
- **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.

#### DEPRECATED

Expand Down
15 changes: 13 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class MaxContentLengthWarning(APIWarnings):
[
'request_function',
'name',
'version',
'endpoint',
'api_key',
'content_type',
Expand Down Expand Up @@ -371,7 +372,9 @@ async def inference_request():
container_client, folder_name, image_bytes, hash_value
)
k-allagbe marked this conversation as resolved.
Show resolved Hide resolved

for idx, model in enumerate(pipelines_endpoints.get(pipeline_name)):
pipeline = pipelines_endpoints.get(pipeline_name)

for idx, model in enumerate(pipeline):
print(f"Entering {model.name.upper()} model") # TODO: Transform into logging
result_json = await model.request_function(model, cache_json_result[idx])
cache_json_result.append(result_json)
Expand All @@ -383,7 +386,7 @@ async def inference_request():
cache_json_result[-1], imageDims, area_ratio, color_format
)

result_json_string = json.dumps(processed_result_json)
result_json_string = await record_model(pipeline, processed_result_json)

# upload the inference results to the user's container as async task
app.add_background_task(
Expand Down Expand Up @@ -455,6 +458,7 @@ async def test():
m = Model(
request_function["test"],
"test_model1",
1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it hardcoded to 1?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model() took different data and in third position, they took the version of the model. Here, since I'm building a test model for the testing, I set the version of the test model to 1.

In the test refactor issue (#59) we should probably delete this endpoint and build the test models in the test files directly.

"http://localhost:8080/test_model1",
"test_api_key",
"application/json",
Expand All @@ -465,6 +469,12 @@ async def test():

return CACHE["endpoints"], 200


async def record_model(pipeline: namedtuple, result: list):
new_entry = [{"name": model.name, "version": model.version} for model in pipeline]
result[0]["models"] = new_entry
return json.dumps(result, indent=4)


async def fetch_json(repo_URL, key, file_path):
"""
Expand Down Expand Up @@ -505,6 +515,7 @@ async def get_pipelines(connection_string, pipeline_blob_name, pipeline_version,
m = Model(
request_function.get(model.get("endpoint_name")),
model.get("model_name"),
model.get("version"),
# To protect sensible data (API key and model endpoint), we encrypt it when
# it's pushed into the blob storage. Once we retrieve the data here in the
# backend, we need to decrypt the byte format to recover the original
Expand Down
3 changes: 2 additions & 1 deletion tests/test_inference_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def test_inference_request_successful(self, mock_container):
"score",
"topN",
"overlapping",
"overlappingIndices"
"overlappingIndices",
"models"
}

# Test the answers from inference_request
Expand Down
Loading