Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
model_server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Randolph Rhodes
model_server
Commits
2d3e0e87
Commit
2d3e0e87
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Pass stack trace of unhandled exceptions to response body
parent
e3162d6b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api.py
+1
-1
1 addition, 1 deletion
api.py
tests/test_api.py
+20
-13
20 additions, 13 deletions
tests/test_api.py
with
21 additions
and
14 deletions
api.py
+
1
−
1
View file @
2d3e0e87
...
...
@@ -5,7 +5,7 @@ from fastapi import FastAPI, HTTPException
from
model_server.session
import
Session
from
model_server.workflow
import
infer_image_to_image
app
=
FastAPI
()
app
=
FastAPI
(
debug
=
True
)
session
=
Session
()
@app.on_event
(
"
startup
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_api.py
+
20
−
13
View file @
2d3e0e87
...
...
@@ -15,7 +15,7 @@ class TestApiFromAutomatedClient(unittest.TestCase):
self
.
server_process
=
Process
(
target
=
uvicorn
.
run
,
args
=
(
'
api:app
'
,
),
kwargs
=
{
'
host
'
:
host
,
'
port
'
:
port
,
'
log_level
'
:
'
info
'
},
kwargs
=
{
'
host
'
:
host
,
'
port
'
:
port
,
'
log_level
'
:
'
debug
'
},
daemon
=
True
)
self
.
uri
=
f
'
http://
{
host
}
:
{
port
}
/
'
...
...
@@ -46,7 +46,7 @@ class TestApiFromAutomatedClient(unittest.TestCase):
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
content
,
b
'
{}
'
)
def
test_load_model
(
self
):
def
test_load_
dummy_
model
(
self
):
model_id
=
DummyImageToImageModel
.
model_id
resp_load
=
requests
.
put
(
self
.
uri
+
f
'
models/load
'
,
...
...
@@ -57,9 +57,21 @@ class TestApiFromAutomatedClient(unittest.TestCase):
self
.
assertEqual
(
resp_list
.
status_code
,
200
)
rj
=
resp_list
.
json
()
self
.
assertEqual
(
rj
[
model_id
][
'
class
'
],
'
DummyImageToImageModel
'
)
return
model_id
def
test_respond_with_error_when_invalid_filepath_requested
(
self
):
model_id
=
self
.
test_load_dummy_model
()
resp
=
requests
.
put
(
self
.
uri
+
f
'
i2i/infer/
'
,
params
=
{
'
model_id
'
:
model_id
,
'
input_filename
'
:
'
not_a_real_file.name
'
}
)
self
.
assertEqual
(
resp
.
status_code
,
404
,
resp
.
content
.
decode
())
def
test_i2i_inference_errors_model_not_found
(
self
):
def
test_i2i_inference_errors_when_model_not_found
(
self
):
model_id
=
'
not_a_real_model
'
resp
=
requests
.
put
(
self
.
uri
+
f
'
i2i/infer/
'
,
...
...
@@ -68,23 +80,18 @@ class TestApiFromAutomatedClient(unittest.TestCase):
'
input_filename
'
:
'
not_a_real_file.name
'
}
)
print
(
resp
.
content
)
self
.
assertEqual
(
resp
.
status_code
,
409
)
self
.
assertEqual
(
resp
.
status_code
,
409
,
resp
.
content
.
decode
())
def
test_i2i_dummy_inference_by_api
(
self
):
model
=
DummyImageToImageModel
()
resp_load
=
requests
.
put
(
self
.
uri
+
f
'
models/load
'
,
params
=
{
'
model_id
'
:
model
.
model_id
}
)
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
f
'
Error loading
{
model
.
model_id
}
'
)
model_id
=
self
.
test_load_dummy_model
()
self
.
copy_input_file_to_server
()
resp_infer
=
requests
.
put
(
self
.
uri
+
f
'
i2i/infer/
'
,
params
=
{
'
model_id
'
:
model
.
model_id
,
'
model_id
'
:
model_id
,
'
input_filename
'
:
czifile
[
'
filename
'
],
'
channel
'
:
2
,
},
)
self
.
assertEqual
(
resp_infer
.
status_code
,
200
,
f
'
Error inferring from
{
model
.
model_id
}
'
)
\ No newline at end of file
self
.
assertEqual
(
resp_infer
.
status_code
,
200
,
f
'
Error inferring from
{
model_id
}
'
,
resp_infer
.
content
.
decode
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment