Create Plotly and other rich notebook outputs from code interpreter runs.
Interactive libraries such as Plotly can emit HTML or JavaScript-backed notebook
outputs. For the most portable workflow, save interactive charts as HTML files
and download or serve them from the machine.
result = machine.run_code("""import plotly.express as pxfig = px.line(x=[1, 2, 3], y=[1, 4, 9], title="Interactive chart")fig.write_html("/workspace/chart.html")fig.show()""")print(any(item.html or item.javascript for item in result.results))
Rich result objects (item.html, item.javascript) are SDK-only. Via the CLI
or HTTP API, write the chart to an HTML file (as above) and fetch it with code artifact download or a filesystem read.Read the generated HTML directly:
html = machine.files.read("/workspace/chart.html")