WayScience / CytoSnake

Orchestrating high-dimensional cell morphology data processing pipelines
https://cytosnake.readthedocs.io
Creative Commons Attribution 4.0 International
3 stars 3 forks source link

`get_project_dir()` is buggy :lady_beetle: #35

Open axiomcura opened 1 year ago

axiomcura commented 1 year ago

The purpose of get_project_dir() is to return the root directory where the project is taken place, basically where the .cytosnake file is located. However, there is a problem with this implementation here is the source code:

def get_project_root() -> Path:
    """Returns complete path where cytosnake performs the analysis. The function
    will check if `.cytosnake` folder exists, if not an error will be raised.

    Return
    ------
    Path
        Returns absolute path of the project folder

    Raises
    ------
    FileNotFoundError
        Raised with the current directory is not a project folder
    """

    # get current working directory
    project_dir = Path().absolute()

    # check if the `.cytosnake` folder exist
    project_folder = project_dir / ".cytosnake"
    if not project_folder.exists():
        raise FileNotFoundError("Current directory is not a project folder")

    return project_dir

The problem with this function is that it assumes that you're only at the project directory. Therefore if this code is executed elsewhere, it will raise and error that the project directory is not found.

axiomcura commented 1 year ago

There is a work around this issue and it has been implemented #26.

The function find_project_dir() which recursively finds the root project directory.

This means that get_project_dir() must contain this function call or be deprecated.