Skip to content

Commit

Permalink
feat: make python client an install package
Browse files Browse the repository at this point in the history
This will allow to install it directly in jupyter docker image:

jolibrain/dd_platform_docker#39
  • Loading branch information
sileht committed Oct 23, 2020
1 parent d534a16 commit ec2f5e2
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 210 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ build/*
!build/get_libs.sh
model/
models/
clients/
tools/build-cpp-netlib/
12 changes: 9 additions & 3 deletions clients/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ or system-wide, e.g. on Ubuntu:
sudo apt-get install python-requests
```

Then either copy it into your Python code repository or point your `PYTHONPATH` to it:
Then install deepdetect python client from deepdetect source code:

```
export PYTHONPATH=/path/to/deepdetect/clients/python/:$PYTHONPATH
cd deepdetect_src/clients/python
pip install .
```

or directly with:

```
pip install git+https://github.com/deepdetect.git#egg=dd_client&subdirectory=dd_client
```

The DD client may post images through they base64 representation if those are
not accessible to the deepdetect server. The base64 conversion is supported for
images on the client filesystem or online (http/https), shall the url be only
accessible to the client. A `base64` flag (default to `False`) is available in
the `post_predict` method.

199 changes: 0 additions & 199 deletions clients/python/dd_bench.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self, host="localhost", port=8080, proto=0, path='', apiversion="0.
self.__ddurl = 'https://%s:%d' % (host, port)
if path:
self.__ddurl += path

def set_return_format(self, f):
assert f == self.RETURN_PYTHON or f == self.RETURN_JSON or f == self.RETURN_NONE
self.__returntype = f
Expand Down Expand Up @@ -247,12 +247,12 @@ def make_call(self, sname, data, parameters_input, parameters_mllib,
parameters_output, use_base64=False, index_uris = []):
"""
Creates a dictionary that holds the JSON call,
to be added to an array and processed by
to be added to an array and processed by
a post_chain API call. This basically eases the making
of chain calls from Python.
Parameters are the same as for a post_predict call
"""

if use_base64:
data = [_convert_base64(d) for d in data]

Expand All @@ -264,7 +264,7 @@ def make_call(self, sname, data, parameters_input, parameters_mllib,
call["data"] = data
if index_uris:
call["index_uris"] = index_uris

return call

def make_action(self, action_type, parameters=[]):
Expand All @@ -289,10 +289,13 @@ def post_chain(self, cname, calls):

chain = {"chain": { "calls": calls } }
return self.post(self.__urls["chain"] + '/%s' % cname, json=chain)

# test
if __name__ == '__main__':

def main():
dd = DD()
dd.set_return_format(dd.RETURN_PYTHON)
inf = dd.info()
print(inf)

# test
if __name__ == '__main__':
main()
Loading

0 comments on commit ec2f5e2

Please sign in to comment.