Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python:
# command to install dependencies
install:
- python setup.py bdist_wheel
- pip install dist/deepomatic-*.whl
- pip install dist/deepomatic_api-*.whl
- mkdir samples
- cp demo.py samples/demo.py

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN python setup.py bdist_wheel
FROM ${BASE_IMAGE} as runtime

# copy egg
COPY --from=builder /app/dist/deepomatic-*.whl /tmp/
COPY --from=builder /app/dist/deepomatic_api-*.whl /tmp/
COPY --from=builder /app/demo.py /samples/

RUN pip install /tmp/deepomatic-*.whl
RUN pip install /tmp/deepomatic_api-*.whl
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
all: release

release: clean
python3 setup.py sdist bdist_wheel

clean:
rm -rf build dist *.egg-info

publish-test: release
# For testing, note that once one version is uploaded, you have to increment the version number or make a post release to re-upload
# https://www.python.org/dev/peps/pep-0440/#post-releases
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

publish: release
# More info here https://packaging.python.org/tutorials/packaging-projects/
twine upload dist/*
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,41 @@
# deepomatic-client-python

Deepomatic API Client for Python.
[Deepomatic](https://www.deepomatic.com) API Client for Python.

This client have been made in order to help you integrating our services within your apps in python.

Tested on python 2.7 & 3.5.

<br/>
Tested on python 2.7, 3.4, 3.5, 3.6.

# API Documentation

https://developers.deepomatic.com/docs/v0.7
<br/>

# Installation

```bash
pip install deepomatic-api
```
git clone https://github.com/Deepomatic/deepomatic-client-python.git
pip install ./deepomatic-client-python
```
<br/>

# Client

Initialize a client.
Does not make any call to the server.

```python
import deepomatic
from deepomatic.api.client import Client

# You should find your app_id and api_key in your account on https://developers.deepomatic.com/dashboard
client = deepomatic.Client(app_id, api_key)
client = Client(app_id, api_key)
```

### Client methods

All client methods can be found in [deepomatic/client.py](deepomatic/client.py) and detail for each type of resource is located in [deepomatic/resources](deepomatic/resources).
All client methods can be found in [deepomatic/api/client.py](deepomatic/api/client.py) and detail for each type of resource is located in [deepomatic/api/resources](deepomatic/api/resources).

### Examples

You will find examples of usage in [demo.py](demo.py).

# Bugs

Please send bug reports to support@deepomatic.com
Please send bug reports to support@deepomatic.com or open an issue here.
33 changes: 6 additions & 27 deletions deepomatic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
# -*- coding: utf-8 -*-
"""
Copyright (c) 2017 Deepomatic SAS
http://www.deepomatic.com/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

from deepomatic.version import __version__
from deepomatic.client import Client
from deepomatic.inputs import ImageInput
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
1 change: 1 addition & 0 deletions deepomatic/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from deepomatic.api.version import __version__
10 changes: 5 additions & 5 deletions deepomatic/client.py → deepomatic/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
THE SOFTWARE.
"""

from deepomatic.http_helper import HTTPHelper
from deepomatic.resources.network import Network
from deepomatic.resources.recognition import RecognitionSpec, RecognitionVersion
from deepomatic.resources.task import Task
from deepomatic.resources.account import Account
from deepomatic.api.http_helper import HTTPHelper
from deepomatic.api.resources.network import Network
from deepomatic.api.resources.recognition import RecognitionSpec, RecognitionVersion
from deepomatic.api.resources.task import Task
from deepomatic.api.resources.account import Account

###############################################################################

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions deepomatic/http_helper.py → deepomatic/api/http_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
from requests.structures import CaseInsensitiveDict
from six import string_types

from deepomatic.exceptions import DeepomaticException, BadStatus
from deepomatic.version import __version__
from deepomatic.api.exceptions import DeepomaticException, BadStatus
from deepomatic.api.version import __version__

###############################################################################

Expand Down
2 changes: 1 addition & 1 deletion deepomatic/inputs.py → deepomatic/api/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import copy
import base64

from deepomatic.exceptions import DeepomaticException
from deepomatic.api.exceptions import DeepomaticException


###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions deepomatic/mixins.py → deepomatic/api/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
THE SOFTWARE.
"""

from deepomatic.exceptions import DeepomaticException
from deepomatic.resource import ResourceList
from deepomatic.api.exceptions import DeepomaticException
from deepomatic.api.resource import ResourceList


###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion deepomatic/resource.py → deepomatic/api/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import json
import copy

from deepomatic.exceptions import DeepomaticException, NoData
from deepomatic.api.exceptions import DeepomaticException, NoData


###############################################################################
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
"""

from deepomatic.resource import Resource
from deepomatic.api.resource import Resource


###############################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
from six import string_types
import numpy as np

from deepomatic.resource import Resource
from deepomatic.utils import InferenceResource
from deepomatic.mixins import CreateableResource, ListableResource, UpdatableResource, DeletableResource
from deepomatic.mixins import RequiredArg, OptionnalArg, ImmutableArg
from deepomatic.api.resource import Resource
from deepomatic.api.utils import InferenceResource
from deepomatic.api.mixins import CreateableResource, ListableResource, UpdatableResource, DeletableResource
from deepomatic.api.mixins import RequiredArg, OptionnalArg, ImmutableArg


###############################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

from six import string_types

from deepomatic.resource import Resource, ResourceList
from deepomatic.utils import InferenceResource
from deepomatic.mixins import CreateableResource, ListableResource, UpdatableResource, DeletableResource
from deepomatic.mixins import RequiredArg, OptionnalArg, ImmutableArg, UpdateOnlyArg
from deepomatic.api.resource import Resource, ResourceList
from deepomatic.api.utils import InferenceResource
from deepomatic.api.mixins import CreateableResource, ListableResource, UpdatableResource, DeletableResource
from deepomatic.api.mixins import RequiredArg, OptionnalArg, ImmutableArg, UpdateOnlyArg


###############################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

from tenacity import Retrying, wait_random_exponential, stop_after_delay, retry_if_result, before_log, after_log, RetryError

from deepomatic.resource import Resource
from deepomatic.mixins import ListableResource
from deepomatic.exceptions import TaskError, TaskTimeout
from deepomatic.api.resource import Resource
from deepomatic.api.mixins import ListableResource
from deepomatic.api.exceptions import TaskError, TaskTimeout
import logging


Expand Down
6 changes: 3 additions & 3 deletions deepomatic/utils.py → deepomatic/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
THE SOFTWARE.
"""

from deepomatic.exceptions import DeepomaticException
from deepomatic.resources.task import Task
from deepomatic.inputs import format_inputs
from deepomatic.api.exceptions import DeepomaticException
from deepomatic.api.resources.task import Task
from deepomatic.api.inputs import format_inputs


###############################################################################
Expand Down
13 changes: 13 additions & 0 deletions deepomatic/api/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
__title__ = 'deepomatic-api'
__description__ = 'Deepomatic API client'
__version__ = '0.7.10'
__author__ = 'deepomatic'
__author_email__ = 'support@deepomatic.com'
__url__ = 'https://github.com/deepomatic/deepomatic-client-python'
__license__ = 'MIT License'
__project_urls__ = {
'Product': 'https://www.deepomatic.com',
'Documentation': 'https://developers.deepomatic.com/docs/v0.7',
'Source': 'https://github.com/deepomatic/deepomatic-client-python',
'Tracker': 'https://github.com/deepomatic/deepomatic-client-python/issues',
}
7 changes: 0 additions & 7 deletions deepomatic/version.py

This file was deleted.

6 changes: 3 additions & 3 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import base64
import tarfile

import deepomatic
from deepomatic import ImageInput
from deepomatic.api.client import Client
from deepomatic.api.inputs import ImageInput

if sys.version_info >= (3, 0):
from urllib.request import urlretrieve
Expand All @@ -19,7 +19,7 @@

app_id = os.getenv('DEEPOMATIC_APP_ID')
api_key = os.getenv('DEEPOMATIC_API_KEY')
client = deepomatic.Client(app_id, api_key, host=api_host)
client = Client(app_id, api_key, host=api_host)

demo_url = "https://static.deepomatic.com/resources/demos/api-clients/dog1.jpg"

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy>=1.10,<2
numpy>=1.10.0,<2
promise>=2.1,<3
six>=1.10.0,<2
requests>=2.19.0,<3 # will not work below in python3
Expand Down
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[bdist_wheel]
universal = 1

[metadata]
license_file = LICENSE
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


about = {}
with io.open(os.path.join(here, 'deepomatic', 'version.py'), 'r', encoding='utf-8') as f:
with io.open(os.path.join(here, 'deepomatic', 'api', 'version.py'), 'r', encoding='utf-8') as f:
exec(f.read(), about)

with io.open(os.path.join(here, 'README.md'), 'r', encoding='utf-8') as readme:
Expand All @@ -22,7 +22,9 @@
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

# Read requirements
install_reqs = parse_requirements('requirements.txt', session='hack')
install_reqs = parse_requirements(os.path.join(here, 'requirements.txt'), session='hack')

namespaces = ['deepomatic']

setup(
name=about['__title__'],
Expand All @@ -31,10 +33,14 @@
author=about['__author__'],
author_email=about['__author_email__'],
url=about['__url__'],
project_urls=about['__project_urls__'],
license=about['__license__'],
packages=find_packages(),
namespace_packages=namespaces,
include_package_data=True,
long_description=README,
long_description_content_type='text/markdown',
data_files=[('', ['requirements.txt'])],
install_requires=[str(ir.req) for ir in install_reqs],
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
classifiers=[
Expand Down