Mitch
02/19/2025, 11:48 PMMarvin
02/19/2025, 11:48 PMcreate_table_artifact
function can be called directly, and it accepts a table
argument, which can be provided as either a list of lists, a list of dictionaries, or a dictionary of lists. This function does not inherently require a task to be utilized.
Here's a brief example of how you might use it:
python
from prefect.artifacts import create_table_artifact
# Example table data
table_data = [
{"column1": "value1", "column2": "value2"},
{"column1": "value3", "column2": "value4"}
]
# Create the table artifact
create_table_artifact(
key="example-table",
table=table_data,
description="An example table artifact"
)
You can find more details on the Prefect documentation.Mitch
02/19/2025, 11:48 PMMarvin
02/19/2025, 11:49 PMcreate_table_artifact
function can be used within the flow context. Here's how you can do it:
python
from prefect import flow
from prefect.artifacts import create_table_artifact
@flow
def my_flow():
# Example table data
table_data = [
{"column1": "value1", "column2": "value2"},
{"column1": "value3", "column2": "value4"}
]
# Create the table artifact
create_table_artifact(
key="example-table",
table=table_data,
description="An example table artifact"
)
if __name__ == "__main__":
my_flow()
By placing the create_table_artifact
function call within a flow, you can still utilize Prefect's orchestration features without the need to define a separate task for the artifact creation.