-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from zenml-io/feature/stack-showcase
Feature/stack showcase
- Loading branch information
Showing
36 changed files
with
2,818 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,7 @@ dmypy.json | |
.pyre/ | ||
|
||
# Zenml | ||
.zen/ | ||
src/.zen/ | ||
|
||
# MLflow | ||
mlruns/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.venv* | ||
.requirements* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# 📜 ZenML Stack Show Case | ||
|
||
This project aims to demonstrate the power of stacks. The code in this | ||
project assumes that you have quite a few stacks registered already. | ||
|
||
## default | ||
* `default` Orchestrator | ||
* `default` Artifact Store | ||
|
||
```commandline | ||
zenml stack set default | ||
python run.py --training-pipeline | ||
``` | ||
|
||
## local-sagemaker-step-operator-stack | ||
* `default` Orchestrator | ||
* `s3` Artifact Store | ||
* `local` Image Builder | ||
* `aws` Container Registry | ||
* `Sagemaker` Step Operator | ||
|
||
```commandline | ||
zenml stack set local-sagemaker-step-operator-stack | ||
zenml integration install aws -y | ||
python run.py --training-pipeline | ||
``` | ||
|
||
## sagemaker-airflow-stack | ||
* `Airflow` Orchestrator | ||
* `s3` Artifact Store | ||
* `local` Image Builder | ||
* `aws` Container Registry | ||
* `Sagemaker` Step Operator | ||
|
||
```commandline | ||
zenml stack set sagemaker-airflow-stack | ||
zenml integration install airflow -y | ||
pip install apache-airflow-providers-docker apache-airflow~=2.5.0 | ||
zenml stack up | ||
python run.py --training-pipeline | ||
``` | ||
|
||
## sagemaker-stack | ||
* `Sagemaker` Orchestrator | ||
* `s3` Artifact Store | ||
* `local` Image Builder | ||
* `aws` Container Registry | ||
* `Sagemaker` Step Operator | ||
|
||
```commandline | ||
zenml stack set sagemaker-stack | ||
python run.py --training-pipeline | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# environment configuration | ||
settings: | ||
docker: | ||
required_integrations: | ||
- sklearn | ||
|
||
# configuration of the Model Control Plane | ||
model_version: | ||
name: breast_cancer_classifier | ||
license: Apache 2.0 | ||
description: Classification of Breast Cancer Dataset. | ||
tags: ["classification", "sklearn"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# environment configuration | ||
settings: | ||
docker: | ||
required_integrations: | ||
- sklearn | ||
|
||
# configuration of the Model Control Plane | ||
model_version: | ||
name: breast_cancer_classifier | ||
version: production | ||
license: Apache 2.0 | ||
description: Classification of Breast Cancer Dataset. | ||
tags: ["classification", "sklearn"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# environment configuration | ||
settings: | ||
docker: | ||
required_integrations: | ||
- sklearn | ||
|
||
# configuration of the Model Control Plane | ||
model_version: | ||
name: breast_cancer_classifier | ||
license: Apache 2.0 | ||
description: Classification of Breast Cancer Dataset. | ||
tags: ["classification", "sklearn"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# {% include 'template/license_header' %} | ||
|
||
from .feature_engineering import feature_engineering | ||
from .inference import inference | ||
from .training import training |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# {% include 'template/license_header' %} | ||
|
||
import random | ||
from typing import List, Optional | ||
|
||
from steps import ( | ||
data_loader, | ||
data_preprocessor, | ||
data_splitter, | ||
) | ||
from zenml import pipeline | ||
from zenml.logger import get_logger | ||
|
||
logger = get_logger(__name__) | ||
|
||
|
||
@pipeline | ||
def feature_engineering( | ||
test_size: float = 0.2, | ||
drop_na: Optional[bool] = None, | ||
normalize: Optional[bool] = None, | ||
drop_columns: Optional[List[str]] = None, | ||
target: Optional[str] = "target", | ||
): | ||
""" | ||
Feature engineering pipeline. | ||
This is a pipeline that loads the data, processes it and splits | ||
it into train and test sets. | ||
Args: | ||
test_size: Size of holdout set for training 0.0..1.0 | ||
drop_na: If `True` NA values will be removed from dataset | ||
normalize: If `True` dataset will be normalized with MinMaxScaler | ||
drop_columns: List of columns to drop from dataset | ||
target: Name of target column in dataset | ||
""" | ||
### ADD YOUR OWN CODE HERE - THIS IS JUST AN EXAMPLE ### | ||
# Link all the steps together by calling them and passing the output | ||
# of one step as the input of the next step. | ||
raw_data = data_loader(random_state=random.randint(0, 100), target=target) | ||
dataset_trn, dataset_tst = data_splitter( | ||
dataset=raw_data, | ||
test_size=test_size, | ||
) | ||
dataset_trn, dataset_tst, _ = data_preprocessor( | ||
dataset_trn=dataset_trn, | ||
dataset_tst=dataset_tst, | ||
drop_na=drop_na, | ||
normalize=normalize, | ||
drop_columns=drop_columns, | ||
target=target, | ||
) | ||
return dataset_trn, dataset_tst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# {% include 'template/license_header' %} | ||
|
||
from typing import List, Optional | ||
|
||
from steps import ( | ||
data_loader, | ||
inference_preprocessor, | ||
inference_predict, | ||
) | ||
from zenml import pipeline, ExternalArtifact | ||
from zenml.client import Client | ||
from zenml.logger import get_logger | ||
|
||
logger = get_logger(__name__) | ||
|
||
|
||
@pipeline | ||
def inference( | ||
test_size: float = 0.2, | ||
drop_na: Optional[bool] = None, | ||
normalize: Optional[bool] = None, | ||
drop_columns: Optional[List[str]] = None, | ||
): | ||
""" | ||
Model training pipeline. | ||
This is a pipeline that loads the data, processes it and splits | ||
it into train and test sets, then search for best hyperparameters, | ||
trains and evaluates a model. | ||
Args: | ||
test_size: Size of holdout set for training 0.0..1.0 | ||
drop_na: If `True` NA values will be removed from dataset | ||
normalize: If `True` dataset will be normalized with MinMaxScaler | ||
drop_columns: List of columns to drop from dataset | ||
""" | ||
### ADD YOUR OWN CODE HERE - THIS IS JUST AN EXAMPLE ### | ||
# Link all the steps together by calling them and passing the output | ||
# of one step as the input of the next step. | ||
client = Client() | ||
random_state = client.get_artifact("dataset").run_metadata["random_state"].value | ||
target = "target" | ||
df_inference = data_loader(random_state=random_state, is_inference=True) | ||
df_inference = inference_preprocessor( | ||
dataset_inf=df_inference, | ||
preprocess_pipeline=ExternalArtifact(name="preprocess_pipeline"), | ||
target=target, | ||
) | ||
inference_predict( | ||
dataset_inf=df_inference, | ||
) | ||
### END CODE HERE ### |
Oops, something went wrong.