Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SVLT
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
ALMF
SVLT
Commits
d7642645
Commit
d7642645
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Ignore pycache files
parent
9d130294
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
+3
-6
3 additions, 6 deletions
api.py
tests/test_api.py
+27
-0
27 additions, 0 deletions
tests/test_api.py
with
30 additions
and
6 deletions
model_server/
api.py
→
api.py
+
3
−
6
View file @
d7642645
...
...
@@ -2,8 +2,8 @@ from pathlib import Path
from
fastapi
import
FastAPI
,
HTTPException
from
session
import
Session
from
workflow
import
infer_image_to_image
from
model_server.
session
import
Session
from
model_server.
workflow
import
infer_image_to_image
app
=
FastAPI
()
session
=
Session
()
...
...
@@ -14,7 +14,7 @@ def startup():
@app.get
(
'
/
'
)
def
read_root
():
return
{
'
test
'
:
'
success
'
}
return
{
'
success
'
:
True
}
@app.get
(
'
/models
'
)
def
list_active_models
():
...
...
@@ -27,9 +27,6 @@ def load_model(model_id: str, project_file: Path) -> Path: # does API autoencode
status_code
=
409
,
detail
=
f
'
Model with id
{
model_id
}
has already been loaded
'
)
# model = new_ilastik_shell
# session.models[model_id] = model
pass
@app.post
(
'
/i2i/infer/{model_id}
'
)
# image file in, image file out
def
infer_img
(
model_id
:
str
,
imgf
:
str
,
channel
:
int
=
None
)
->
dict
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_api.py
0 → 100644
+
27
−
0
View file @
d7642645
from
multiprocessing
import
Process
import
requests
import
unittest
import
uvicorn
class
TestApiFromAutomatedClient
(
unittest
.
TestCase
):
def
setUp
(
self
)
->
None
:
import
uvicorn
host
=
'
127.0.0.1
'
port
=
5000
self
.
server_process
=
Process
(
target
=
uvicorn
.
run
,
args
=
(
'
api:app
'
,
),
kwargs
=
{
'
host
'
:
host
,
'
port
'
:
port
,
'
log_level
'
:
'
info
'
},
daemon
=
True
)
self
.
uri
=
f
'
http://
{
host
}
:
{
port
}
/
'
self
.
server_process
.
start
()
def
tearDown
(
self
)
->
None
:
self
.
server_process
.
terminate
()
def
test_trivial_api_response
(
self
):
resp
=
requests
.
get
(
self
.
uri
,
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
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