Skip to content

Commit d30c1f8

Browse files
committed
chore: code qual
1 parent 09f75dc commit d30c1f8

File tree

3 files changed

+16
-46
lines changed

3 files changed

+16
-46
lines changed

src/sasctl/core.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,11 @@ def username(self):
571571
def hostname(self):
572572
return self._settings.get("domain")
573573

574-
def send(self, request, **kwargs):
574+
def send(self, req, **kwargs):
575575
if self.message_log.isEnabledFor(logging.DEBUG):
576-
r = copy.deepcopy(request)
577-
for filter in self.filters:
578-
r = filter(r)
576+
r = copy.deepcopy(req)
577+
for filter_ in self.filters:
578+
r = filter_(r)
579579

580580
self.message_log.debug(
581581
"HTTP/1.1 {verb} {url}\n{headers}\nBody:\n{body}".format(
@@ -588,14 +588,14 @@ def send(self, request, **kwargs):
588588
)
589589
)
590590
else:
591-
self.message_log.info("HTTP/1.1 %s %s", request.method, request.url)
591+
self.message_log.info("HTTP/1.1 %s %s", req.method, req.url)
592592

593-
response = super(Session, self).send(request, **kwargs)
593+
response = super(Session, self).send(req, **kwargs)
594594

595595
if self.message_log.isEnabledFor(logging.DEBUG):
596596
r = copy.deepcopy(response)
597-
for filter in self.filters:
598-
r = filter(r)
597+
for filter_ in self.filters:
598+
r = filter_(r)
599599

600600
self.message_log.debug(
601601
"HTTP {status} {url}\n{headers}\nBody:\n{body}".format(

src/sasctl/pzmm/write_json_files.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import importlib
77
import json
88

9-
# import math #not used
109
import pickle
1110
import pickletools
1211
import sys
@@ -1449,13 +1448,6 @@ def stat_dataset_to_dataframe(
14491448
Raised if an improper data format is provided.
14501449
14511450
"""
1452-
# If numpy inputs are supplied, then assume numpy is installed
1453-
try:
1454-
# noinspection PyPackageRequirements
1455-
import numpy as np
1456-
except ImportError:
1457-
np = None
1458-
14591451
# Convert target_value to numeric for creating binary probabilities
14601452
if isinstance(target_value, str):
14611453
target_value = float(target_value)

src/sasctl/utils/model_info.py

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_model_info(model, X, y=None):
6363

6464
# Most PyTorch models are actually subclasses of torch.nn.Module, so checking module
6565
# name alone is not sufficient.
66-
elif torch and isinstance(model, torch.nn.Module):
66+
if torch and isinstance(model, torch.nn.Module):
6767
return PyTorchModelInfo(model, X, y)
6868

6969
raise ValueError(f"Unrecognized model type {type(model)} received.")
@@ -200,7 +200,8 @@ class OnnxModelInfo(ModelInfo):
200200
def __init__(self, model, X, y=None):
201201
if onnx is None:
202202
raise RuntimeError(
203-
"The onnx package must be installed to work with ONNX models. Please `pip install onnx`."
203+
"The onnx package must be installed to work with ONNX models. "
204+
"Please `pip install onnx`."
204205
)
205206

206207
self._model = model
@@ -214,38 +215,19 @@ def __init__(self, model, X, y=None):
214215

215216
if len(inputs) > 1:
216217
warnings.warn(
217-
f"The ONNX model has {len(inputs)} inputs but only the first input will be captured in Model Manager."
218+
f"The ONNX model has {len(inputs)} inputs but only the first input "
219+
f"will be captured in Model Manager."
218220
)
219221

220222
if len(outputs) > 1:
221223
warnings.warn(
222-
f"The ONNX model has {len(outputs)} outputs but only the first input will be captured in Model Manager."
224+
f"The ONNX model has {len(outputs)} outputs but only the first output "
225+
f"will be captured in Model Manager."
223226
)
224227

225228
self._X_df = inputs[0]
226229
self._y_df = outputs[0]
227230

228-
# initializer (static params)
229-
230-
# for field in model.ListFields():
231-
# doc_string
232-
# domain
233-
# metadata_props
234-
# model_author
235-
# model_license
236-
# model_version
237-
# producer_name
238-
# producer_version
239-
# training_info
240-
241-
# irVersion
242-
# producerName
243-
# producerVersion
244-
# opsetImport
245-
246-
# # list of (FieldDescriptor, value)
247-
# fields = model.ListFields()
248-
249231
@staticmethod
250232
def _tensor_to_dataframe(tensor):
251233
"""
@@ -272,7 +254,7 @@ def _tensor_to_dataframe(tensor):
272254
name = tensor.get("name", "Var")
273255
type_ = tensor["type"]
274256

275-
if not "tensorType" in type_:
257+
if "tensorType" not in type_:
276258
raise ValueError(f"Received an unexpected ONNX input type: {type_}.")
277259

278260
dtype = onnx.helper.tensor_dtype_to_np_dtype(type_["tensorType"]["elemType"])
@@ -374,8 +356,6 @@ def __init__(self, model, X, y=None):
374356
raise ValueError(
375357
f"Expected input data to be a numpy array or PyTorch tensor, received {type(X)}."
376358
)
377-
# if X.ndim != 2:
378-
# raise ValueError(f"Expected input date with shape (n_samples, n_dim), received shape {X.shape}.")
379359

380360
# Ensure each input is a PyTorch Tensor
381361
X = tuple(x if isinstance(x, torch.Tensor) else torch.tensor(x) for x in X)
@@ -395,8 +375,6 @@ def __init__(self, model, X, y=None):
395375
)
396376

397377
self._model = model
398-
399-
# TODO: convert X and y to DF with arbitrary names
400378
self._X = X
401379
self._y = y
402380

0 commit comments

Comments
 (0)