RZT aiOS allows block developers to publish logs at various levels and publish various metrics so that it can visualized while the block code is running. The logs and metrics associated with a pipeline execution are persisted even after the execution is complete. The metrics can later be used to generate various reports. Block developer can add log messages at various levels
logger.debug(message_str)
logger.info(message_string)
can be used to log an info messagelogger.warn(message_str)
api is can be used to log warning messages.logger.error(message_string)
The below blocks illustrates how various types of logs are displayed in pipeline run. The Block
class has a logger
attribute which has various methods to log messages
import razor.flow as rf
from razor.api import project_space_path
@rf.block
class DemostrateLogging:
def run(self):
self.logger.debug("This is a debug message. Will be displayed only in verbose mode")
self.logger.info("This is an info message")
self.logger.warn("This will be logged as a warning message")
self.logger.error("This will be logged as a error message")
Create a pipeline and run the block
logging_block = DemostrateLogging()
pipeline = rf.Pipeline(targets=[logging_block])
pipeline.execute()
from razor.api.core.metrics import LineGraph
@rf.block
class plot_graph():
def run(self):
line_graph = {}
counter = 0
metrics = {"mse": 1.0}
while counter < 100:
for metric_key, value in metrics.items():
if counter == 0:
line_graph[metric_key] = LineGraph(name=f"{metric_key}",
y_label=[metric_key],
y_type=float,
keys=self._block_params,
x_label='steps')
line_graph[metric_key].post(x=counter, y=[float(counter)])
counter += 1
Create a pipeline using the block
plot_graph = plot_graph()
pipeline = rf.Pipeline(targets=[plot_graph])
List all the deployed engines
razor.api.engines()
Run the pipeline.
Replace <Engine Name>
with the name of engine
razor.api.engines(<Engine Name>).execute(pipeline)
From IDE go to the pipeline runs page and click on metrics
tab to view the graph