Closed 25shmeckles closed 1 year ago
This is a feature I did not implement yet, currently the path is passed only like this: https://github.com/Octoframes/jupyter_capture_output/blob/0fbade42e93f7915c310728cde9b5ac46776574d/jupyter_capture_output/co_cellmagic.py#L79 A starting point for an implementation will be this:
if path.exists():
print("Path is there")
else:
print("Path will be created")
path.mkdir()
I don't have time right now to think this completely through, but in end September I will have more free time to have a look on this.
My problem is not about creating the directory. The directory exists. The problem is that the output gets written correctly to a file in the current working directory, but somehow it doesn't work if the path is pointing somewhere else.
So, with %%capture_text --path mylog.txt
works but %%capture_text --path ./log/mylog.txt
doesn't. The path exists, of course.
okay, I see! I am planing to make a proper implementation of the path integration, probably end of September.
@25shmeckles, I've just implemented a proper path system with pathlib, could you test this again with the latest jupyter_capture_output version (that is version 0.0.7) ? Here is a notebook that can be used for testing: https://github.com/Octoframes/jupyter_capture_output/blob/main/cap_example_notebook.ipynb
It looks ok. It saves the log in the proper folder now, and it creates the folder structure if it doesn't exist. Good job!
Glad to hear this. I am closing this issue now.
The following doesn't work.
It doesn't throw any error. It simply won't write any file. I have the impression that it has some issues with relative paths.
If I pass only the file name
path ="mylog.txt"
, it works as expected, and it writes a file in the same folder of the running notebook. However, I want to write the log in another folder. Of course, the folder exists. This is my tree: