From 3954da8e24ee7e957eba101a8fe1803c605a5752 Mon Sep 17 00:00:00 2001 From: Christopher Samiullah Date: Mon, 20 Feb 2023 10:26:33 +0800 Subject: [PATCH] switch to railway from heroku for section 06 - 08 (#857) * switch to railway for section 06-08 --- .circleci/config.yml | 57 ++++++++++--------- .../house-prices-api/runtime.txt | 1 - .../house-prices-api/runtime.txt | 1 - .../model-package/regression_model/VERSION | 2 +- .../model-package/tox.ini | 7 ++- section-08-deploying-with-containers/Makefile | 13 ----- .../house-prices-api/requirements.txt | 2 +- .../house-prices-api/runtime.txt | 1 - 8 files changed, 37 insertions(+), 47 deletions(-) delete mode 100644 section-06-model-serving-api/house-prices-api/runtime.txt delete mode 100644 section-07-ci-and-publishing/house-prices-api/runtime.txt delete mode 100644 section-08-deploying-with-containers/Makefile delete mode 100644 section-08-deploying-with-containers/house-prices-api/runtime.txt diff --git a/.circleci/config.yml b/.circleci/config.yml index c916f3f47..037645ab2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,6 @@ -version: 2 +version: '2.1' +orbs: + node: circleci/node@5.1.0 defaults: &defaults docker: @@ -40,15 +42,19 @@ jobs: command: | tox - section_07_deploy_app_to_heroku: + section_07_deploy_app_to_railway: <<: *defaults steps: - checkout: - path: ~/project + path: ~/project/ + - node/install: + node-version: '16.13' + - run: node --version + - run: npm i -g @railway/cli - run: - name: Deploy to Heroku + name: Deploy to Railway App (You must set RAILWAY_TOKEN env var) command: | - git subtree push --prefix section-07-ci-and-publishing/house-prices-api https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master + cd section-07-ci-and-publishing/house-prices-api && railway up --detach section_07_test_and_upload_regression_model: <<: *defaults @@ -71,28 +77,22 @@ jobs: tox -e publish_model - section_08_deploy_app_container_in_heroku: + section_08_deploy_app_container_via_railway: <<: *defaults steps: - setup_remote_docker: # Supported versions: https://circleci.com/docs/2.0/building-docker-images/#docker-version - version: 20.10.6 + version: 20.10.18 - checkout: - path: ~/project - - run: - name: Build image - command: | - sudo curl https://cli-assets.heroku.com/install.sh | sh - cd section-08-deploying-with-containers && make build-ml-api-heroku - - run: - name: Push Image to Heroku - command: | - # Push the built container to the Heroku image registry - cd section-08-deploying-with-containers && make push-ml-api-heroku + path: ~/project/ + - node/install: + node-version: '16.13' + - run: node --version + - run: npm i -g @railway/cli - run: - name: Release to Heroku + name: Build and run Dockerfile (see https://docs.railway.app/deploy/dockerfiles) command: | - cd section-08-deploying-with-containers && make release-heroku + cd section-08-deploying-with-containers && railway up --detach test_regression_model_py37: docker: @@ -265,24 +265,27 @@ tags_only: &tags_only workflows: version: 2 - section_07: + deploy_pipeline: jobs: - section_07_test_app - - section_07_deploy_app_to_heroku: + - section_07_deploy_app_to_railway: requires: - section_07_test_app filters: branches: only: - master + - demo # upload after git tags are created - section_07_test_and_upload_regression_model: <<: *tags_only - - section_08_deploy_app_container_in_heroku: - filters: - branches: - only: - - master + + - section_08_deploy_app_container_via_railway: + filters: + branches: + only: + - master + - demo # test-all: # jobs: diff --git a/section-06-model-serving-api/house-prices-api/runtime.txt b/section-06-model-serving-api/house-prices-api/runtime.txt deleted file mode 100644 index cd6f13073..000000000 --- a/section-06-model-serving-api/house-prices-api/runtime.txt +++ /dev/null @@ -1 +0,0 @@ -python-3.11.1 \ No newline at end of file diff --git a/section-07-ci-and-publishing/house-prices-api/runtime.txt b/section-07-ci-and-publishing/house-prices-api/runtime.txt deleted file mode 100644 index 88f4ef204..000000000 --- a/section-07-ci-and-publishing/house-prices-api/runtime.txt +++ /dev/null @@ -1 +0,0 @@ -python-3.9.5 \ No newline at end of file diff --git a/section-07-ci-and-publishing/model-package/regression_model/VERSION b/section-07-ci-and-publishing/model-package/regression_model/VERSION index c4e41f945..7636e7565 100644 --- a/section-07-ci-and-publishing/model-package/regression_model/VERSION +++ b/section-07-ci-and-publishing/model-package/regression_model/VERSION @@ -1 +1 @@ -4.0.3 +4.0.5 diff --git a/section-07-ci-and-publishing/model-package/tox.ini b/section-07-ci-and-publishing/model-package/tox.ini index e500db2c8..7a49ed86c 100644 --- a/section-07-ci-and-publishing/model-package/tox.ini +++ b/section-07-ci-and-publishing/model-package/tox.ini @@ -15,7 +15,7 @@ skipsdist = True [testenv] basepython = python install_command = pip install {opts} {packages} -whitelist_externals = train +whitelist_externals = train,python passenv = KAGGLE_USERNAME @@ -23,6 +23,7 @@ passenv = GEMFURY_PUSH_URL [testenv:test_package] +whitelist_externals = python deps = -rrequirements/test_requirements.txt @@ -50,8 +51,9 @@ commands= [testenv:fetch_data] envdir = {toxworkdir}/test_package +whitelist_externals = unzip deps = - {[testenv:test_package]deps} + kaggle<1.6.0 setenv = {[testenv:test_package]setenv} @@ -65,6 +67,7 @@ commands= [testenv:publish_model] envdir = {toxworkdir}/test_package +whitelist_externals = python deps = {[testenv:test_package]deps} diff --git a/section-08-deploying-with-containers/Makefile b/section-08-deploying-with-containers/Makefile deleted file mode 100644 index 9644e8311..000000000 --- a/section-08-deploying-with-containers/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -heroku-login: - HEROKU_API_KEY=${HEROKU_API_KEY} heroku container:login - -build-ml-api-heroku: heroku-login - docker build --build-arg PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL} -t registry.heroku.com/${HEROKU_APP_NAME}/web . - -push-ml-api-heroku: heroku-login - docker push registry.heroku.com/${HEROKU_APP_NAME}/web - -release-heroku: heroku-login - heroku container:release web --app ${HEROKU_APP_NAME} - -.PHONY: heroku-login build-ml-api-heroku push-ml-api-heroku \ No newline at end of file diff --git a/section-08-deploying-with-containers/house-prices-api/requirements.txt b/section-08-deploying-with-containers/house-prices-api/requirements.txt index 602e2c36f..e13438d36 100644 --- a/section-08-deploying-with-containers/house-prices-api/requirements.txt +++ b/section-08-deploying-with-containers/house-prices-api/requirements.txt @@ -7,4 +7,4 @@ pydantic>=1.10.4,<1.12.0 typing_extensions>=4.2.0,<5.0.0 loguru>=0.5.3,<1.0.0 # fetched from gemfury -tid-regression-model==4.0.2 \ No newline at end of file +tid-regression-model==4.0.5 \ No newline at end of file diff --git a/section-08-deploying-with-containers/house-prices-api/runtime.txt b/section-08-deploying-with-containers/house-prices-api/runtime.txt deleted file mode 100644 index 88f4ef204..000000000 --- a/section-08-deploying-with-containers/house-prices-api/runtime.txt +++ /dev/null @@ -1 +0,0 @@ -python-3.9.5 \ No newline at end of file