Skip to content

Commit

Permalink
run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
mwm5945 committed Jun 20, 2023
1 parent b2132f7 commit 9304727
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"import tensorflow as tf\n",
"\n",
"if __name__ == \"__main__\":\n",
"\n",
" x = tf.placeholder(tf.float32, [None, 784], name=\"x\")\n",
"\n",
" W = tf.Variable(tf.zeros([784, 10]))\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"import tensorflow as tf\n",
"\n",
"if __name__ == \"__main__\":\n",
"\n",
" x = tf.placeholder(tf.float32, [None, 784], name=\"x\")\n",
"\n",
" W = tf.Variable(tf.zeros([784, 10]))\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"import tensorflow as tf\n",
"\n",
"if __name__ == \"__main__\":\n",
"\n",
" x = tf.placeholder(tf.float32, [None, 784], name=\"x\")\n",
"\n",
" W = tf.Variable(tf.zeros([784, 10]))\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@
"import tensorflow as tf\n",
"\n",
"if __name__ == \"__main__\":\n",
"\n",
" x = tf.placeholder(tf.float32, [None, 784], name=\"x\")\n",
"\n",
" W = tf.Variable(tf.zeros([784, 10]))\n",
Expand Down
6 changes: 3 additions & 3 deletions operator/hack/csv_hack.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def update_container_image(csv, version):
][0]["env"]
):
if env["name"] == "EXECUTOR_CONTAINER_IMAGE_AND_VERSION":
csv["spec"]["install"]["spec"]["deployments"][0]["spec"]["template"]["spec"][
"containers"
][0]["env"][n]["value"] = (
csv["spec"]["install"]["spec"]["deployments"][0]["spec"]["template"][
"spec"
]["containers"][0]["env"][n]["value"] = (
"docker.io/seldonio/seldon-core-executor:" + version
)
return csv
Expand Down
84 changes: 45 additions & 39 deletions operator/helm/split_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import yaml

parser = argparse.ArgumentParser()
parser.add_argument("--prefix", default="xx",
help="find files matching prefix")
parser.add_argument("--prefix", default="xx", help="find files matching prefix")
parser.add_argument("--folder", required=True, help="Output folder")
args, _ = parser.parse_known_args()

Expand All @@ -30,11 +29,13 @@
HELM_CREATERESOURCES_RBAC_IF_START = "{{- if .Values.managerCreateResources }}\n"
HELM_K8S_V1_CRD_IF_START = '{{- if or (ge (int (regexFind "[0-9]+" .Capabilities.KubeVersion.Minor)) 18) (.Values.crd.forcev1) }}\n'
HELM_K8S_V1BETA1_CRD_IF_START = '{{- if or (lt (int (regexFind "[0-9]+" .Capabilities.KubeVersion.Minor)) 18) (.Values.crd.forcev1beta1) }}\n'
HELM_CRD_ANNOTATIONS_WITH_START = '{{- with .Values.crd.annotations }}\n'
HELM_ANNOTATIONS_TOYAML4 = '{{- toYaml . | nindent 4}}\n'
HELM_ANNOTATIONS_TOYAML8 = '{{- toYaml . | nindent 8}}\n'
HELM_CONTROLER_DEP_ANNOTATIONS_WITH_START = '{{- with .Values.manager.annotations }}\n'
HELM_CONTROLER_DEP_POD_SEC_CTX_WITH_START = '{{- with .Values.manager.containerSecurityContext }}\n'
HELM_CRD_ANNOTATIONS_WITH_START = "{{- with .Values.crd.annotations }}\n"
HELM_ANNOTATIONS_TOYAML4 = "{{- toYaml . | nindent 4}}\n"
HELM_ANNOTATIONS_TOYAML8 = "{{- toYaml . | nindent 8}}\n"
HELM_CONTROLER_DEP_ANNOTATIONS_WITH_START = "{{- with .Values.manager.annotations }}\n"
HELM_CONTROLER_DEP_POD_SEC_CTX_WITH_START = (
"{{- with .Values.manager.containerSecurityContext }}\n"
)
HELM_IF_END = "{{- end }}\n"

HELM_ENV_SUBST = {
Expand Down Expand Up @@ -71,7 +72,7 @@
"EXECUTOR_REQUEST_LOGGER_WORK_QUEUE_SIZE": "executor.requestLogger.workQueueSize",
"EXECUTOR_REQUEST_LOGGER_WRITE_TIMEOUT_MS": "executor.requestLogger.writeTimeoutMs",
"DEPLOYMENT_NAME_AS_PREFIX": "manager.deploymentNameAsPrefix",
"EXECUTOR_FULL_HEALTH_CHECKS": "executor.fullHealthChecks"
"EXECUTOR_FULL_HEALTH_CHECKS": "executor.fullHealthChecks",
}
HELM_VALUES_IMAGE_PULL_POLICY = "{{ .Values.image.pullPolicy }}"

Expand Down Expand Up @@ -100,8 +101,7 @@ def helm_namespace_override():
webhookData
+ '{{- $altNames := list ( printf "seldon-webhook-service.%s" (include "seldon.namespace" .) ) ( printf "seldon-webhook-service.%s.svc" (include "seldon.namespace" .) ) -}}\n'
)
webhookData = webhookData + \
'{{- $ca := genCA "custom-metrics-ca" 365 -}}\n'
webhookData = webhookData + '{{- $ca := genCA "custom-metrics-ca" 365 -}}\n'
webhookData = (
webhookData
+ '{{- $cert := genSignedCert "seldon-webhook-service" nil $altNames 365 $ca -}}\n'
Expand All @@ -113,8 +113,7 @@ def helm_namespace_override():
kind = res["kind"].lower()
name = res["metadata"]["name"].lower()
version = res["apiVersion"]
filename = args.folder + "/" + \
(kind + "_" + name).lower() + ".yaml"
filename = args.folder + "/" + (kind + "_" + name).lower() + ".yaml"
print(filename)
print(version)
if (
Expand Down Expand Up @@ -173,7 +172,9 @@ def helm_namespace_override():
] = helm_value("managerUserID")

# Priority class name
res["spec"]["template"]["spec"]["priorityClassName"] = helm_value("manager.priorityClassName")
res["spec"]["template"]["spec"]["priorityClassName"] = helm_value(
"manager.priorityClassName"
)

# Resource requests
res["spec"]["template"]["spec"]["containers"][0]["resources"][
Expand Down Expand Up @@ -206,8 +207,7 @@ def helm_namespace_override():
if portSpec["name"] == "webhook-server":
portSpec["containerPort"] = helm_value("webhook.port")
for argIdx in range(
0, len(res["spec"]["template"]["spec"]
["containers"][0]["args"])
0, len(res["spec"]["template"]["spec"]["containers"][0]["args"])
):
if (
res["spec"]["template"]["spec"]["containers"][0]["args"][argIdx]
Expand All @@ -221,16 +221,17 @@ def helm_namespace_override():
)

# Update metrics port
res["spec"]["template"]["metadata"]["annotations"]["prometheus.io/port"] = helm_value("metrics.port")
res["spec"]["template"]["metadata"]["annotations"][
"prometheus.io/port"
] = helm_value("metrics.port")
for portSpec in res["spec"]["template"]["spec"]["containers"][0][
"ports"
]:
if portSpec["name"] == "metrics":
portSpec["containerPort"] = helm_value("metrics.port")

for argIdx in range(
0, len(res["spec"]["template"]["spec"]
["containers"][0]["args"])
0, len(res["spec"]["template"]["spec"]["containers"][0]["args"])
):
if (
res["spec"]["template"]["spec"]["containers"][0]["args"][argIdx]
Expand All @@ -241,12 +242,13 @@ def helm_namespace_override():
] = "--metrics-addr=:" + helm_value("metrics.port")

# Networking
res["spec"]["template"]["spec"]["hostNetwork"] = helm_value("hostNetwork")
res["spec"]["template"]["spec"]["hostNetwork"] = helm_value(
"hostNetwork"
)

if kind == "configmap" and name == "seldon-config":
res["data"]["credentials"] = helm_value_json("credentials")
res["data"]["predictor_servers"] = helm_value_json(
"predictor_servers")
res["data"]["predictor_servers"] = helm_value_json("predictor_servers")
res["data"]["storageInitializer"] = helm_value_json(
"storageInitializer"
)
Expand All @@ -269,8 +271,7 @@ def helm_namespace_override():
res["roleRef"]["name"] + "-" + helm_namespace_override()
)
if name == "seldon-manager-rolebinding":
res["subjects"][0]["name"] = helm_value(
"serviceAccount.name")
res["subjects"][0]["name"] = helm_value("serviceAccount.name")
res["subjects"][0]["namespace"] = helm_namespace_override()
elif name != "seldon-spartakus-volunteer":
res["subjects"][0]["namespace"] = helm_namespace_override()
Expand All @@ -283,8 +284,7 @@ def helm_namespace_override():
or name == "seldon1-manager-sas-rolebinding"
or name == "seldon-leader-election-rolebinding"
):
res["subjects"][0]["name"] = helm_value(
"serviceAccount.name")
res["subjects"][0]["name"] = helm_value("serviceAccount.name")
res["subjects"][0]["namespace"] = helm_namespace_override()

