Skip to content

Commit

Permalink
Merge branch 'feature/add-sagemaker-schedule' of github.com:zenml-io/…
Browse files Browse the repository at this point in the history
…zenml into feature/add-sagemaker-schedule
  • Loading branch information
htahir1 committed Jan 9, 2025
2 parents 467f25b + 9542ed8 commit 48f93ff
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
10 changes: 4 additions & 6 deletions examples/e2e/steps/deployment/deployment_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@


@step
def deployment_deploy() -> (
Annotated[
Optional[MLFlowDeploymentService],
ArtifactConfig(name="mlflow_deployment", is_deployment_artifact=True),
]
):
def deployment_deploy() -> Annotated[
Optional[MLFlowDeploymentService],
ArtifactConfig(name="mlflow_deployment", is_deployment_artifact=True),
]:
"""Predictions step.
This is an example of a predictions step that takes the data in and returns
Expand Down
8 changes: 4 additions & 4 deletions examples/e2e/steps/training/model_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ def model_evaluator(
dataset_trn.drop(columns=[target]),
dataset_trn[target],
)
logger.info(f"Train accuracy={trn_acc*100:.2f}%")
logger.info(f"Train accuracy={trn_acc * 100:.2f}%")
tst_acc = model.score(
dataset_tst.drop(columns=[target]),
dataset_tst[target],
)
logger.info(f"Test accuracy={tst_acc*100:.2f}%")
logger.info(f"Test accuracy={tst_acc * 100:.2f}%")
mlflow.log_metric("testing_accuracy_score", tst_acc)

messages = []
if trn_acc < min_train_accuracy:
messages.append(
f"Train accuracy {trn_acc*100:.2f}% is below {min_train_accuracy*100:.2f}% !"
f"Train accuracy {trn_acc * 100:.2f}% is below {min_train_accuracy * 100:.2f}% !"
)
if tst_acc < min_test_accuracy:
messages.append(
f"Test accuracy {tst_acc*100:.2f}% is below {min_test_accuracy*100:.2f}% !"
f"Test accuracy {tst_acc * 100:.2f}% is below {min_test_accuracy * 100:.2f}% !"
)
if fail_on_accuracy_quality_gates and messages:
raise RuntimeError(
Expand Down
4 changes: 3 additions & 1 deletion examples/e2e_nlp/steps/deploying/huggingface_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def deploy_to_huggingface(
"""
### ADD YOUR OWN CODE HERE - THIS IS JUST AN EXAMPLE ###
secret = Client().get_secret("huggingface_creds")
assert secret, "No secret found with name 'huggingface_creds'. Please create one that includes your `username` and `token`."
assert secret, (
"No secret found with name 'huggingface_creds'. Please create one that includes your `username` and `token`."
)
token = secret.secret_values["token"]
api = HfApi(token=token)
hf_repo = api.create_repo(
Expand Down
10 changes: 4 additions & 6 deletions examples/e2e_nlp/steps/promotion/promote_get_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@


@step
def promote_get_metrics() -> (
Tuple[
Annotated[Dict[str, Any], "latest_metrics"],
Annotated[Dict[str, Any], "current_metrics`"],
]
):
def promote_get_metrics() -> Tuple[
Annotated[Dict[str, Any], "latest_metrics"],
Annotated[Dict[str, Any], "current_metrics`"],
]:
"""Get metrics for comparison for promoting a model.
This is an example of a metric retrieval step. It is used to retrieve
Expand Down
6 changes: 3 additions & 3 deletions examples/llm_finetuning/steps/promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def promote(

msg = (
f"`{metric}` values to compare:\n"
f"base={base_metrics[metric]*100:.2f}%\n"
f"finetuned={ft_metrics[metric]*100:.2f}%"
f"base={base_metrics[metric] * 100:.2f}%\n"
f"finetuned={ft_metrics[metric] * 100:.2f}%"
)
if staging_metrics:
msg += f"\nstaging={staging_metrics[metric]*100:.2f}%"
msg += f"\nstaging={staging_metrics[metric] * 100:.2f}%"
logger.info(msg)

if base_metrics[metric] <= ft_metrics[metric]:
Expand Down
2 changes: 1 addition & 1 deletion examples/mlops_starter/steps/model_promoter.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def model_promoter(accuracy: float, stage: str = "production") -> bool:

if accuracy < 0.8:
logger.info(
f"Model accuracy {accuracy*100:.2f}% is below 80% ! Not promoting model."
f"Model accuracy {accuracy * 100:.2f}% is below 80% ! Not promoting model."
)
else:
logger.info(f"Model promoted to {stage}!")
Expand Down

0 comments on commit 48f93ff

Please sign in to comment.