Skip to content

Commit

Permalink
applied isort seldon_core and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxue authored and seldondev committed Feb 5, 2021
1 parent 23eced9 commit 5ecbf9c
Show file tree
Hide file tree
Showing 37 changed files with 278 additions and 261 deletions.
25 changes: 9 additions & 16 deletions python/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
# Test and linters
black==20.8b1
coverage==5.3.1 # 2nd lvl dep on cov required to avoid sqllite dep
flake8==3.8.1
grpcio-tools==1.33.2
isort==5.7.0
mypy-protobuf==1.22
mypy<0.791
Pillow==8.1.0
pytest==6.2.2
pandas==1.1.0 # used in serving_test_gen
pillow==8.1.0
pip-licenses==3.1.0 # fetch licenses
pytest-cov==2.10.1
pytest==6.2.2
tenacity==6.3.1 # tenacity - used for smart retrying
tox<4.0.0
grpcio-tools==1.33.2
mypy-protobuf==1.22

# tenacity - used for smart retrying
tenacity==6.3.1

# 2nd lvl dep on cov required to avoid sqllite dep
coverage==5.3.1

# Used in serving_test_gen
pandas==1.1.0

# Fetch licenses
pip-licenses==3.1.0
1 change: 1 addition & 0 deletions python/seldon_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from seldon_core.version import __version__

from .storage import Storage
5 changes: 3 additions & 2 deletions python/seldon_core/api_tester.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import argparse
import json
from seldon_core.seldon_client import SeldonClient
from seldon_core.microservice_tester import unfold_contract, generate_batch
import logging

from seldon_core.microservice_tester import generate_batch, unfold_contract
from seldon_core.seldon_client import SeldonClient


def get_seldon_client(args) -> SeldonClient:
"""
Expand Down
7 changes: 4 additions & 3 deletions python/seldon_core/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os
import logging
import atexit

import logging
import os
from multiprocessing.util import _exit_function
from typing import Dict, Union

from gunicorn.app.base import BaseApplication

from seldon_core.utils import setup_tracing

logger = logging.getLogger(__name__)
Expand Down
16 changes: 9 additions & 7 deletions python/seldon_core/batch_processor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import click
import json
import requests
from queue import Queue, Empty
from threading import Thread, Event
from seldon_core.seldon_client import SeldonClient
import numpy as np
import logging
import uuid
import time
import uuid
from queue import Empty, Queue
from threading import Event, Thread

import click
import numpy as np
import requests

from seldon_core.seldon_client import SeldonClient

CHOICES_GATEWAY_TYPE = ["ambassador", "istio", "seldon"]
CHOICES_TRANSPORT = ["rest", "grpc"]
Expand Down
8 changes: 5 additions & 3 deletions python/seldon_core/flask_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import json
import base64

import json
from http import HTTPStatus
from flask import request, current_app, jsonify as flask_jsonify
from typing import Dict, Union

from flask import current_app
from flask import jsonify as flask_jsonify
from flask import request


def get_multi_form_data_request() -> Dict:
"""
Expand Down
6 changes: 2 additions & 4 deletions python/seldon_core/metadata.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import os
import json
import logging

import os
from typing import Dict

from seldon_core.metrics import split_image_tag

from jsonschema import validate
from jsonschema.exceptions import ValidationError

from seldon_core.metrics import split_image_tag

logger = logging.getLogger(__name__)

Expand Down
25 changes: 11 additions & 14 deletions python/seldon_core/metrics.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import json
import logging
import os
from multiprocessing import Manager
from typing import Dict, List, Tuple

import numpy as np
from prometheus_client import exposition
from prometheus_client.core import (
HistogramMetricFamily,
GaugeMetricFamily,
CounterMetricFamily,
CollectorRegistry,
CounterMetricFamily,
GaugeMetricFamily,
HistogramMetricFamily,
)
from prometheus_client import exposition
from prometheus_client.utils import floatToGoString

from multiprocessing import Manager

import numpy as np

from typing import List, Dict, Tuple
import logging
import json
import os


logger = logging.getLogger(__name__)

NONIMPLEMENTED_MSG = "NOT_IMPLEMENTED"
Expand Down
20 changes: 10 additions & 10 deletions python/seldon_core/microservice.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import argparse
import os
import importlib
import json
import time
import logging
import multiprocessing as mp
import threading
import os
import sys

from typing import Dict, Callable
import threading
import time
from distutils.util import strtobool
from typing import Callable, Dict

from seldon_core import persistence, __version__, wrapper as seldon_microservice
from seldon_core.metrics import SeldonMetrics
from seldon_core.flask_utils import ANNOTATIONS_FILE, SeldonMicroserviceException
from seldon_core.utils import getenv_as_bool, setup_tracing
from seldon_core import __version__, persistence
from seldon_core import wrapper as seldon_microservice
from seldon_core.app import (
StandaloneApplication,
UserModelApplication,
accesslog,
threads,
post_worker_init,
threads,
)
from seldon_core.flask_utils import ANNOTATIONS_FILE, SeldonMicroserviceException
from seldon_core.metrics import SeldonMetrics
from seldon_core.utils import getenv_as_bool, setup_tracing

logger = logging.getLogger(__name__)

