Skip to content

Commit c77eba6

Browse files
authored
Drop pre/post process from templates (#279)
* Drop pre/post process from templates * Bump version
1 parent 87a30f1 commit c77eba6

File tree

11 files changed

+3
-143
lines changed

11 files changed

+3
-143
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "truss"
3-
version = "0.4.4"
3+
version = "0.4.5"
44
description = "A seamless bridge from model development to model delivery"
55
license = "MIT"
66
readme = "README.md"

truss/templates/custom/model/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ def load(self):
1212
# Load model here and assign to self._model.
1313
pass
1414

15-
def preprocess(self, model_input: Any) -> Any:
16-
"""
17-
Incorporate pre-processing required by the model if desired here.
18-
19-
These might be feature transformations that are tightly coupled to the model.
20-
"""
21-
return model_input
22-
23-
def postprocess(self, model_output: Any) -> Any:
24-
"""
25-
Incorporate post-processing required by the model if desired here.
26-
"""
27-
return model_output
28-
2915
def predict(self, model_input: Any) -> Any:
3016
model_output = {}
3117
# Invoke model on model_input and calculate predictions here.

truss/templates/huggingface_transformer/model/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,6 @@ def load(self):
2727
**transformer_config,
2828
)
2929

30-
def preprocess(self, model_input: Any) -> Any:
31-
"""
32-
Incorporate pre-processing required by the model if desired here.
33-
34-
These might be feature transformations that are tightly coupled to the model.
35-
"""
36-
return model_input
37-
38-
def postprocess(self, model_output: Any) -> Any:
39-
"""
40-
Incorporate post-processing required by the model if desired here.
41-
"""
42-
return model_output
43-
4430
def predict(self, model_input: Any) -> Any:
4531
model_output = {}
4632
instances = model_input

truss/templates/keras/model/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,6 @@ def load(self):
1717
str(self._data_dir / self._model_binary_dir)
1818
)
1919

20-
def preprocess(self, model_input: Any) -> Any:
21-
"""
22-
Incorporate pre-processing required by the model if desired here.
23-
24-
These might be feature transformations that are tightly coupled to the model.
25-
"""
26-
return model_input
27-
28-
def postprocess(self, model_output: Any) -> Any:
29-
"""
30-
Incorporate post-processing required by the model if desired here.
31-
"""
32-
return model_output
33-
3420
def predict(self, model_input: Any) -> Any:
3521
model_output = {}
3622
inputs = np.array(model_input)

truss/templates/lightgbm/model/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ def load(self):
2525
model_file_path = next(path for path in paths if path.exists())
2626
self._model = joblib.load(model_file_path)
2727

28-
def preprocess(self, model_input: Any) -> Any:
29-
"""
30-
Incorporate pre-processing required by the model if desired here.
31-
32-
These might be feature transformations that are tightly coupled to the model.
33-
"""
34-
return model_input
35-
36-
def postprocess(self, model_output: Any) -> Any:
37-
"""
38-
Incorporate post-processing required by the model if desired here.
39-
"""
40-
return model_output
41-
4228
def predict(self, model_input: Any) -> Any:
4329
model_output = {}
4430
result = self._model.predict(model_input)

truss/templates/mlflow/model/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@ def load(self):
1616
model_binary_dir_path = self._data_dir / self._model_binary_dir
1717
self._model = mlflow.pyfunc.load_model(model_binary_dir_path / "model")
1818

19-
def preprocess(self, model_input: Any) -> Any:
20-
"""
21-
Incorporate pre-processing required by the model if desired here.
22-
23-
These might be feature transformations that are tightly coupled to the model.
24-
"""
25-
return model_input
26-
27-
def postprocess(self, model_output: Any) -> Any:
28-
"""
29-
Incorporate post-processing required by the model if desired here.
30-
"""
31-
return model_output
32-
3319
def predict(self, model_input: Any) -> Any:
3420
model_output = {}
3521
inputs = np.array(model_input)

