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

Improved logs #244

Merged
merged 1 commit into from
Dec 17, 2021
Merged
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
46 changes: 13 additions & 33 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

import os

from zenml.core.repo import Repository

os.environ["ZENML_DEBUG"] = "true"
import pandas as pd

from zenml.core.repo import Repository
from zenml.pipelines import pipeline
from zenml.steps import step

os.environ["ZENML_DEBUG"] = "true"


@step
def importer() -> pd.DataFrame:
Expand All @@ -45,6 +45,13 @@ def evaluator(df: pd.DataFrame, model: int) -> int:

@step
def deployer(model: int, evaluation_results: int) -> bool:
print(
Repository()
.get_pipeline("my_pipeline")
.runs[-1]
.steps[-2]
.output.read()
)
return True


Expand All @@ -58,42 +65,15 @@ def my_pipeline(importer, preprocesser, trainer, evaluator, deployer):


# Pipeline
lineage_pipeline = my_pipeline(
p = my_pipeline(
importer=importer(),
preprocesser=preprocesser(),
trainer=trainer(),
evaluator=evaluator(),
deployer=deployer(),
)

lineage_pipeline.run()
lineage_pipeline.run()
lineage_pipeline.run()
lineage_pipeline.run()
p.run()

pipeline = Repository().get_pipelines()[-1]

# for run in pipeline.runs:
# try:
# deployer_step = run.get_step(name="deployer")
# trainer_step = run.get_step(name="trainer")
# deployed_model_artifact = deployer_step.inputs["model"]
# trained_model_artifact = trainer_step.output
#
# # lets do the lineage
# print(
# f"trained_model_artifact was produced by: "
# f"{trained_model_artifact.producer_step.id} and is_cached: "
# f"{trained_model_artifact.is_cached} step cached: "
# f"{trainer_step.status}"
# )
# except Exception as e:
# if "No step found for name `deployer`" in str(e):
# pass
# else:
# raise e


from zenml.post_execution.visualizers.lineage.pipeline_lineage_visualizer import PipelineLineageVisualizer

PipelineLineageVisualizer().visualize(pipeline)
pipeline = Repository().get_pipelines()[-1]
17 changes: 13 additions & 4 deletions src/zenml/pipelines/base_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
import inspect
import time
from abc import abstractmethod
from datetime import datetime
from typing import (
Expand Down Expand Up @@ -45,7 +46,7 @@
from zenml.logger import get_logger
from zenml.stacks.base_stack import BaseStack
from zenml.steps.base_step import BaseStep
from zenml.utils import analytics_utils, yaml_utils
from zenml.utils import analytics_utils, string_utils, yaml_utils

logger = get_logger(__name__)
PIPELINE_INNER_FUNC_NAME: str = "connect"
Expand Down Expand Up @@ -105,7 +106,7 @@ def __init__(self, *args: BaseStep, **kwargs: Any) -> None:
self.requirements_file = kwargs.pop(PARAM_REQUIREMENTS_FILE, None)

self.pipeline_name = self.__class__.__name__
logger.info(f"Creating pipeline: {self.pipeline_name}")
logger.info("Creating run for pipeline: `%s`", self.pipeline_name)
logger.info(
f'Cache {"enabled" if self.enable_cache else "disabled"} for '
f"pipeline `{self.pipeline_name}`"
Expand Down Expand Up @@ -272,9 +273,11 @@ def run(self, run_name: Optional[str] = None) -> Any:
},
)

start_time = time.time()
logger.info(
f"Using orchestrator `{self.stack.orchestrator_name}` for "
f"pipeline `{self.pipeline_name}`. Running pipeline.."
"Using stack `%s` for pipeline `%s`. Running pipeline..",
Repository().get_active_stack_key(),
self.pipeline_name,
)

# filepath of the file where pipeline.run() was called
Expand All @@ -287,6 +290,12 @@ def run(self, run_name: Optional[str] = None) -> Any:
)
ret = self.stack.orchestrator.run(self, run_name)
self.stack.orchestrator.post_run()
run_duration = time.time() - start_time
logger.info(
"Pipeline run `%s` has finished in %s.",
run_name,
string_utils.get_human_readable_time(run_duration),
)
return ret

def with_config(
Expand Down