Skip to content

Commit 68d7418

Browse files
fix(ensembler): Remove all pipenv usage (caraml-dev#412)
* Remove all pipenv usages * Loosen numpy requirement * Remove legacy ensembler test * Fix ensembler service test
1 parent 9a53d9f commit 68d7418

File tree

5 files changed

+18
-27
lines changed

5 files changed

+18
-27
lines changed

engines/pyfunc-ensembler-job/Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ setup: build
1010
@DIST_VERSION=$$(echo $(VERSION) | \
1111
sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+)(-rc([0-9]+))?/\1rc\3/'); \
1212
$(ACTIVATE_ENV) && pip install "dist/turing_pyfunc_ensembler_job-$${DIST_VERSION}-py3-none-any.whl[dev]"
13-
@pip install pipenv
1413

1514
.PHONY: type-check
1615
type-check:
17-
@pipenv run mypy --ignore-missing-imports --allow-untyped-globals --implicit-optional ensembler --follow-imports silent
16+
@$(ACTIVATE_ENV) && mypy \
17+
--install-types \
18+
--non-interactive \
19+
--ignore-missing-imports \
20+
--allow-untyped-globals \
21+
ensembler
1822

1923
.PHONY: lint
2024
lint:
@@ -24,7 +28,11 @@ lint:
2428

2529
.PHONY: test
2630
test: type-check
27-
@pipenv run pytest -W ignore
31+
@$(ACTIVATE_ENV) && \
32+
python -m pytest \
33+
--cov=ensembler \
34+
--ignore=env \
35+
-W ignore
2836

2937
.PHONY: build-image
3038
build-image: version

engines/pyfunc-ensembler-job/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cloudpickle==2.0.0
22
google-cloud-storage>=1.37.0
33
jinjasql==0.1.8
44
jinja2==3.0.3
5-
numpy==1.22.0
5+
numpy>=1.22.0
66
pandas==1.3.5
77
py4j==0.10.9
88
pyarrow>=0.14.1,<=9.0.0

engines/pyfunc-ensembler-service/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ setup: build
1010
@DIST_VERSION=$$(echo $(VERSION) | \
1111
sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+)(-rc([0-9]+))?/\1rc\3/'); \
1212
$(ACTIVATE_ENV) && pip install "dist/turing_pyfunc_ensembler_service-$${DIST_VERSION}-py3-none-any.whl[dev]"
13-
@pip install pipenv
1413

1514
.PHONY: lint
1615
lint:
@@ -20,7 +19,11 @@ lint:
2019

2120
.PHONY: test
2221
test:
23-
@pipenv run pytest -W ignore
22+
@$(ACTIVATE_ENV) && \
23+
python -m pytest \
24+
--cov=pyfunc_ensembler_runner \
25+
--cov-report term-missing \
26+
-W ignore
2427

2528
.PHONY: build-image
2629
build-image: version

engines/pyfunc-ensembler-service/tests/conftest.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@ def ensemble(
1717
return kwargs
1818

1919

20-
class LegacyEnsembler(PyFunc):
21-
def initialize(self, artifacts: Dict):
22-
pass
23-
24-
def ensemble(self, input: Dict, predictions: Dict, treatment_config: Dict) -> Any:
25-
if treatment_config["configuration"]["name"] == "choose_the_control":
26-
return predictions["control"]["data"]["predictions"]
27-
else:
28-
return [0, 0]
29-
30-
3120
def get_ensembler_path(model):
3221
import os
3322
import mlflow
@@ -49,8 +38,3 @@ def get_ensembler_path(model):
4938
@pytest.fixture
5039
def simple_ensembler_uri():
5140
return get_ensembler_path(TestEnsembler())
52-
53-
54-
@pytest.fixture
55-
def legacy_ensembler_uri():
56-
return get_ensembler_path(LegacyEnsembler())

engines/pyfunc-ensembler-service/tests/test_ensembler_runner.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
"simple_ensembler_uri",
2828
dummy_short_request,
2929
{"Key": "Value"},
30-
{"headers": {"Key": "Value"}},
31-
),
32-
pytest.param("legacy_ensembler_uri", dummy_long_request, {}, [296.15732, 0]),
33-
pytest.param(
34-
"legacy_ensembler_uri", dummy_short_request, {"Key": "Value"}, [0, 0]
30+
{"headers": {"Key": "Value"}, "enricher_response" : None},
3531
),
3632
],
3733
)

0 commit comments

Comments
 (0)