From e47789ec350d369bc53fbbea0429e00a584eccce Mon Sep 17 00:00:00 2001 From: isabelizimm Date: Thu, 13 Oct 2022 15:06:10 -0400 Subject: [PATCH 01/17] adding initial files to set up testing --- Makefile | 17 ++++ docker-compose.yml | 17 ++++ tests/test_vetiver_pins.py | 94 +++++++++++++++++++ vetiver-testing/setup-rsconnect/add-users.sh | 1 + .../setup-rsconnect/dump_api_keys.py | 21 +++++ .../setup-rsconnect/rstudio-connect.gcfg | 22 +++++ vetiver-testing/setup-rsconnect/users.txt | 4 + 7 files changed, 176 insertions(+) create mode 100644 docker-compose.yml create mode 100644 tests/test_vetiver_pins.py create mode 100644 vetiver-testing/setup-rsconnect/add-users.sh create mode 100644 vetiver-testing/setup-rsconnect/dump_api_keys.py create mode 100644 vetiver-testing/setup-rsconnect/rstudio-connect.gcfg create mode 100644 vetiver-testing/setup-rsconnect/users.txt diff --git a/Makefile b/Makefile index e4563d62..7f8d3576 100644 --- a/Makefile +++ b/Makefile @@ -171,3 +171,20 @@ promote-docs-in-s3: --cache-control max-age=300 \ docs/site/ \ s3://docs.rstudio.com/rsconnect-python/ + + +dev: vetiver/tests/rsconnect_api_keys.json + +dev-start: + docker-compose up -d + docker-compose exec -T rsconnect bash < script/setup-rsconnect/add-users.sh + # curl fails with error 52 without a short sleep.... + sleep 5 + curl -s --retry 10 --retry-connrefused http://localhost:3939 + +dev-stop: + docker-compose down + rm -f $(RSC_API_KEYS) + +$(RSC_API_KEYS): dev-start + python script/setup-rsconnect/dump_api_keys.py $@ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8be8fc6b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.1' + +services: + + rsconnect: + image: rstudio/rstudio-connect:2021.12.1 + restart: always + ports: + - 3939:3939 + volumes: + - $PWD/script/setup-rsconnect/users.txt:/etc/users.txt + - $PWD/script/setup-rsconnect/rstudio-connect.gcfg:/etc/rstudio-connect/rstudio-connect.gcfg + # by default, mysql rounds to 4 decimals, but tests require more precision + privileged: true + environment: + RSTUDIO_CONNECT_HASTE: "enabled" + RSC_LICENSE: E6BW-76XS-ZV43-ITMV-C736-QCFY-8STA diff --git a/tests/test_vetiver_pins.py b/tests/test_vetiver_pins.py new file mode 100644 index 00000000..807bd210 --- /dev/null +++ b/tests/test_vetiver_pins.py @@ -0,0 +1,94 @@ +import pytest +import json +import sklearn +import pins +from pins.boards import BoardRsConnect +from pins.rsconnect.api import RsConnectApi +from pins.rsconnect.fs import RsConnectFs +from rsconnect.api import RSConnectServer + +import vetiver + +# Load data, model +X_df, y = vetiver.mock.get_mock_data() +model = vetiver.mock.get_mock_model().fit(X_df, y) + +RSC_SERVER_URL = "http://localhost:3939" +RSC_KEYS_FNAME = "vetiver/tests/rsconnect_api_keys.json" + +pytestmark = pytest.mark.rsc_test # noqa + + +def server_from_key(name): + with open(RSC_KEYS_FNAME) as f: + api_key = json.load(f)[name] + return RSConnectServer(RSC_SERVER_URL, api_key) + + +def get_key(name): + with open(RSC_KEYS_FNAME) as f: + api_key = json.load(f)[name] + return api_key + + +def rsc_from_key(name): + with open(RSC_KEYS_FNAME) as f: + api_key = json.load(f)[name] + return RsConnectApi(RSC_SERVER_URL, api_key) + + +def rsc_fs_from_key(name): + + rsc = rsc_from_key(name) + + return RsConnectFs(rsc) + + +def rsc_delete_user_content(rsc): + guid = rsc.get_user()["guid"] + content = rsc.get_content(owner_guid=guid) + for entry in content: + rsc.delete_content_item(entry["guid"]) + + +@pytest.fixture(scope="function") +def rsc_short(): + # tears down content after each test + fs_susan = rsc_fs_from_key("susan") + + # delete any content that might already exist + rsc_delete_user_content(fs_susan.api) + + yield BoardRsConnect( + "", fs_susan, allow_pickle_read=True + ) # fs_susan.ls to list content + + rsc_delete_user_content(fs_susan.api) + + +def test_board_pin_write(rsc_short): + v = vetiver.VetiverModel( + model=model, ptype_data=X_df, model_name="susan/model", versioned=None + ) + vetiver.vetiver_pin_write(board=rsc_short, model=v) + assert isinstance(rsc_short.pin_read("susan/model"), sklearn.dummy.DummyRegressor) + + +def test_deploy(rsc_short): + v = vetiver.VetiverModel( + model=model, ptype_data=X_df, model_name="susan/model", versioned=None + ) + board = pins.board_rsconnect( + server_url=RSC_SERVER_URL, api_key=get_key("susan"), allow_pickle_read=True + ) + + vetiver.vetiver_pin_write(board=board, model=v) + connect_server = RSConnectServer(url=RSC_SERVER_URL, api_key=get_key("susan")) + assert isinstance(board.pin_read("susan/model"), sklearn.dummy.DummyRegressor) + + vetiver.deploy_rsconnect( + connect_server=connect_server, board=board, pin_name="susan/model" + ) + response = vetiver.predict(RSC_SERVER_URL + "/predict", json=X_df) + assert response.status_code == 200, response.text + assert response.json() == {"prediction": [44.47, 44.47]}, response.json() diff --git a/vetiver-testing/setup-rsconnect/add-users.sh b/vetiver-testing/setup-rsconnect/add-users.sh new file mode 100644 index 00000000..1df8c7f4 --- /dev/null +++ b/vetiver-testing/setup-rsconnect/add-users.sh @@ -0,0 +1 @@ +awk ' { system("useradd -m -s /bin/bash "$1); system("echo \""$1":"$2"\" | chpasswd"); system("id "$1) } ' /etc/users.txt diff --git a/vetiver-testing/setup-rsconnect/dump_api_keys.py b/vetiver-testing/setup-rsconnect/dump_api_keys.py new file mode 100644 index 00000000..eebef59f --- /dev/null +++ b/vetiver-testing/setup-rsconnect/dump_api_keys.py @@ -0,0 +1,21 @@ +import json +import sys + +from pins.rsconnect.api import _HackyConnect + +OUT_FILE = sys.argv[1] + + +def get_api_key(user, password, email): + rsc = _HackyConnect("http://localhost:3939") + + return rsc.create_first_admin(user, password, email).api_key + + +api_keys = { + "admin": get_api_key("admin", "admin0", "admin@example.com"), + "susan": get_api_key("susan", "susan", "susan@example.com"), + "derek": get_api_key("derek", "derek", "derek@example.com"), +} + +json.dump(api_keys, open(OUT_FILE, "w")) diff --git a/vetiver-testing/setup-rsconnect/rstudio-connect.gcfg b/vetiver-testing/setup-rsconnect/rstudio-connect.gcfg new file mode 100644 index 00000000..98d0add0 --- /dev/null +++ b/vetiver-testing/setup-rsconnect/rstudio-connect.gcfg @@ -0,0 +1,22 @@ +[Server] +DataDir = /data +Address = http://localhost:3939 + +[HTTP] +Listen = :3939 + +[Authentication] +Provider = pam + +[Authorization] +DefaultUserRole = publisher + +[Python] +Enabled = true +Executable = /opt/python/3.9.5/bin/python + +[RPackageRepository "CRAN"] +URL = https://packagemanager.rstudio.com/cran/__linux__/bionic/latest + +[RPackageRepository "RSPM"] +URL = https://packagemanager.rstudio.com/cran/__linux__/bionic/latest diff --git a/vetiver-testing/setup-rsconnect/users.txt b/vetiver-testing/setup-rsconnect/users.txt new file mode 100644 index 00000000..dd4ec359 --- /dev/null +++ b/vetiver-testing/setup-rsconnect/users.txt @@ -0,0 +1,4 @@ +admin admin0 +test test +susan susan +derek derek From cceef6575b7dec58e247ed8efc9f9ca5fd31cda9 Mon Sep 17 00:00:00 2001 From: isabelizimm Date: Thu, 13 Oct 2022 15:12:26 -0400 Subject: [PATCH 02/17] update github actions --- .github/workflows/main.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d32b730..e32749e0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -144,3 +144,29 @@ jobs: repo: 'rsconnect-jupyter', event_type: 'rsconnect_python_latest' }) + test-rsconnect: + name: "Test vetiver" + runs-on: ubuntu-latest + if: ${{ !github.event.pull_request.head.repo.fork }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e . + python -m pip install vetiver + - name: run RStudio Connect + run: | + docker-compose up --build -d + make dev + env: + RSC_LICENSE: ${{ secrets.RSC_LICENSE }} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + # NOTE: edited to run checks for python package + - name: Run tests + run: | + pytest vetiver -m 'rsc_test' From 1f9a4c69d01b2d517ff0ccd57718a28ab7e85a37 Mon Sep 17 00:00:00 2001 From: isabelizimm Date: Thu, 13 Oct 2022 15:14:56 -0400 Subject: [PATCH 03/17] updating config files --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8be8fc6b..c0292d52 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,4 +14,4 @@ services: privileged: true environment: RSTUDIO_CONNECT_HASTE: "enabled" - RSC_LICENSE: E6BW-76XS-ZV43-ITMV-C736-QCFY-8STA + RSC_LICENSE: ${RSC_LICENSE} From a71567fc9a1efaab8e5867b986aab7992de10d8a Mon Sep 17 00:00:00 2001 From: isabelizimm Date: Mon, 14 Nov 2022 17:00:40 -0500 Subject: [PATCH 04/17] update to match vetiver's strategy --- .github/workflows/main.yml | 1 + docker-compose.yml | 4 +- tests/test_vetiver_pins.py | 56 ++++++++++--------- .../setup-rsconnect/rstudio-connect.gcfg | 1 + 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 24ff7771..bfe372cb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -163,6 +163,7 @@ jobs: - name: run RStudio Connect run: | docker-compose up --build -d + pip freeze > requirements.txt make dev env: RSC_LICENSE: ${{ secrets.RSC_LICENSE }} diff --git a/docker-compose.yml b/docker-compose.yml index c0292d52..f46ad2a4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,9 @@ -version: '3.1' +version: '3.2' services: rsconnect: - image: rstudio/rstudio-connect:2021.12.1 + image: rstudio/rstudio-connect:latest restart: always ports: - 3939:3939 diff --git a/tests/test_vetiver_pins.py b/tests/test_vetiver_pins.py index 807bd210..cb1c37d4 100644 --- a/tests/test_vetiver_pins.py +++ b/tests/test_vetiver_pins.py @@ -2,29 +2,22 @@ import json import sklearn import pins +import pandas as pd +import numpy as np + from pins.boards import BoardRsConnect from pins.rsconnect.api import RsConnectApi from pins.rsconnect.fs import RsConnectFs -from rsconnect.api import RSConnectServer +from rsconnect.api import RSConnectServer, RSConnectClient import vetiver -# Load data, model -X_df, y = vetiver.mock.get_mock_data() -model = vetiver.mock.get_mock_model().fit(X_df, y) - RSC_SERVER_URL = "http://localhost:3939" RSC_KEYS_FNAME = "vetiver/tests/rsconnect_api_keys.json" pytestmark = pytest.mark.rsc_test # noqa -def server_from_key(name): - with open(RSC_KEYS_FNAME) as f: - api_key = json.load(f)[name] - return RSConnectServer(RSC_SERVER_URL, api_key) - - def get_key(name): with open(RSC_KEYS_FNAME) as f: api_key = json.load(f)[name] @@ -66,18 +59,15 @@ def rsc_short(): rsc_delete_user_content(fs_susan.api) -def test_board_pin_write(rsc_short): - v = vetiver.VetiverModel( - model=model, ptype_data=X_df, model_name="susan/model", versioned=None - ) - vetiver.vetiver_pin_write(board=rsc_short, model=v) - assert isinstance(rsc_short.pin_read("susan/model"), sklearn.dummy.DummyRegressor) +def test_deploy(rsc_short): + np.random.seed(500) + # Load data, model + X_df, y = vetiver.mock.get_mock_data() + model = vetiver.mock.get_mock_model().fit(X_df, y) + + v = vetiver.VetiverModel(model=model, ptype_data=X_df, model_name="susan/model") -def test_deploy(rsc_short): - v = vetiver.VetiverModel( - model=model, ptype_data=X_df, model_name="susan/model", versioned=None - ) board = pins.board_rsconnect( server_url=RSC_SERVER_URL, api_key=get_key("susan"), allow_pickle_read=True ) @@ -87,8 +77,24 @@ def test_deploy(rsc_short): assert isinstance(board.pin_read("susan/model"), sklearn.dummy.DummyRegressor) vetiver.deploy_rsconnect( - connect_server=connect_server, board=board, pin_name="susan/model" + connect_server=connect_server, + board=board, + pin_name="susan/model", + title="testapivetiver", + extra_files=["requirements.txt"], ) - response = vetiver.predict(RSC_SERVER_URL + "/predict", json=X_df) - assert response.status_code == 200, response.text - assert response.json() == {"prediction": [44.47, 44.47]}, response.json() + + # get url of where content lives + client = RSConnectClient(connect_server) + dicts = client.content_search() + rsc_api = list(filter(lambda x: x["title"] == "testapivetiver", dicts)) + content_url = rsc_api[0].get("content_url") + + h = {"Authorization": f'Key {get_key("susan")}'} + + endpoint = vetiver.vetiver_endpoint(content_url + "/predict") + response = vetiver.predict(endpoint, X_df, headers=h) + + assert isinstance(response, pd.DataFrame), response + assert response.iloc[0, 0] == 44.47 + assert len(response) == 100 diff --git a/vetiver-testing/setup-rsconnect/rstudio-connect.gcfg b/vetiver-testing/setup-rsconnect/rstudio-connect.gcfg index 98d0add0..23608bf3 100644 --- a/vetiver-testing/setup-rsconnect/rstudio-connect.gcfg +++ b/vetiver-testing/setup-rsconnect/rstudio-connect.gcfg @@ -13,6 +13,7 @@ DefaultUserRole = publisher [Python] Enabled = true +Executable = /opt/python/3.8.10/bin/python Executable = /opt/python/3.9.5/bin/python [RPackageRepository "CRAN"] From 29db57894577de92f86818a89a3952eca9df304a Mon Sep 17 00:00:00 2001 From: isabelizimm Date: Mon, 14 Nov 2022 17:26:23 -0500 Subject: [PATCH 05/17] dont interfere with other tests --- .github/workflows/main.yml | 3 +-- tests/test_vetiver_pins.py | 29 ++++++++++-------------- vetiver-testing/vetiver-requirements.txt | 4 ++++ 3 files changed, 17 insertions(+), 19 deletions(-) create mode 100644 vetiver-testing/vetiver-requirements.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bfe372cb..fd4a633a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -158,8 +158,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -e . - python -m pip install vetiver + python -m pip install -r vetiver-testing/vetiver-requirements.txt - name: run RStudio Connect run: | docker-compose up --build -d diff --git a/tests/test_vetiver_pins.py b/tests/test_vetiver_pins.py index cb1c37d4..85d0a27a 100644 --- a/tests/test_vetiver_pins.py +++ b/tests/test_vetiver_pins.py @@ -1,16 +1,16 @@ import pytest -import json -import sklearn -import pins -import pandas as pd -import numpy as np -from pins.boards import BoardRsConnect -from pins.rsconnect.api import RsConnectApi -from pins.rsconnect.fs import RsConnectFs -from rsconnect.api import RSConnectServer, RSConnectClient +torch = pytest.importorskip("vetiver", reason="vetiver library not installed") -import vetiver +import json # noqa +import pins # noqa +import pandas as pd # noqa +import numpy as np # noqa + +from pins.boards import BoardRsConnect # noqa +from pins.rsconnect.api import RsConnectApi # noqa +from pins.rsconnect.fs import RsConnectFs # noqa +from rsconnect.api import RSConnectServer, RSConnectClient # noqa RSC_SERVER_URL = "http://localhost:3939" RSC_KEYS_FNAME = "vetiver/tests/rsconnect_api_keys.json" @@ -52,9 +52,7 @@ def rsc_short(): # delete any content that might already exist rsc_delete_user_content(fs_susan.api) - yield BoardRsConnect( - "", fs_susan, allow_pickle_read=True - ) # fs_susan.ls to list content + yield BoardRsConnect("", fs_susan, allow_pickle_read=True) # fs_susan.ls to list content rsc_delete_user_content(fs_susan.api) @@ -68,13 +66,10 @@ def test_deploy(rsc_short): v = vetiver.VetiverModel(model=model, ptype_data=X_df, model_name="susan/model") - board = pins.board_rsconnect( - server_url=RSC_SERVER_URL, api_key=get_key("susan"), allow_pickle_read=True - ) + board = pins.board_rsconnect(server_url=RSC_SERVER_URL, api_key=get_key("susan"), allow_pickle_read=True) vetiver.vetiver_pin_write(board=board, model=v) connect_server = RSConnectServer(url=RSC_SERVER_URL, api_key=get_key("susan")) - assert isinstance(board.pin_read("susan/model"), sklearn.dummy.DummyRegressor) vetiver.deploy_rsconnect( connect_server=connect_server, diff --git a/vetiver-testing/vetiver-requirements.txt b/vetiver-testing/vetiver-requirements.txt new file mode 100644 index 00000000..2a261b90 --- /dev/null +++ b/vetiver-testing/vetiver-requirements.txt @@ -0,0 +1,4 @@ +pins +pandas +numpy +vetiver From 2f78186a819c4f7ce79a5abffe8c0b0b4081267c Mon Sep 17 00:00:00 2001 From: isabelizimm Date: Mon, 14 Nov 2022 17:35:02 -0500 Subject: [PATCH 06/17] add pytest mark --- .github/workflows/main.yml | 2 +- pyproject.toml | 5 +++++ tests/test_vetiver_pins.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd4a633a..6373c477 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -171,4 +171,4 @@ jobs: # NOTE: edited to run checks for python package - name: Run tests run: | - pytest vetiver -m 'rsc_test' + pytest -m 'vetiver' diff --git a/pyproject.toml b/pyproject.toml index e42624a7..c0939a29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,3 +10,8 @@ omit = ["tests/*"] [tool.setuptools_scm] write_to = "rsconnect/version.py" + +[tool.pytest.ini_options] +markers = [ + "vetiver: tests for vetiver", +] diff --git a/tests/test_vetiver_pins.py b/tests/test_vetiver_pins.py index 85d0a27a..b9ade3dd 100644 --- a/tests/test_vetiver_pins.py +++ b/tests/test_vetiver_pins.py @@ -15,7 +15,7 @@ RSC_SERVER_URL = "http://localhost:3939" RSC_KEYS_FNAME = "vetiver/tests/rsconnect_api_keys.json" -pytestmark = pytest.mark.rsc_test # noqa +pytestmark = pytest.mark.vetiver # noqa def get_key(name): From 7642202ec3a30f38ce40181f329a98059dd1cdb7 Mon Sep 17 00:00:00 2001 From: isabelizimm Date: Mon, 14 Nov 2022 17:39:19 -0500 Subject: [PATCH 07/17] add vetiver specific dependencies --- tests/test_vetiver_pins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_vetiver_pins.py b/tests/test_vetiver_pins.py index b9ade3dd..878cbddb 100644 --- a/tests/test_vetiver_pins.py +++ b/tests/test_vetiver_pins.py @@ -1,6 +1,6 @@ import pytest -torch = pytest.importorskip("vetiver", reason="vetiver library not installed") +vetiver = pytest.importorskip("vetiver", reason="vetiver library not installed") import json # noqa import pins # noqa From 89350aced4c5f9da08ad6373cc0692be26176db8 Mon Sep 17 00:00:00 2001 From: isabelizimm Date: Mon, 14 Nov 2022 18:46:04 -0500 Subject: [PATCH 08/17] make py3.5 compliant --- Makefile | 9 ++++++--- conftest.py | 15 +++++++++++++++ docker-compose.yml | 4 ++-- tests/test_vetiver_pins.py | 4 ++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 7f8d3576..e3da4677 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,8 @@ endif TEST_ENV = +RSC_API_KEYS=vetiver-testing/rsconnect_api_keys.json + ifneq ($(CONNECT_SERVER),) TEST_ENV += CONNECT_SERVER=$(CONNECT_SERVER) endif @@ -173,11 +175,11 @@ promote-docs-in-s3: s3://docs.rstudio.com/rsconnect-python/ -dev: vetiver/tests/rsconnect_api_keys.json +dev: vetiver-testing/rsconnect_api_keys.json dev-start: docker-compose up -d - docker-compose exec -T rsconnect bash < script/setup-rsconnect/add-users.sh + docker-compose exec -T rsconnect bash < vetiver-testing/setup-rsconnect/add-users.sh # curl fails with error 52 without a short sleep.... sleep 5 curl -s --retry 10 --retry-connrefused http://localhost:3939 @@ -187,4 +189,5 @@ dev-stop: rm -f $(RSC_API_KEYS) $(RSC_API_KEYS): dev-start - python script/setup-rsconnect/dump_api_keys.py $@ \ No newline at end of file + python vetiver-testing/setup-rsconnect/dump_api_keys.py $@ + \ No newline at end of file diff --git a/conftest.py b/conftest.py index e1ee128c..9d3d1562 100644 --- a/conftest.py +++ b/conftest.py @@ -1,7 +1,22 @@ import sys +import pytest from os.path import abspath, dirname HERE = dirname(abspath(__file__)) sys.path.insert(0, HERE) + + +def pytest_addoption(parser): + parser.addoption( + "--vetiver", action="store_true", default=False, help="run vetiver tests" + ) + +def pytest_configure(config): + config.addinivalue_line("markers", "vetiver: test for vetiver interaction") + +def pytest_collection_modifyitems(config, items): + if config.getoption("--vetiver"): + return + skip_vetiver = pytest.mark.skip(reason="need --vetiver option to run") diff --git a/docker-compose.yml b/docker-compose.yml index f46ad2a4..2f3349c8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,8 +8,8 @@ services: ports: - 3939:3939 volumes: - - $PWD/script/setup-rsconnect/users.txt:/etc/users.txt - - $PWD/script/setup-rsconnect/rstudio-connect.gcfg:/etc/rstudio-connect/rstudio-connect.gcfg + - $PWD/vetiver-testing/setup-rsconnect/users.txt:/etc/users.txt + - $PWD/vetiver-testing/setup-rsconnect/rstudio-connect.gcfg:/etc/rstudio-connect/rstudio-connect.gcfg # by default, mysql rounds to 4 decimals, but tests require more precision privileged: true environment: diff --git a/tests/test_vetiver_pins.py b/tests/test_vetiver_pins.py index 878cbddb..ba9ed320 100644 --- a/tests/test_vetiver_pins.py +++ b/tests/test_vetiver_pins.py @@ -13,7 +13,7 @@ from rsconnect.api import RSConnectServer, RSConnectClient # noqa RSC_SERVER_URL = "http://localhost:3939" -RSC_KEYS_FNAME = "vetiver/tests/rsconnect_api_keys.json" +RSC_KEYS_FNAME = "vetiver-testing/rsconnect_api_keys.json" pytestmark = pytest.mark.vetiver # noqa @@ -85,7 +85,7 @@ def test_deploy(rsc_short): rsc_api = list(filter(lambda x: x["title"] == "testapivetiver", dicts)) content_url = rsc_api[0].get("content_url") - h = {"Authorization": f'Key {get_key("susan")}'} + h = {"Authorization": 'Key {}'.format(get_key("susan"))} endpoint = vetiver.vetiver_endpoint(content_url + "/predict") response = vetiver.predict(endpoint, X_df, headers=h) From 0f0b084fbfd7006ead9cff9c8bd914f7cd9e7eff Mon Sep 17 00:00:00 2001 From: isabelizimm Date: Mon, 14 Nov 2022 18:54:39 -0500 Subject: [PATCH 09/17] run in gha --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6373c477..0f5445d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -149,7 +149,6 @@ jobs: test-rsconnect: name: "Test vetiver" runs-on: ubuntu-latest - if: ${{ !github.event.pull_request.head.repo.fork }} steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 From a6e010ffdc76a15e5de927252e742043f12bdea9 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Tue, 10 Jan 2023 16:37:40 -0500 Subject: [PATCH 10/17] update license variable name --- .github/workflows/main.yml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8a6f4438..dc237f06 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -164,7 +164,7 @@ jobs: pip freeze > requirements.txt make dev env: - RSC_LICENSE: ${{ secrets.RSC_LICENSE }} + CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # NOTE: edited to run checks for python package diff --git a/docker-compose.yml b/docker-compose.yml index 2f3349c8..9341ee7c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,4 +14,4 @@ services: privileged: true environment: RSTUDIO_CONNECT_HASTE: "enabled" - RSC_LICENSE: ${RSC_LICENSE} + CONNECT_LICENSE: ${CONNECT_LICENSE} From 5f79c1573a36ce348319d1aff779cd484014aa07 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Wed, 11 Jan 2023 15:17:24 -0500 Subject: [PATCH 11/17] Revert "update license variable name" This reverts commit a6e010ffdc76a15e5de927252e742043f12bdea9. --- .github/workflows/main.yml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dc237f06..8a6f4438 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -164,7 +164,7 @@ jobs: pip freeze > requirements.txt make dev env: - CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }} + RSC_LICENSE: ${{ secrets.RSC_LICENSE }} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # NOTE: edited to run checks for python package diff --git a/docker-compose.yml b/docker-compose.yml index 9341ee7c..2f3349c8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,4 +14,4 @@ services: privileged: true environment: RSTUDIO_CONNECT_HASTE: "enabled" - CONNECT_LICENSE: ${CONNECT_LICENSE} + RSC_LICENSE: ${RSC_LICENSE} From a8c3deeb9e8df96f44e8c3a7cb51470f5bce1485 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Wed, 11 Jan 2023 15:26:56 -0500 Subject: [PATCH 12/17] replace license env with export --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8a6f4438..fdb297b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -162,9 +162,9 @@ jobs: run: | docker-compose up --build -d pip freeze > requirements.txt + export RSC_LICENSE=${{ secrets.RSC_LICENSE }} make dev env: - RSC_LICENSE: ${{ secrets.RSC_LICENSE }} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # NOTE: edited to run checks for python package From ae5299bf56e045ccc3882d0c416dba1a25a5d3e0 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Wed, 11 Jan 2023 15:53:37 -0500 Subject: [PATCH 13/17] move export up --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fdb297b1..464fc695 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -160,9 +160,9 @@ jobs: python -m pip install -r vetiver-testing/vetiver-requirements.txt - name: run RStudio Connect run: | + export RSC_LICENSE=${{ secrets.RSC_LICENSE }} docker-compose up --build -d pip freeze > requirements.txt - export RSC_LICENSE=${{ secrets.RSC_LICENSE }} make dev env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 835d57ae1e4867d9f50c4cb359a3ea60944eda64 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Wed, 11 Jan 2023 16:40:25 -0500 Subject: [PATCH 14/17] Revert "move export up" This reverts commit ae5299bf56e045ccc3882d0c416dba1a25a5d3e0. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 464fc695..fdb297b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -160,9 +160,9 @@ jobs: python -m pip install -r vetiver-testing/vetiver-requirements.txt - name: run RStudio Connect run: | - export RSC_LICENSE=${{ secrets.RSC_LICENSE }} docker-compose up --build -d pip freeze > requirements.txt + export RSC_LICENSE=${{ secrets.RSC_LICENSE }} make dev env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 6052894c3ce8c7df37c44f7a730b5085d531d6d9 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Wed, 11 Jan 2023 16:40:33 -0500 Subject: [PATCH 15/17] Revert "replace license env with export" This reverts commit a8c3deeb9e8df96f44e8c3a7cb51470f5bce1485. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fdb297b1..8a6f4438 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -162,9 +162,9 @@ jobs: run: | docker-compose up --build -d pip freeze > requirements.txt - export RSC_LICENSE=${{ secrets.RSC_LICENSE }} make dev env: + RSC_LICENSE: ${{ secrets.RSC_LICENSE }} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # NOTE: edited to run checks for python package From 4359fa3cd6d9ae23175010f207cd1b582ae953f9 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Wed, 11 Jan 2023 17:06:30 -0500 Subject: [PATCH 16/17] add pytest to requirements --- vetiver-testing/vetiver-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/vetiver-testing/vetiver-requirements.txt b/vetiver-testing/vetiver-requirements.txt index 2a261b90..7700f9bf 100644 --- a/vetiver-testing/vetiver-requirements.txt +++ b/vetiver-testing/vetiver-requirements.txt @@ -2,3 +2,4 @@ pins pandas numpy vetiver +pytest From 81997d83aa144b11e63a156be1de53b7ca9e1d9f Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 12 Jan 2023 20:03:03 +0000 Subject: [PATCH 17/17] pip install requirements Co-authored-by: Isabel Zimmerman <54685329+isabelizimm@users.noreply.github.com> --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8a6f4438..d23547e8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -157,6 +157,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + python -m pip install -r requirements.txt python -m pip install -r vetiver-testing/vetiver-requirements.txt - name: run RStudio Connect run: |