HTML

Video Walkthrough

What will you get with this integration?

This integration lets you log any standalone HTML string object or file with Neptune API and have it displayed interactively in the Neptune UI.

Introduction

This guide will show you how to:

Step 0: Before you start

Make sure you have the neptune-client installed.

pip install neptune-client

This integration is tested with neptune-client==0.9.19

Step 1: Import and initialize Neptune

import neptune.new as neptune
run = neptune.init(api_token='<your_api_token>', project='<your_project_name>')

You can use the api_token='ANONYMOUS' and project='common/html-support' to explore without having to create a Neptune account

Executing this cell will give you a link looking like: https://app.neptune.ai/common/html-support/e/HTMLSUP-13 with common/html-support replaced by your project, and HTMLSUP-13 replaced by your run.

Click on the link to open the run in Neptune. For now, it is empty but keep the tab with the run open to see what happens next.

Step 2: Log HTML objects to Neptune

Create a sample HTML string and file

html_str = "<button type='button', style='background-color:#005879; width:400px; height:400px; font-size:30px'> <a style='color: #ccc', href='https://docs.neptune.ai'> Take me back to the docs!<a> </button>"
with open('sample.html', 'w') as f:
f.write(html_str)

Log HTML string object

run['html_obj'].upload(neptune.types.File.from_content(html_str, extension='html'))

Log HTML file

run['html_file'].upload(neptune.types.File('sample.html'))

Step 3: Stop logging

Once you are done logging, you should stop tracking the run using the stop() method. This is needed only while logging from a notebook environment. While logging through a script, Neptune automatically stops tracking once the script has completed execution.

run.stop()

Step 4: Explore the HTML object in Neptune

The object can be found in the All metadata section:

Conclusion

You’ve learned how to:

  • Initialize Neptune and create a run,

  • Log HTML string objects to Neptune,

  • Log HTML files to Neptune.

What's next

Now that you know how to log HTML objects to Neptune, you can learn: