https://prefect.io logo
f

Francois van Heerden

02/09/2022, 8:09 PM
Is it possible to include a link to a pdf produced as output from a run using the
Artifacts
api? I’m currently using the server backed and a local agent.
k

Kevin Kho

02/09/2022, 9:14 PM
Hi @Francois van Heerden, did you run into an issue when trying? There is a
create_link_artifact
f

Francois van Heerden

02/10/2022, 6:06 AM
Yes, sorry dit try (the very naive)
create_link_artifact("file:///<full_path>")
but this created a link with
localhost:8080/default/flow-run
prepended on the host machine and
<host_ip>:8080/flow_run
on a remote machine, casing a 404 error when accessing the link.
k

Kevin Kho

02/10/2022, 2:14 PM
Could you show me the code that you tried?
f

Francois van Heerden

02/10/2022, 3:11 PM
Copy code
@task(name='Link Document')
def link_document(path):

    # create_link_artifact('file:///{}'.format(path.replace('\\', '/')))

    create_markdown_artifact("Report available at [link](\"file:///{}\").".format(path))
These are the two methods I tried. The
create_markdown_artifact
creates an empty link, while the
create_link_artifact
produces the link with server path prepended as described above.
k

Kevin Kho

02/10/2022, 3:16 PM
Ahh ok I see what you mean but I’m not sure. What you want the link to be? Cuz I don’t think you’ll be able to access the link like that from a remote machine?
f

Francois van Heerden

02/10/2022, 3:34 PM
Ideally an embedded pdf with a download option, in html:
Copy code
<object data="{}" type="application/pdf" width="700px" height="700px">
    <embed src="{}">
        <p>This browser does not support PDFs. Please download the PDF to view it: <a href="{}">Download PDF</a>.</p>
    </embed>
</object>
But I understand that this might be a challenge, as the server is running in a Docker container with no access to the file system.
k

Kevin Kho

02/10/2022, 3:40 PM
I personally don’t know how to shape this link to download from remote. I think this all becomes easier if you maybe use something like S3 to host it?
f

Francois van Heerden

02/10/2022, 3:46 PM
Yes, this is more or less how I currently handle it (use local hosting instead of S3). Was hoping to avoid the additional copying around, as in many instances the pdf will be overwritten many times. Thanks for the help!
2 Views