# Update webhook certificates
Expand Down Expand Up @@ -333,8 +333,7 @@ def helm_namespace_override():

# Update webhook service port
if kind == "service" and name == "seldon-webhook-service":
res["spec"]["ports"][0]["targetPort"] = helm_value(
"webhook.port")
res["spec"]["ports"][0]["targetPort"] = helm_value("webhook.port")

fdata = yaml.dump(res, width=1000)

Expand Down Expand Up @@ -427,8 +426,10 @@ def helm_namespace_override():
+ HELM_K8S_V1BETA1_CRD_IF_START
+ re.sub(
r"(.*controller-gen.kubebuilder.io/version.*\n)",
r"\1" + HELM_CRD_ANNOTATIONS_WITH_START +
HELM_ANNOTATIONS_TOYAML4 + HELM_IF_END,
r"\1"
+ HELM_CRD_ANNOTATIONS_WITH_START
+ HELM_ANNOTATIONS_TOYAML4
+ HELM_IF_END,
fdata,
re.M,
)
Expand All @@ -444,8 +445,10 @@ def helm_namespace_override():
+ HELM_K8S_V1_CRD_IF_START
+ re.sub(
r"(.*controller-gen.kubebuilder.io/version.*\n)",
r"\1" + HELM_CRD_ANNOTATIONS_WITH_START +
HELM_ANNOTATIONS_TOYAML4 + HELM_IF_END,
r"\1"
+ HELM_CRD_ANNOTATIONS_WITH_START
+ HELM_ANNOTATIONS_TOYAML4
+ HELM_IF_END,
fdata,
re.M,
)
Expand All @@ -459,8 +462,10 @@ def helm_namespace_override():
elif kind == "deployment" and name == "seldon-controller-manager":
fdata = re.sub(
r"(.*template:\n.*metadata:\n.*annotations:\n)",
r"\1" + HELM_CONTROLER_DEP_ANNOTATIONS_WITH_START +
HELM_ANNOTATIONS_TOYAML8 + HELM_IF_END,
r"\1"
+ HELM_CONTROLER_DEP_ANNOTATIONS_WITH_START
+ HELM_ANNOTATIONS_TOYAML8
+ HELM_IF_END,
fdata,
re.M,
)
Expand All @@ -480,8 +485,10 @@ def helm_namespace_override():