Expand Down
8 changes: 5 additions & 3 deletions python/seldon_core/microservice_tester.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import argparse
import numpy as np
import json
from typing import Dict, List, Union, Tuple
import logging
from typing import Dict, List, Tuple, Union

import numpy as np
from numpy.core.multiarray import ndarray

from seldon_core.seldon_client import SeldonClient
import logging


class SeldonTesterException(Exception):
Expand Down
10 changes: 6 additions & 4 deletions python/seldon_core/persistence.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import threading
import os
import time
import logging
import os
import pickle
import threading
import time
from typing import Dict, Type

import redis

from seldon_core.user_model import SeldonComponent
from typing import Dict, Type

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

if _TF_PRESENT:
# Let tensorflow shadow these imports if present
from tensorflow.core.framework import tensor_pb2, types_pb2, tensor_shape_pb2
from tensorflow.core.framework import tensor_pb2, tensor_shape_pb2, types_pb2
25 changes: 13 additions & 12 deletions python/seldon_core/seldon_client.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
from seldon_core.proto import prediction_pb2
from seldon_core.proto import prediction_pb2_grpc
import http.client as http_client
import json
import logging
from typing import Dict, Iterable, List, Optional, Tuple, Union

import grpc
import numpy as np
import requests
from google.protobuf import any_pb2, json_format

from seldon_core.proto import prediction_pb2, prediction_pb2_grpc
from seldon_core.utils import (
array_to_grpc_datadef,
seldon_message_to_json,
feedback_to_json,
json_to_feedback,
json_to_seldon_message,
feedback_to_json,
seldon_message_to_json,
seldon_messages_to_json,
)
import numpy as np
import grpc
import requests
from typing import Tuple, Dict, Union, List, Optional, Iterable
import json
import logging
import http.client as http_client
from google.protobuf import any_pb2, json_format

logger = logging.getLogger(__name__)

Expand Down
64 changes: 33 additions & 31 deletions python/seldon_core/seldon_methods.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
import logging
import os
from typing import Any, Dict, List, Tuple, Union

import numpy as np
import yaml
import logging
from seldon_core.utils import (
extract_request_parts,
construct_response,
json_to_seldon_message,
seldon_message_to_json,
construct_response_json,
extract_request_parts_json,
extract_feedback_request_parts,
getenv_as_bool,
from google.protobuf import json_format

from seldon_core.flask_utils import SeldonMicroserviceException
from seldon_core.metadata import SeldonInvalidMetadataError, validate_model_metadata
from seldon_core.metrics import (
AGGREGATE_METRIC_METHOD_TAG,
FEEDBACK_METRIC_METHOD_TAG,
HEALTH_METRIC_METHOD_TAG,
INPUT_TRANSFORM_METRIC_METHOD_TAG,
OUTPUT_TRANSFORM_METRIC_METHOD_TAG,
PREDICT_METRIC_METHOD_TAG,
ROUTER_METRIC_METHOD_TAG,
SeldonMetrics,
)
from seldon_core.proto import prediction_pb2
from seldon_core.user_model import (
INCLUDE_METRICS_IN_CLIENT_RESPONSE,
SeldonNotImplementedError,
SeldonResponse,
client_predict,
client_aggregate,
client_route,
client_custom_metrics,
client_transform_output,
client_transform_input,
client_send_feedback,
client_health_status,
SeldonNotImplementedError,
client_predict,
client_route,
client_send_feedback,
client_transform_input,
client_transform_output,
)
from seldon_core.flask_utils import SeldonMicroserviceException
from seldon_core.metrics import (
SeldonMetrics,
FEEDBACK_METRIC_METHOD_TAG,
PREDICT_METRIC_METHOD_TAG,
INPUT_TRANSFORM_METRIC_METHOD_TAG,
OUTPUT_TRANSFORM_METRIC_METHOD_TAG,
ROUTER_METRIC_METHOD_TAG,
AGGREGATE_METRIC_METHOD_TAG,
HEALTH_METRIC_METHOD_TAG,
from seldon_core.utils import (
construct_response,
construct_response_json,
extract_feedback_request_parts,
extract_request_parts,
extract_request_parts_json,
getenv_as_bool,
json_to_seldon_message,
seldon_message_to_json,
)
from seldon_core.metadata import validate_model_metadata, SeldonInvalidMetadataError
from google.protobuf import json_format
from seldon_core.proto import prediction_pb2
from typing import Any, Union, List, Dict, Tuple
import numpy as np

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion python/seldon_core/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import glob
import logging
import tempfile
import os
import tempfile

_LOCAL_PREFIX = "file://"

Expand Down
15 changes: 8 additions & 7 deletions python/seldon_core/user_model.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from seldon_core.metrics import validate_metrics
from seldon_core.flask_utils import SeldonMicroserviceException
import json
from typing import Dict, List, Union, Iterable, Tuple
import numpy as np
from seldon_core.proto import prediction_pb2
from seldon_core.metrics import SeldonMetrics
import inspect
import json
import logging
import os
from typing import Dict, Iterable, List, Tuple, Union

import numpy as np

from seldon_core.flask_utils import SeldonMicroserviceException
from seldon_core.metrics import SeldonMetrics, validate_metrics
from seldon_core.proto import prediction_pb2

logger = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit 5ecbf9c

Please sign in to comment.