deusebio / Graph-Machine-Learning

Graph Machine Learning, published by Packt
MIT License
0 stars 1 forks source link

Cannot create path in root directory #15

Closed smithna closed 3 days ago

smithna commented 1 week ago

When I try to import draw_graph on my Mac, I get the following error.

https://github.com/deusebio/Graph-Machine-Learning/blob/513387bb0dd22e5af4b53618b2620e97deb18f61/Chapter01/01_Introduction_Networkx.ipynb#L27

`--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) File /usr/local/Cellar/python@3.9/3.9.20/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py:1323, in Path.mkdir(self, mode, parents, exist_ok) 1322 try: -> 1323 self._accessor.mkdir(self, mode) 1324 except FileNotFoundError:

FileNotFoundError: [Errno 2] No such file or directory: '/data/Chapter01/figures'

During handling of the above exception, another exception occurred:

FileNotFoundError Traceback (most recent call last) File /usr/local/Cellar/python@3.9/3.9.20/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py:1323, in Path.mkdir(self, mode, parents, exist_ok) 1322 try: -> 1323 self._accessor.mkdir(self, mode) 1324 except FileNotFoundError:

FileNotFoundError: [Errno 2] No such file or directory: '/data/Chapter01'

During handling of the above exception, another exception occurred:

OSError Traceback (most recent call last) Cell In[1], line 12 8 import sys 10 sys.path.append(f"{os.getcwd()}/..") ---> 12 from utils import draw_graph

File ~/Documents/Graph-Machine-Learning/Chapter01/../utils.py:19 16 enhanced_edge_color = '#cc2f04' 18 if not FIGURES_DIR.exists(): ---> 19 FIGURES_DIR.mkdir(parents=True) 21 # draw a simple graph 22 def draw_graph(G, node_names={}, filename=None, node_size=50, layout = None, plot_weight=False):

File /usr/local/Cellar/python@3.9/3.9.20/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py:1327, in Path.mkdir(self, mode, parents, exist_ok) 1325 if not parents or self.parent == self: 1326 raise -> 1327 self.parent.mkdir(parents=True, exist_ok=True) 1328 self.mkdir(mode, parents=False, exist_ok=exist_ok) 1329 except OSError: 1330 # Cannot rely on checking for EEXIST, since the operating system 1331 # could give priority to other errors like EACCES or EROFS

File /usr/local/Cellar/python@3.9/3.9.20/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py:1327, in Path.mkdir(self, mode, parents, exist_ok) 1325 if not parents or self.parent == self: 1326 raise -> 1327 self.parent.mkdir(parents=True, exist_ok=True) 1328 self.mkdir(mode, parents=False, exist_ok=exist_ok) 1329 except OSError: 1330 # Cannot rely on checking for EEXIST, since the operating system 1331 # could give priority to other errors like EACCES or EROFS

File /usr/local/Cellar/python@3.9/3.9.20/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py:1323, in Path.mkdir(self, mode, parents, exist_ok) 1319 """ 1320 Create a new directory at this given path. 1321 """ 1322 try: -> 1323 self._accessor.mkdir(self, mode) 1324 except FileNotFoundError: 1325 if not parents or self.parent == self:

OSError: [Errno 30] Read-only file system: '/data'`

It is because this line is trying to create the directory in my root.

https://github.com/deusebio/Graph-Machine-Learning/blob/513387bb0dd22e5af4b53618b2620e97deb18f61/utils.py#L9

deusebio commented 1 week ago

Yes, that's a sensible comment. We have raised a PR (https://github.com/deusebio/Graph-Machine-Learning/pull/21) to address this issue and allow users to customize where they want to store the data using the DATA_FOLDER environment variable. If not set, it falls back to the project folder <root>/data

The previous hardcoded value was there because in docker images we store the data under the folder /data (which people can then map to dedicated folders in their host). We keep this behavior by setting the environment variable DATA_FOLDER in the dockerfile.

deusebio commented 3 days ago

PR has been merged! @smithna feel free to re-open if you are still experiencing issues. Thanks