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
b44fae11
Commit
b44fae11
authored
11 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Accept body data in PUT
parent
256dfc0d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
model_server/clients/imagej/adapter.py
+4
-3
4 additions, 3 deletions
model_server/clients/imagej/adapter.py
model_server/clients/imagej/client_test.py
+12
-3
12 additions, 3 deletions
model_server/clients/imagej/client_test.py
with
16 additions
and
6 deletions
model_server/clients/imagej/adapter.py
+
4
−
3
View file @
b44fae11
...
...
@@ -13,12 +13,13 @@ HOST = '127.0.0.1'
PORT
=
6221
uri
=
'
http://{}:{}/
'
.
format
(
HOST
,
PORT
)
def
hit_endpoint
(
method
,
endpoint
,
params
=
None
):
def
hit_endpoint
(
method
,
endpoint
,
params
=
None
,
body
=
None
):
"""
Python 2.7 implementation of HTTP client
:param method: (str) either
'
GET
'
or
'
PUT
'
:param endpoint: (str) endpoint of HTTP request
:param params: (dict) of parameters required by client request
:param params: (dict) of parameters that are embedded in client request URL
:param body: (dict) of parameters that JSON-encoded and attached as payload in request
:return: (dict) of response status and content, formatted as dict if request is successful
"""
connection
=
httplib
.
HTTPConnection
(
HOST
,
PORT
)
...
...
@@ -28,7 +29,7 @@ def hit_endpoint(method, endpoint, params=None):
url
=
endpoint
+
'
?
'
+
urllib
.
urlencode
(
params
)
else
:
url
=
endpoint
connection
.
request
(
method
,
url
)
connection
.
request
(
method
,
url
,
body
=
json
.
dumps
(
body
)
)
resp
=
connection
.
getresponse
()
resp_str
=
resp
.
read
()
try
:
...
...
This diff is collapsed.
Click to expand it.
model_server/clients/imagej/client_test.py
+
12
−
3
View file @
b44fae11
from
adapter
import
hit_endpoint
,
verify_server
import
os
import
sys
for
sp
in
[
'
model_server/model_server/clients
'
,
'
trec_adaptive_feedback/trec_adaptive_feedback/clients
'
]:
sys
.
path
.
append
(
os
.
path
.
join
(
os
.
path
.
expanduser
(
'
~
'
),
sp
))
from
imagej.adapter
import
hit_endpoint
,
verify_server
if
__name__
==
'
__main__
'
:
print
(
verify_server
())
print
(
verify_server
(
popup
=
False
))
data
=
{
'
par1
'
:
'
hello
'
,
'
par2
'
:
[
'
ab
'
,
'
cd
'
]}
resp
=
hit_endpoint
(
'
PUT
'
,
'
/
'
,
params
=
None
)
resp
=
hit_endpoint
(
'
PUT
'
,
'
/bounce_back
'
,
params
=
None
)
print
(
resp
)
assert
resp
[
'
status
'
]
==
200
print
(
'
Finished
'
)
\ 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