truss/templates/pipeline/model/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,5 @@ def load(self):
1212
with open(self._data_dir / "pipeline.cpick", "rb") as f:
1313
self._pipeline = pickle.load(f)
1414

15-
def preprocess(self, model_input: Any) -> Any:
16-
"""
17-
Incorporate pre-processing required by the model if desired here.
18-
19-
These might be feature transformations that are tightly coupled to the model.
20-
"""
21-
return model_input
22-
23-
def postprocess(self, model_output: Any) -> Any:
24-
"""
25-
Incorporate post-processing required by the model if desired here.
26-
"""
27-
return model_output
28-
2915
def predict(self, model_input: Any) -> Any:
3016
return self._pipeline(model_input)

truss/templates/pytorch/model/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ def load(self):
2626
self._model = imp.load_pickle(package_name, model_pickle_filename)
2727
self._model_dtype = list(self._model.parameters())[0].dtype
2828

29-
def preprocess(self, model_input: Any) -> Any:
30-
"""
31-
Incorporate pre-processing required by the model if desired here.
32-
33-
These might be feature transformations that are tightly coupled to the model.
34-
"""
35-
return model_input
36-
37-
def postprocess(self, model_output: Any) -> Any:
38-
"""
39-
Incorporate post-processing required by the model if desired here.
40-
"""
41-
return model_output
42-
4329
def predict(self, model_input: Any) -> Any:
4430
model_output = {}
4531
with torch.no_grad():

truss/templates/sklearn/model/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,6 @@ def load(self):
2424
model_file_path = next(path for path in paths if path.exists())
2525
self._model = joblib.load(model_file_path)
2626

27-
def preprocess(self, model_input: Any) -> Any:
28-
"""
29-
Incorporate pre-processing required by the model if desired here.
30-
31-
These might be feature transformations that are tightly coupled to the model.
32-
"""
33-
return model_input
34-
35-
def postprocess(self, model_output: Any) -> Any:
36-
"""
37-
Incorporate post-processing required by the model if desired here.
38-
"""
39-
return model_output
40-
4127
def predict(self, model_input: Any) -> Any:
4228
model_output = {}
4329
result = self._model.predict(model_input)

truss/templates/xgboost/model/model.py

-14
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ def load(self):
3131
self._model = xgb.Booster()
3232
self._model.load_model(model_file_path)
3333

34-
def preprocess(self, model_input: Any) -> Any:
35-
"""
36-
Incorporate pre-processing required by the model if desired here.
37-
38-
These might be feature transformations that are tightly coupled to the model.
39-
"""
40-
return model_input
41-
42-
def postprocess(self, model_output: Any) -> Any:
43-
"""
44-
Incorporate post-processing required by the model if desired here.
45-
"""
46-
return model_output
47-
4834
def predict(self, model_input: Any) -> Any:
4935
model_output = {}
5036
dmatrix_inputs = xgb.DMatrix(model_input)

truss/test_data/test_truss/model/model.py

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List
1+
from typing import Any
22

33

44
class Model:
@@ -12,21 +12,7 @@ def load(self):
1212
# Load model here and assign to self._model.
1313
pass
1414

15-
def preprocess(self, model_input: Any) -> Any:
16-
"""
17-
Incorporate pre-processing required by the model if desired here.
18-
19-
These might be feature transformations that are tightly coupled to the model.
20-
"""
21-
return model_input
22-
23-
def postprocess(self, model_output: Dict) -> Dict:
24-
"""
25-
Incorporate post-processing required by the model if desired here.
26-
"""
27-
return model_output
28-
29-
def predict(self, model_input: Dict) -> Dict[str, List]:
15+
def predict(self, model_input: Any) -> Any:
3016
model_output = {}
3117
# Invoke model on model_input and calculate predictions here.
3218
model_output["predictions"] = []

0 commit comments

Comments
 (0)