Project-oriented workflow in Python
Slowing down. Last release over 3 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install pyprojrootProject-oriented workflow in Python
Finding project directories in Python (data science) projects.
This library aims to provide both
the programmatic functionality from the R rprojroot package
and the interactive functionality from the R here package.
Motivation
Problem: I have a project that has a specific folder structure, for example, one mentioned in Noble 2009 or something similar to this project template, and I want to be able to:
- Run my python scripts without having to specify a series of
../to get to thedatafolder. cdinto the directory of my python script instead of calling it from the root project directory and specify all the folders to the script.- Reference datasets from a root directory when using a jupyter notebook because everytime I use a jupyter notebook, the working directory changes to the location of the notebook, not where I launched the notebook server.
Solution: pyprojroot finds the root working directory for your project as a pathlib.Path object.
You can now use the here function to pass in a relative path from the project root directory
(no matter what working directory you are in the project),
and you will get a full path to the specified file.
That is, in a jupyter notebook,
you can write something like pandas.read_csv(here('data/my_data.csv'))
instead of pandas.read_csv('../data/my_data.csv').
This allows you to restructure the files in your project without having to worry about changing file paths.
Great for reading and writing datasets!
Further reading:
Installation
pip
python -m pip install pyprojroot