Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example deploy to railway #904

Open
wants to merge 21 commits into
base: demo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
version: 2
version: '2.1'
orbs:
node: circleci/[email protected]

defaults: &defaults
docker:
Expand Down Expand Up @@ -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:[email protected]/$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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
Accompanying repo for the online course Deployment of Machine Learning Models.

For the documentation, visit the [course on Udemy](https://www.udemy.com/deployment-of-machine-learning-models/?couponCode=TIDREPO).

An Update Readme.
Original file line number Diff line number Diff line change
Expand Up @@ -4611,8 +4611,8 @@
"source": [
"# Additional Resources\n",
"\n",
"- [Feature Engineering for Machine Learning](https://www.udemy.com/course/feature-engineering-for-machine-learning/?referralCode=A855148E05283015CF06) - Online Course\n",
"- [Packt Feature Engineering Cookbook](https://www.packtpub.com/data/python-feature-engineering-cookbook) - Book\n",
"- [Feature Engineering for Machine Learning](https://www.trainindata.com/p/feature-engineering-for-machine-learning) - Online Course\n",
"- [Packt Feature Engineering Cookbook](https://www.amazon.com/Python-Feature-Engineering-Cookbook-transforming-dp-1804611301/dp/1804611301) - Book\n",
"- [Predict house price with Feature-engine](https://www.kaggle.com/solegalli/predict-house-price-with-feature-engine) - Kaggle kernel\n",
"- [Comprehensive data exploration with Python](https://www.kaggle.com/pmarcelino/comprehensive-data-exploration-with-python) - Kaggle kernel\n",
"- [How I made top 0.3% on a Kaggle competition](https://www.kaggle.com/lavanyashukla01/how-i-made-top-0-3-on-a-kaggle-competition) - Kaggle kernel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@
"\n",
"For the remaining categorical variables, we will group those categories that are present in less than 1% of the observations. That is, all values of categorical variables that are shared by less than 1% of houses, well be replaced by the string \"Rare\".\n",
"\n",
"To learn more about how to handle categorical variables visit our course [Feature Engineering for Machine Learning](https://www.udemy.com/course/feature-engineering-for-machine-learning/?referralCode=A855148E05283015CF06) in Udemy."
"To learn more about how to handle categorical variables visit our course [Feature Engineering for Machine Learning](https://www.trainindata.com/p/feature-engineering-for-machine-learning)."
]
},
{
Expand Down Expand Up @@ -1805,7 +1805,7 @@
"\n",
"We will do it so that we capture the monotonic relationship between the label and the target.\n",
"\n",
"To learn more about how to encode categorical variables visit our course [Feature Engineering for Machine Learning](https://www.udemy.com/course/feature-engineering-for-machine-learning/?referralCode=A855148E05283015CF06) in Udemy."
"To learn more about how to encode categorical variables visit our course [Feature Engineering for Machine Learning](https://www.trainindata.com/p/feature-engineering-for-machine-learning)."
]
},
{
Expand Down Expand Up @@ -3083,9 +3083,9 @@
"\n",
"# Additional Resources\n",
"\n",
"- [Feature Engineering for Machine Learning](https://www.udemy.com/course/feature-engineering-for-machine-learning/?referralCode=A855148E05283015CF06) - Online Course\n",
"- [Packt Feature Engineering Cookbook](https://www.packtpub.com/data/python-feature-engineering-cookbook) - Book\n",
"- [Feature Engineering for Machine Learning: A comprehensive Overview](https://trainindata.medium.com/feature-engineering-for-machine-learning-a-comprehensive-overview-a7ad04c896f8) - Article\n",
"- [Feature Engineering for Machine Learning](https://www.trainindata.com/p/feature-engineering-for-machine-learning) - Online Course\n",
"- [Packt Feature Engineering Cookbook](https://www.amazon.com/Python-Feature-Engineering-Cookbook-transforming-dp-1804611301/dp/1804611301) - Book\n",
"- [Feature Engineering for Machine Learning: A comprehensive Overview](https://www.blog.trainindata.com/feature-engineering-for-machine-learning/) - Article\n",
"- [Practical Code Implementations of Feature Engineering for Machine Learning with Python](https://towardsdatascience.com/practical-code-implementations-of-feature-engineering-for-machine-learning-with-python-f13b953d4bcd) - Article"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,17 @@
"source": [
"# Additional Resources\n",
"\n",
"- [Feature Selection for Machine Learning](https://www.udemy.com/course/feature-selection-for-machine-learning/?referralCode=186501DF5D93F48C4F71) - Online Course\n",
"- [Feature Selection for Machine Learning: A comprehensive Overview](https://trainindata.medium.com/feature-selection-for-machine-learning-a-comprehensive-overview-bd571db5dd2d) - Article"
"- [Feature Selection for Machine Learning](https://www.trainindata.com/p/feature-selection-for-machine-learning) - Online Course\n",
"- [Feature Selection in Machine Learning with Python](https://leanpub.com/feature-selection-in-machine-learning/) - Book\n",
"- [Feature Selection for Machine Learning: A comprehensive Overview](https://www.blog.trainindata.com/feature-selection-for-machine-learning/) - Article"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@
"\n",
"We will do it so that we capture the monotonic relationship between the label and the target.\n",
"\n",
"To learn more about how to encode categorical variables visit our course [Feature Engineering for Machine Learning](https://www.udemy.com/course/feature-engineering-for-machine-learning/?referralCode=A855148E05283015CF06) in Udemy."
"To learn more about how to encode categorical variables visit our course [Feature Engineering for Machine Learning](https://www.trainindata.com/p/feature-engineering-for-machine-learning)."
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -1095,7 +1095,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.10.5"
},
"toc": {
"base_numbering": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from feature_engine.encoding import OrdinalEncoder, RareLabelEncoder
from feature_engine.imputation import (
AddMissingIndicator,
CategoricalImputer,
MeanMedianImputer,
)
from feature_engine.imputation import AddMissingIndicator, CategoricalImputer, MeanMedianImputer
from feature_engine.selection import DropFeatures
from feature_engine.transformation import LogTransformer
from feature_engine.wrappers import SklearnTransformerWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ pydantic>=1.8.1,<2.0.0
scikit-learn>=1.1.3,<2.0.0
strictyaml>=1.3.2,<2.0.0
ruamel.yaml>=0.16.12,<1.0.0
feature-engine>=1.0.2,<2.0.0
feature-engine>=1.0.2,<1.6.0 # breaking change in v1.6.0
joblib>=1.0.1,<2.0.0
3 changes: 1 addition & 2 deletions section-05-production-model-package/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ skipsdist = True
[testenv]
basepython = python
install_command = pip install {opts} {packages}
whitelist_externals = train
allowlist_externals = train

setenv =
PYTHONPATH=.
Expand Down Expand Up @@ -47,7 +47,6 @@ deps =
commands =
flake8 regression_model tests
isort regression_model tests
black regression_model tests
{posargs:mypy regression_model}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pydantic>=1.10.4,<1.12.0
typing_extensions>=4.2.0,<5.0.0
loguru>=0.5.3,<1.0.0
# We will explain this in the course
tid-regression-model>=3.2.0
tid-regression-model>=3.2.0
feature-engine>=1.0.2,<1.6.0 # breaking change in v1.6.0
1 change: 0 additions & 1 deletion section-06-model-serving-api/house-prices-api/runtime.txt

This file was deleted.

1 change: 1 addition & 0 deletions section-07-ci-and-publishing/gemfurypushurl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gemfury_push_url - https://gxpw8hV5RQwZ8qY9s69t:@pypi.fury.io/samsontontoye/
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.2"
__version__ = "0.0.5"
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pydantic>=1.10.4,<1.12.0
typing_extensions>=4.2.0,<5.0.0
loguru>=0.5.3,<1.0.0
# We will explain this in the course
tid-regression-model>=3.2.0
tid-regression-model>=3.2.0
feature-engine>=1.0.2,<1.6.0 # breaking change in v1.6.0
1 change: 0 additions & 1 deletion section-07-ci-and-publishing/house-prices-api/runtime.txt

This file was deleted.

4 changes: 2 additions & 2 deletions section-07-ci-and-publishing/model-package/publish_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Building packages and uploading them to a Gemfury repository

GEMFURY_URL=$GEMFURY_PUSH_URL
GEMFURY_URL=https://gxpw8hV5RQwZ8qY9s69t:@pypi.fury.io/samsontontoye/

set -e

Expand Down Expand Up @@ -41,4 +41,4 @@ else
ls -d */ | while read dir; do
build $dir
done
fi
fi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.3
4.0.5
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ pydantic>=1.8.1,<2.0.0
scikit-learn>=1.1.3,<2.0.0
strictyaml>=1.3.2,<2.0.0
ruamel.yaml>=0.16.12,<1.0.0
feature-engine>=1.0.2,<2.0.0
feature-engine>=1.0.2,<1.6.0 # breaking change in v1.6.0
joblib>=1.0.1,<2.0.0
15 changes: 9 additions & 6 deletions section-07-ci-and-publishing/model-package/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ skipsdist = True
[testenv]
basepython = python
install_command = pip install {opts} {packages}
whitelist_externals = train
allowlist_externals = train,python

passenv =
KAGGLE_USERNAME
KAGGLE_KEY
GEMFURY_PUSH_URL
godfatherfigure
ecd29195e37703773256fad8d107c3f2
https://gxpw8hV5RQwZ8qY9s69t:@pypi.fury.io/samsontontoye/

[testenv:test_package]
allowlist_externals = python
deps =
-rrequirements/test_requirements.txt

Expand Down Expand Up @@ -50,8 +51,9 @@ commands=

[testenv:fetch_data]
envdir = {toxworkdir}/test_package
allowlist_externals = unzip
deps =
{[testenv:test_package]deps}
kaggle<1.6.0

setenv =
{[testenv:test_package]setenv}
Expand All @@ -65,6 +67,7 @@ commands=

[testenv:publish_model]
envdir = {toxworkdir}/test_package
allowlist_externals = *
deps =
{[testenv:test_package]deps}

Expand All @@ -89,4 +92,4 @@ commands =

[flake8]
exclude = .git,env
max-line-length = 90
max-line-length = 90
13 changes: 0 additions & 13 deletions section-08-deploying-with-containers/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ 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
tid-regression-model==4.0.5
feature-engine>=1.0.2,<1.6.0 # breaking change in v1.6.0

This file was deleted.