fdata = re.sub(
r"(.*command:\n)",
HELM_CONTROLER_DEP_POD_SEC_CTX_WITH_START +
HELM_ANNOTATIONS_TOYAML8 + HELM_IF_END + r"\1",
HELM_CONTROLER_DEP_POD_SEC_CTX_WITH_START
+ HELM_ANNOTATIONS_TOYAML8
+ HELM_IF_END
+ r"\1",
fdata,
re.M,
)
Expand All @@ -492,7 +499,8 @@ def helm_namespace_override():
)
# make sure metrics.port is not quoted as its an int
fdata = fdata.replace(
"containerPort: '{{ .Values.metrics.port }}'", "containerPort: {{ .Values.metrics.port }}"
"containerPort: '{{ .Values.metrics.port }}'",
"containerPort: {{ .Values.metrics.port }}",
)
# make sure webhook is not quoted as its an int
fdata = fdata.replace(
Expand Down Expand Up @@ -538,9 +546,7 @@ def helm_namespace_override():
)
webhookData = re.sub(
r"(.*caBundle:.*\n)",
HELM_NOT_CERTMANAGER_IF_START
+ r"\1"
+ HELM_IF_END,
HELM_NOT_CERTMANAGER_IF_START + r"\1" + HELM_IF_END,
webhookData,
re.M,
)
Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import find_packages, setup

# Extra dependencies, with special 'tensorflow' key. TF requires a specific versio of
# Extra dependencies, with special 'tensorflow' key. TF requires a specific versio of
# proto to be installed to use their protos.
extras = {"tensorflow": ["tensorflow", "protobuf>=3.20.2,<4.0.0"]}
all_extra_deps = chain.from_iterable(extras.values())
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_application_exception_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def to_dict(self):


class UserObject(SeldonComponent):

model_error_handler = flask.Blueprint("error_handlers", __name__)

@model_error_handler.app_errorhandler(UserCustomException)
Expand All @@ -56,7 +55,6 @@ def predict(self, X, features_names, **kwargs):


class UserObjectLowLevel(SeldonComponent):

model_error_handler = flask.Blueprint("error_handlers", __name__)

