Skip to content

Commit

Permalink
add seed to model script
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelizimm committed Dec 6, 2022
1 parent 10d34c8 commit 54f8fb3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
python -m pip install -e .[dev,torch,statsmodels,xgboost]
- name: Run Tests
run: |
pytest -m 'not rsc_test' --cov --cov-report xml
pytest -m 'not rsc_test and not docker' --cov --cov-report xml
- name: Upload coverage
uses: codecov/codecov-action@v2

Expand Down
3 changes: 3 additions & 0 deletions script/setup-docker/docker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import vetiver
import pins
import numpy as np

np.random.seed(500)

X, y = vetiver.get_mock_data()
model = vetiver.get_mock_model().fit(X, y)
Expand Down
4 changes: 2 additions & 2 deletions vetiver/tests/test_prepare_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
DOCKER_URL = "http://0.0.0.0:8080/predict"

pytestmark = pytest.mark.docker # noqa
np.random.seed(500)


def test_predict_sklearn_df_check_ptype():
np.random.seed(500)

X, y = vetiver.mock.get_mock_data()
response = vetiver.predict(endpoint=DOCKER_URL, data=X)

assert isinstance(response, pd.DataFrame), response
assert response.iloc[0, 0] == 54.52
assert response.iloc[0, 0] == 44.47
assert len(response) == 100
13 changes: 8 additions & 5 deletions vetiver/write_docker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import warnings
from pathlib import Path

from .write_fastapi import write_app
from .attach_pkgs import load_pkgs
Expand Down Expand Up @@ -92,14 +93,14 @@ def write_docker(
CMD ["uvicorn", "app.app:api", "--host", "{host}", "--port", "{port}"]
"""

f = open(f"{path}Dockerfile", "x")
f = open(Path(path, "Dockerfile"), "x")
f.write(docker_script)


def prepare_docker(
board,
pin_name: str,
path: str = "",
path: str = "./",
version=None,
rspm_env: bool = False,
host: str = "0.0.0.0",
Expand All @@ -125,8 +126,10 @@ def prepare_docker(
Port to run VetiverAPI from Dockerfile
"""
# urljoin everything

v = VetiverModel.from_pin(board=board, name=pin_name, version=version)
write_app(board=board, pin_name=pin_name, version=version, file=f"{path}app.py")
load_pkgs(v, path=f"{path}vetiver_")
write_app(
board=board, pin_name=pin_name, version=version, file=Path(path, "app.py")
)
load_pkgs(v, path=Path(path, "vetiver_"))
write_docker(path=path, rspm_env=rspm_env, host=host, port=port)

0 comments on commit 54f8fb3

Please sign in to comment.