Manages execution reports for a multi-step flow and publishes them
as Prefect artifacts.
Attributes
number_steps : int
Total number of steps expected in the flow.
report : list[dict]
Accumulated list of step results.
Source code in docs/rs-client-libraries/rs_workflows/utils/artifact_verbose.py
| class ReportManager:
"""
Manages execution reports for a multi-step flow and publishes them
as Prefect artifacts.
Attributes
----------
number_steps : int
Total number of steps expected in the flow.
report : list[dict]
Accumulated list of step results.
"""
def __init__(self):
self.report = []
def success_step(self, step: int, description: str) -> None:
"""
Register a successful step in the report.
"""
item = {
"step": step,
"description": description,
"status": "OK",
}
self.report.append(item)
def failed_step(self, step: int, description: str) -> None:
"""
Register a failed step in the report.
"""
item = {
"step": step,
"description": description,
"status": "NOK",
}
self.report.append(item)
async def push_report(self, key_value: str, description_value: str):
"""
Publish the accumulated report as a Prefect table artifact.
Notes
-----
- Prefect artifact keys must contain only lowercase letters,
numbers, and dashes.
- A timestamp is appended to the description for traceability.
Returns
-------
ArtifactResponse
The Prefect artifact object returned by create_table_artifact().
"""
now = datetime.now()
timestamp = now.strftime("%A %d %B %Y, %H:%M:%S")
await acreate_table_artifact(
key=key_value.lower(),
table=self.report,
description=f"{description_value} - {timestamp}",
)
|
failed_step(step, description)
Register a failed step in the report.
Source code in docs/rs-client-libraries/rs_workflows/utils/artifact_verbose.py
| def failed_step(self, step: int, description: str) -> None:
"""
Register a failed step in the report.
"""
item = {
"step": step,
"description": description,
"status": "NOK",
}
self.report.append(item)
|
push_report(key_value, description_value)
async
Publish the accumulated report as a Prefect table artifact.
Notes
- Prefect artifact keys must contain only lowercase letters,
numbers, and dashes.
- A timestamp is appended to the description for traceability.
Returns
ArtifactResponse
The Prefect artifact object returned by create_table_artifact().
Source code in docs/rs-client-libraries/rs_workflows/utils/artifact_verbose.py
| async def push_report(self, key_value: str, description_value: str):
"""
Publish the accumulated report as a Prefect table artifact.
Notes
-----
- Prefect artifact keys must contain only lowercase letters,
numbers, and dashes.
- A timestamp is appended to the description for traceability.
Returns
-------
ArtifactResponse
The Prefect artifact object returned by create_table_artifact().
"""
now = datetime.now()
timestamp = now.strftime("%A %d %B %Y, %H:%M:%S")
await acreate_table_artifact(
key=key_value.lower(),
table=self.report,
description=f"{description_value} - {timestamp}",
)
|
success_step(step, description)
Register a successful step in the report.
Source code in docs/rs-client-libraries/rs_workflows/utils/artifact_verbose.py
| def success_step(self, step: int, description: str) -> None:
"""
Register a successful step in the report.
"""
item = {
"step": step,
"description": description,
"status": "OK",
}
self.report.append(item)
|