@model_error_handler.app_errorhandler(UserCustomException)
Expand Down
1 change: 0 additions & 1 deletion python/tests/test_combiner_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def aggregate_rest(self, Xs):
def aggregate_grpc(
self, request: Union[prediction_pb2.SeldonMessage, List, Dict]
) -> Union[prediction_pb2.SeldonMessage, List, Dict]:

is_proto = isinstance(request, prediction_pb2.SeldonMessage)

arr = np.array([9, 9])
Expand Down
1 change: 0 additions & 1 deletion python/tests/test_router_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def __init__(self, metrics_ok=True, ret_nparray=False):
def route_raw(
self, request: Union[prediction_pb2.SeldonMessage, List, Dict]
) -> Union[prediction_pb2.SeldonMessage, List, Dict]:

is_proto = isinstance(request, prediction_pb2.SeldonMessage)

arr = np.array([1])
Expand Down
4 changes: 0 additions & 4 deletions python/tests/test_transformer_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def __init__(self, metrics_ok=True, ret_nparray=False):
def transform_input_raw(
self, request: Union[prediction_pb2.SeldonMessage, List, Dict]
) -> Union[prediction_pb2.SeldonMessage, List, Dict]:

is_proto = isinstance(request, prediction_pb2.SeldonMessage)

arr = np.array([9, 9])
Expand All @@ -131,7 +130,6 @@ def transform_input_raw(
def transform_output_raw(
self, request: Union[prediction_pb2.SeldonMessage, List, Dict]
) -> Union[prediction_pb2.SeldonMessage, List, Dict]:

is_proto = isinstance(request, prediction_pb2.SeldonMessage)

arr = np.array([9, 9])
Expand All @@ -155,7 +153,6 @@ def __init__(self, metrics_ok=True, ret_nparray=False):
def transform_input_raw(
self, request: Union[prediction_pb2.SeldonMessage, List, Dict]
) -> Union[prediction_pb2.SeldonMessage, List, Dict]:

is_proto = isinstance(request, prediction_pb2.SeldonMessage)

arr = np.array([9, 9])
Expand All @@ -171,7 +168,6 @@ def transform_input_raw(
def transform_output_raw(
self, request: Union[prediction_pb2.SeldonMessage, List, Dict]
) -> Union[prediction_pb2.SeldonMessage, List, Dict]:

is_proto = isinstance(request, prediction_pb2.SeldonMessage)

arr = np.array([9, 9])
Expand Down
1 change: 0 additions & 1 deletion testing/scripts/e2e_utils/s2i.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
def create_s2i_image(
s2i_folder: str, s2i_image: str, image_name: str, s2i_runtime_image: str = None
) -> str:

logging.info(f"Building {image_name} with s2i...")
if s2i_runtime_image:
s2i.build(s2i_folder, s2i_image, image_name, runtime_image=s2i_runtime_image)
Expand Down
2 changes: 0 additions & 2 deletions testing/scripts/seldon_e2e_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,6 @@ def create_and_run_script(folder, notebook):


def bench_results_from_output_logs(name, namespace="argo", print_results=True):

output = run(
f"argo logs --no-color {name} -n {namespace}",
stdout=subprocess.PIPE,
Expand Down Expand Up @@ -766,7 +765,6 @@ def run_benchmark_and_capture_results(
benchmark_data={"data": {"ndarray": [[1, 2, 3, 4]]}},
benchmark_grpc_data_override="",
):

# Helm chart command requires escaped commas and brackets
data_str = (
json.dumps(benchmark_data)
Expand Down
4 changes: 0 additions & 4 deletions testing/scripts/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
@pytest.mark.benchmark
@pytest.mark.usefixtures("argo_worfklows")
def test_service_orchestrator():

sort_by = ["apiType", "disableOrchestrator"]

data_size = 1_000
Expand Down Expand Up @@ -69,7 +68,6 @@ def test_service_orchestrator():
@pytest.mark.benchmark
@pytest.mark.usefixtures("argo_worfklows")
def test_workers_performance():

sort_by = ["apiType", "serverWorkers"]

data_size = 10
Expand Down Expand Up @@ -99,7 +97,6 @@ def test_workers_performance():
@pytest.mark.benchmark
@pytest.mark.usefixtures("argo_worfklows")
def test_python_wrapper_v1_vs_v2_iris():

sort_by = ["concurrency", "apiType"]
benchmark_concurrency_list = ["1", "50", "150"]

Expand Down Expand Up @@ -218,7 +215,6 @@ def test_python_wrapper_v1_vs_v2_iris():
@pytest.mark.benchmark
@pytest.mark.usefixtures("argo_worfklows")
def test_v1_seldon_data_types():

sort_by = ["concurrency", "apiType"]

# 10000 element array
Expand Down
Loading

0 comments on commit 9304727

Please sign in to comment.