Skip to content

Commit fbc5d5d

Browse files
committed
pre-commit fixing
1 parent 9772ec1 commit fbc5d5d

16 files changed

Lines changed: 53 additions & 37 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
exclude: "(.*\\.csv)|(^pins/tests/_snapshots)"
3+
exclude: "(.*\\.csv)|(^examples/)"
44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
66
rev: v2.4.0

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ help:
2020
@echo "clean-test - remove test and coverage artifacts"
2121
@echo "lint - check style with flake8"
2222
@echo "test - run tests quickly with the default Python"
23+
@echo "test-rsc - run tests for rsconnect"
2324
@echo "coverage - check code coverage quickly with the default Python"
2425
@echo "docs - generate Sphinx HTML documentation, including API docs"
2526
@echo "cdocs - cleanout previous build & generate Sphinx HTML documentation, including API docs"
@@ -54,6 +55,9 @@ lint:
5455
flake8 vetiver
5556

5657
test: clean-test
58+
pytest -m 'not rsc_test'
59+
60+
test-rsc: clean-test
5761
pytest
5862

5963
coverage:

examples/coffeeratings.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,32 @@
66
from pathlib import Path
77

88
# Load training data
9-
raw = pd.read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-07-07/coffee_ratings.csv')
9+
raw = pd.read_csv(
10+
"https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-07-07/coffee_ratings.csv"
11+
)
1012
df = pd.DataFrame(raw)
11-
coffee = df[["total_cup_points", "aroma", "flavor", "sweetness", "acidity", \
12-
"body", "uniformity", "balance"]].dropna()
13-
14-
X_train, X_test, y_train, y_test = model_selection.train_test_split(coffee.iloc[:,1:],coffee['total_cup_points'],test_size=0.2)
13+
coffee = df[
14+
[
15+
"total_cup_points",
16+
"aroma",
17+
"flavor",
18+
"sweetness",
19+
"acidity",
20+
"body",
21+
"uniformity",
22+
"balance",
23+
]
24+
].dropna()
25+
26+
X_train, X_test, y_train, y_test = model_selection.train_test_split(
27+
coffee.iloc[:, 1:], coffee["total_cup_points"], test_size=0.2
28+
)
1529

1630
# fit model
1731
lr_fit = LinearRegression().fit(X_train, y_train)
1832

1933
# create vetiver model
20-
v = vetiver.VetiverModel(lr_fit, ptype_data=X_train, model_name = "v")
34+
v = vetiver.VetiverModel(lr_fit, ptype_data=X_train, model_name="v")
2135

2236
# version model via pin
2337
from pins import board_folder
@@ -27,12 +41,12 @@
2741
model_board = board_folder(path=path, versioned=True, allow_pickle_read=True)
2842
vetiver_pin_write(board=model_board, model=v)
2943

30-
myapp = vetiver.VetiverAPI(v, check_ptype = True)
44+
myapp = vetiver.VetiverAPI(v, check_ptype=True)
3145
api = myapp.app
3246

3347
# next, run myapp.run() to start API and see visual documentation
3448
# create app.py file that includes pinned VetiverAPI to be deployed
35-
vetiver.vetiver_write_app(model_board, "v", file = path+"app.py")
49+
vetiver.vetiver_write_app(model_board, "v", file=path + "app.py")
3650

3751
# automatically create requirements.txt
3852
vetiver.load_pkgs(model=v, path=path)

examples/coffeeratings/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import pins
33

44
# edited to reflect Docker container path, and allow_pickle_read=True
5-
b = pins.board_folder('/code/app', allow_pickle_read=True)
6-
v = vetiver.vetiver_pin_read(b, 'v', version = '20220415T174503Z-06d9b')
5+
b = pins.board_folder("/code/app", allow_pickle_read=True)
6+
v = vetiver.vetiver_pin_read(b, "v", version="20220415T174503Z-06d9b")
77

88
vetiver_api = vetiver.VetiverAPI(v)
99
api = vetiver_api.app

examples/coffeeratings/vetiver_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ uvicorn==0.17.6
7272
# via vetiver
7373

7474
# manually edited to reflect appropriate versions of packages currently being developed
75-
git+https://github.com/isabelizimm/vetiver-python.git@37dff15a63238b1e6c44788af70473f19c29d83e
75+
git+https://github.com/isabelizimm/vetiver-python.git@37dff15a63238b1e6c44788af70473f19c29d83e

vetiver/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from .handlers.base import BaseHandler, create_handler, InvalidModelError # noqa
1515
from .handlers.sklearn import SKLearnHandler # noqa
1616
from .handlers.torch import TorchHandler # noqa
17-
from .rsconnect import deploy_rsconnect # noqa
18-
from .monitor import compute_metrics, pin_metrics, plot_metrics, _rolling_df # noqa
17+
from .rsconnect import deploy_rsconnect # noqa
18+
from .monitor import compute_metrics, pin_metrics, plot_metrics, _rolling_df # noqa
1919

2020
__author__ = "Isabel Zimmerman <isabel.zimmerman@rstudio.com>"
2121
__all__ = []

vetiver/data/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def __dir__():
1212

1313
def __getattr__(k):
1414
import pandas as pd
15+
1516
f_path = sources.get("mtcars")
1617
if k == "chicago":
1718
f_path = sources.get("chicago")

vetiver/pin_read_write.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ def vetiver_pin_read(board, name: str, version: str = None) -> VetiverModel:
6161
6262
Notes
6363
-----
64-
If reading a board from RSConnect, the `board` argument must be in "username/modelname" format.
64+
If reading a board from RSConnect, the `board` argument must be in
65+
"username/modelname" format.
6566
6667
"""
6768

6869
warnings.warn(
69-
"vetiver_pin_read will be removed in v1.0.0. Use classmethod VetiverModel.from_pin() instead",
70+
"vetiver_pin_read will be removed in v1.0.0. Use classmethod "
71+
"VetiverModel.from_pin() instead",
7072
DeprecationWarning,
7173
)
7274

vetiver/ptype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class NoAvailablePTypeError(Exception):
1919

2020
def __init__(
2121
self,
22-
message="There is no method available to create a 0-row input data prototype for `model`",
22+
message="There is no method to create a 0-row input data prototype for `model`",
2323
):
2424
self.message = message
2525
super().__init__(self.message)

vetiver/rsconnect.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ def deploy_rsconnect(
2626
2727
Parameters
2828
----------
29-
connect_server:
29+
connect_server:
3030
RSConnect Server
31-
board:
31+
board:
3232
Pins board
3333
pin_name: str
3434
Name of pin
3535
version: str
3636
Version of pin
3737
extra_files: typing.List[str]
38-
Any extra files to include in
38+
Any extra files to include in
3939
new:
4040
Force as a new deploy
4141
app_id:
@@ -46,7 +46,7 @@ def deploy_rsconnect(
4646
Optional name of a Python executable
4747
conda_mode: bool
4848
Use conda to build an environment.yml
49-
force_generate: bool
49+
force_generate: bool
5050
Force generating "requirements.txt" or "environment.yml"
5151
log_callback: typing.Callable
5252
Callback to use to write the log to
@@ -64,11 +64,10 @@ def deploy_rsconnect(
6464
shutil.copyfile(file, os.path.join(temp, filename))
6565
new_files = new_files + [os.path.join(temp, filename)]
6666
extra_files = new_files
67-
67+
6868
if board.fs.protocol == "file":
6969
shutil.copytree(board.path_to_pin(pin_name), os.path.join(temp, pin_name))
7070

71-
7271
tmp_app = temp + "/app.py"
7372

7473
write_app(

0 commit comments

Comments
 (0)