shy-accountant-549
03/07/2023, 5:16 PMshy-accountant-549
03/07/2023, 5:17 PMimport pandas as pd
from sklearn.datasets import load_wine
from sklearn.linear_model import LogisticRegression
import flytekit.extras.sklearn
from flytekit import task, workflow
@task
def get_data() -> pd.DataFrame:
"""Get the wine dataset."""
return load_wine(as_frame=True).frame
@task
def process_data(data: pd.DataFrame) -> pd.DataFrame:
"""Simplify the task from a 3-class to a binary classification problem."""
return data.assign(target=lambda x: x["target"].where(x["target"] == 0, 1))
@task
def train_model(data: pd.DataFrame, hyperparameters: dict) -> LogisticRegression:
"""Train a model on the wine dataset."""
features = data.drop("target", axis="columns")
target = data["target"]
return LogisticRegression(max_iter=3000, **hyperparameters).fit(features, target)
@workflow
def training_workflow(hyperparameters: dict) -> LogisticRegression:
"""Put all of the steps together into a single workflow."""
data = get_data()
processed_data = process_data(data=data)
return train_model(
data=processed_data,
hyperparameters=hyperparameters,
)
freezing-airport-6809
freezing-airport-6809
freezing-airport-6809
flytectl version
shy-accountant-549
03/07/2023, 5:27 PM(flyte) % flytectl version ~ protopias-mbp
INFO[0000] [0] Couldn't find a config file []. Relying on env vars and pflags.
{
"App": "flytectl",
"Build": "a6b856a",
"Version": "0.6.32",
"BuildTime": "2023-03-07 11:26:50.606778 -0600 CST m=+0.016443210"
}%
shy-accountant-549
03/07/2023, 5:27 PM(flyte) % pip list | grep flyte ~/flytesnacks (master ⚡) protopias-mbp
flyteidl 1.3.9
flytekit 1.4.0
freezing-airport-6809
freezing-airport-6809
freezing-airport-6809
freezing-airport-6809
freezing-boots-56761
freezing-boots-56761
freezing-boots-56761
shy-accountant-549
03/07/2023, 5:55 PMpip install flytekit scikit-learn
brew install flyteorg/homebrew-tap/flytectl
flytectl demo start
export FLYTECTL_CONFIG=~/.flyte/config-sandbox.yaml
pyflyte run --remote example.py training_workflow \
--hyperparameters '{"C": 0.1}'
freezing-airport-6809
freezing-boots-56761
freezing-boots-56761
freezing-boots-56761
freezing-boots-56761
freezing-boots-56761
freezing-airport-6809
freezing-airport-6809
freezing-boots-56761
thankful-minister-83577
freezing-boots-56761
thankful-minister-83577
thankful-minister-83577
freezing-airport-6809
freezing-airport-6809
thankful-minister-83577
thankful-minister-83577
shy-accountant-549
03/07/2023, 6:26 PM@shy-accountant-549 can you confirm?yes 1.3.2 works
high-accountant-32689
03/08/2023, 3:03 AMshy-accountant-549
03/08/2023, 7:24 PM