Marc Lipoff

    Marc Lipoff

    1 year ago
    Is there an example of how to create a markdown artifact?
    m

    Mariia Kerimova

    1 year ago
    Hello Marc! There is my super simple example of creating a table.
    from prefect.artifacts import create_markdown
    from prefect import task, Flow
    
    @task
    def get_items():
        item = ["one", "two", "three", "four"]
        items = []
        for i in range(4):
            items.append(item)
        return items
    
    @task()
    def parse_artifact_format(item):
        row = "| " + " | ".join(item) + "|\n"
        return row
    
    @task(name="Create Table")
    def generate_artifact(info_markdown_format):
        table = "".join(info_markdown_format)
        create_markdown(
            f"| Column | Column | Column | Column |\n| ----------- | ----------- | ----------- | ----------- |\n{table}"
        )
    
    
    with Flow(
        name="Markdown Flow"
    ) as flow:
        items = get_items()
        info_markdown_format = parse_artifact_format.map(items)
        generate_artifact(info_markdown_format)
    
    if __name__ == "__main__":
        flow.register(project_name="Examples")
        # flow.run()
    Marc Lipoff

    Marc Lipoff

    1 year ago
    thanks!
    Cooper Marcus

    Cooper Marcus

    1 year ago
    @Berty Pribilovics cool ^^