WestHealth / pyvis

Python package for creating and visualizing interactive network graphs.
http://pyvis.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
1k stars 172 forks source link

[ERROR] OSError: [Errno 30] Read-only file system: 'lib' #294

Open pei-lin-ml opened 3 months ago

pei-lin-ml commented 3 months ago

https://github.com/WestHealth/pyvis/blame/ccb7ce745ee4159ce45eac70b9848ab965fc0906/pyvis/network.py#L519

This hard coding prevents execution in AWS lambda function. Stack trace: [ERROR] OSError: [Errno 30] Read-only file system: 'lib' Traceback (most recent call last): File "/var/task/lambda_function.py", line 101, in handler plot_graph_for_originator(df, originator) File "/var/task/lambda_function.py", line 53, in plot_graph_for_originator nt.save_graph(f"/tmp/{html_file}") File "/var/lang/lib/python3.11/site-packages/pyvis/network.py", line 438, in save_graph self.write_html(name) File "/var/lang/lib/python3.11/site-packages/pyvis/network.py", line 519, in write_html os.makedirs("lib") File "<frozen os>", line 225, in makedirs

Instead of hard coded lib, it should take the output dir from the designated output file, in the lambda function case it is /tmp.

FlxVctr commented 1 month ago

Used it in another context than AWS lambda (Beeware framework), but got this fixed by adding the argument by changing cdn_resources from its standard value ('local')

net = Network(notebook=False, cdn_resources="in_line")

Then it switches to @pei-lin-ml's desired behaviour: https://github.com/WestHealth/pyvis/blob/ccb7ce745ee4159ce45eac70b9848ab965fc0906/pyvis/network.py#L528