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
1cea684d
Commit
1cea684d
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Similarly, API test cases now call GET through an internal method
parent
c673b215
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
model_server/extensions/ilastik/tests/test_ilastik.py
+9
-9
9 additions, 9 deletions
model_server/extensions/ilastik/tests/test_ilastik.py
tests/test_api.py
+22
-29
22 additions, 29 deletions
tests/test_api.py
with
31 additions
and
38 deletions
model_server/extensions/ilastik/tests/test_ilastik.py
+
9
−
9
View file @
1cea684d
...
...
@@ -144,7 +144,7 @@ class TestIlastikOverApi(TestServerBaseClass):
)
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
model_id
=
resp_load
.
json
()[
'
model_id
'
]
resp_list
=
requests
.
get
(
self
.
uri
+
'
models
'
)
resp_list
=
self
.
_get
(
'
models
'
)
self
.
assertEqual
(
resp_list
.
status_code
,
200
)
rj
=
resp_list
.
json
()
self
.
assertEqual
(
rj
[
model_id
][
'
class
'
],
'
IlastikPixelClassifierModel
'
)
...
...
@@ -152,24 +152,24 @@ class TestIlastikOverApi(TestServerBaseClass):
def
test_load_another_ilastik_pixel_model
(
self
):
model_id
=
self
.
test_load_ilastik_pixel_model
()
resp_list_1st
=
requests
.
get
(
self
.
uri
+
'
models
'
).
json
()
resp_list_1st
=
self
.
_get
(
'
models
'
).
json
()
self
.
assertEqual
(
len
(
resp_list_1st
),
1
,
resp_list_1st
)
resp_load_2nd
=
self
.
_put
(
'
ilastik/seg/load/
'
,
{
'
project_file
'
:
str
(
ilastik_classifiers
[
'
px
'
]),
'
duplicate
'
:
True
,
},
)
resp_list_2nd
=
requests
.
get
(
self
.
uri
+
'
models
'
).
json
()
resp_list_2nd
=
self
.
_get
(
'
models
'
).
json
()
self
.
assertEqual
(
len
(
resp_list_2nd
),
2
,
resp_list_2nd
)
resp_load_3rd
=
self
.
_put
(
'
ilastik/seg/load/
'
,
{
'
project_file
'
:
str
(
ilastik_classifiers
[
'
px
'
]),
'
duplicate
'
:
False
},
)
resp_list_3rd
=
requests
.
get
(
self
.
uri
+
'
models
'
).
json
()
resp_list_3rd
=
self
.
_get
(
'
models
'
).
json
()
self
.
assertEqual
(
len
(
resp_list_3rd
),
2
,
resp_list_3rd
)
def
test_no_duplicate_model_with_different_path_formats
(
self
):
requests
.
get
(
self
.
uri
+
'
restart
'
)
resp_list_1
=
requests
.
get
(
self
.
uri
+
'
models
'
).
json
()
self
.
_get
(
'
restart
'
)
resp_list_1
=
self
.
_get
(
'
models
'
).
json
()
self
.
assertEqual
(
len
(
resp_list_1
),
0
)
ilp
=
ilastik_classifiers
[
'
px
'
]
...
...
@@ -194,7 +194,7 @@ class TestIlastikOverApi(TestServerBaseClass):
self
.
assertEqual
(
resp1
.
json
(),
resp2
.
json
())
# assert that only one copy of the model is loaded
resp_list_2
=
requests
.
get
(
self
.
uri
+
'
models
'
).
json
()
resp_list_2
=
self
.
_get
(
'
models
'
).
json
()
print
(
resp_list_2
)
self
.
assertEqual
(
len
(
resp_list_2
),
1
)
...
...
@@ -207,7 +207,7 @@ class TestIlastikOverApi(TestServerBaseClass):
model_id
=
resp_load
.
json
()[
'
model_id
'
]
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
resp_list
=
requests
.
get
(
self
.
uri
+
'
models
'
)
resp_list
=
self
.
_get
(
'
models
'
)
self
.
assertEqual
(
resp_list
.
status_code
,
200
)
rj
=
resp_list
.
json
()
self
.
assertEqual
(
rj
[
model_id
][
'
class
'
],
'
IlastikObjectClassifierFromPixelPredictionsModel
'
)
...
...
@@ -221,7 +221,7 @@ class TestIlastikOverApi(TestServerBaseClass):
model_id
=
resp_load
.
json
()[
'
model_id
'
]
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
resp_list
=
requests
.
get
(
self
.
uri
+
'
models
'
)
resp_list
=
self
.
_get
(
'
models
'
)
self
.
assertEqual
(
resp_list
.
status_code
,
200
)
rj
=
resp_list
.
json
()
self
.
assertEqual
(
rj
[
model_id
][
'
class
'
],
'
IlastikObjectClassifierFromSegmentationModel
'
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_api.py
+
22
−
29
View file @
1cea684d
...
...
@@ -23,21 +23,26 @@ class TestServerBaseClass(unittest.TestCase):
)
self
.
uri
=
f
'
http://
{
host
}
:
{
port
}
/
'
self
.
server_process
.
start
()
requests
.
get
(
self
.
uri
+
'
restart
'
)
def
_
put
(
self
,
endpoint
,
params
=
None
):
def
_
get_sesh
(
self
):
sesh
=
requests
.
Session
()
retries
=
Retry
(
total
=
5
,
backoff_factor
=
0.1
,
)
sesh
.
mount
(
'
http://
'
,
requests
.
adapters
.
HTTPAdapter
(
max_retries
=
retries
))
return
sesh
.
put
(
self
.
uri
+
endpoint
,
params
=
params
)
return
sesh
def
_get
(
self
,
endpoint
):
return
self
.
_get_sesh
().
get
(
self
.
uri
+
endpoint
)
def
_put
(
self
,
endpoint
,
params
=
None
):
return
self
.
_get_sesh
().
put
(
self
.
uri
+
endpoint
,
params
=
params
)
def
copy_input_file_to_server
(
self
):
from
shutil
import
copyfile
resp
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
resp
=
self
.
_get
(
'
paths
'
)
pa
=
resp
.
json
()[
'
inbound_images
'
]
outpath
=
Path
(
pa
)
/
czifile
[
'
filename
'
]
copyfile
(
...
...
@@ -50,7 +55,7 @@ class TestServerBaseClass(unittest.TestCase):
class
TestApiFromAutomatedClient
(
TestServerBaseClass
):
def
test_trivial_api_response
(
self
):
resp
=
requests
.
get
(
self
.
uri
,
)
resp
=
self
.
_get
(
''
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
def
test_bounceback_parameters
(
self
):
...
...
@@ -61,7 +66,7 @@ class TestApiFromAutomatedClient(TestServerBaseClass):
def
test_default_session_paths
(
self
):
import
model_server.conf.defaults
resp
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
resp
=
self
.
_get
(
'
paths
'
)
conf_root
=
model_server
.
conf
.
defaults
.
root
for
p
in
[
'
inbound_images
'
,
'
outbound_images
'
,
'
logs
'
]:
self
.
assertTrue
(
resp
.
json
()[
p
].
startswith
(
conf_root
.
__str__
()))
...
...
@@ -69,7 +74,7 @@ class TestApiFromAutomatedClient(TestServerBaseClass):
self
.
assertTrue
(
resp
.
json
()[
p
].
endswith
(
suffix
))
def
test_list_empty_loaded_models
(
self
):
resp
=
requests
.
get
(
self
.
uri
+
'
models
'
)
resp
=
self
.
_get
(
'
models
'
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
content
,
b
'
{}
'
)
...
...
@@ -77,7 +82,7 @@ class TestApiFromAutomatedClient(TestServerBaseClass):
resp_load
=
self
.
_put
(
f
'
models/dummy/load
'
)
model_id
=
resp_load
.
json
()[
'
model_id
'
]
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
resp_list
=
requests
.
get
(
self
.
uri
+
'
models
'
)
resp_list
=
self
.
_get
(
'
models
'
)
self
.
assertEqual
(
resp_list
.
status_code
,
200
)
rj
=
resp_list
.
json
()
self
.
assertEqual
(
rj
[
model_id
][
'
class
'
],
'
DummySemanticSegmentationModel
'
)
...
...
@@ -117,33 +122,27 @@ class TestApiFromAutomatedClient(TestServerBaseClass):
def
test_restarting_session_clears_loaded_models
(
self
):
resp_load
=
self
.
_put
(
f
'
models/dummy/load
'
,)
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
resp_list_0
=
requests
.
get
(
self
.
uri
+
'
models
'
)
resp_list_0
=
self
.
_get
(
'
models
'
)
self
.
assertEqual
(
resp_list_0
.
status_code
,
200
)
rj0
=
resp_list_0
.
json
()
self
.
assertEqual
(
len
(
rj0
),
1
,
f
'
Unexpected models in response:
{
rj0
}
'
)
resp_restart
=
requests
.
get
(
self
.
uri
+
'
restart
'
)
resp_list_1
=
requests
.
get
(
self
.
uri
+
'
models
'
)
resp_restart
=
self
.
_get
(
'
restart
'
)
resp_list_1
=
self
.
_get
(
'
models
'
)
rj1
=
resp_list_1
.
json
()
self
.
assertEqual
(
len
(
rj1
),
0
,
f
'
Unexpected models in response:
{
rj1
}
'
)
def
test_change_inbound_path
(
self
):
resp_inpath
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
resp_inpath
=
self
.
_get
(
'
paths
'
)
resp_change
=
self
.
_put
(
f
'
paths/watch_output
'
,
{
'
path
'
:
resp_inpath
.
json
()[
'
inbound_images
'
]}
)
self
.
assertEqual
(
resp_change
.
status_code
,
200
)
resp_check
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
resp_check
=
self
.
_get
(
'
paths
'
)
self
.
assertEqual
(
resp_check
.
json
()[
'
inbound_images
'
],
resp_check
.
json
()[
'
outbound_images
'
])
def
test_exception_when_changing_inbound_path
(
self
):
resp_inpath
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
resp_inpath
=
self
.
_get
(
'
paths
'
)
fakepath
=
'
c:/fake/path/to/nowhere
'
resp_change
=
self
.
_put
(
f
'
paths/watch_output
'
,
...
...
@@ -151,21 +150,15 @@ class TestApiFromAutomatedClient(TestServerBaseClass):
)
self
.
assertEqual
(
resp_change
.
status_code
,
404
)
self
.
assertIn
(
fakepath
,
resp_change
.
json
()[
'
detail
'
])
resp_check
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
resp_check
=
self
.
_get
(
'
paths
'
)
self
.
assertEqual
(
resp_inpath
.
json
()[
'
outbound_images
'
],
resp_check
.
json
()[
'
outbound_images
'
])
def
test_no_change_inbound_path
(
self
):
resp_inpath
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
resp_inpath
=
self
.
_get
(
'
paths
'
)
resp_change
=
self
.
_put
(
f
'
paths/watch_output
'
,
{
'
path
'
:
resp_inpath
.
json
()[
'
outbound_images
'
]}
)
self
.
assertEqual
(
resp_change
.
status_code
,
200
)
resp_check
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
resp_check
=
self
.
_get
(
'
paths
'
)
self
.
assertEqual
(
resp_inpath
.
json
()[
'
outbound_images
'
],
resp_check
.
json
()[
'
outbound_images
'
])
\ No newline at end of file
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