Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

put linea dir in root #595

Merged
merged 7 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions lineapy/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@

def linea_folder() -> Path:
"""
Finds the closest `.linea` folder, raising an exception if one does not exist.
Linea folder exists at the root user level (via `Path.home()`).
"""
cwd = Path(".").resolve()
for i, dir in enumerate([cwd, *cwd.parents]):
possible_linea_folder = dir / FOLDER_NAME
if possible_linea_folder.is_dir():
# Return path relative to CWD, so that it is stable
# regardles of parent path in subdirectories
# for notebook output
return Path("./" + "../" * i) / FOLDER_NAME

# you are here because you could not find a .linea folder anywhere. #418 says create one.
logger.warning(
"No .linea folder found. Creating a new folder in current directory."
)
cwd_linea_folder = Path(".").resolve() / FOLDER_NAME
cwd_linea_folder.mkdir(parents=False, exist_ok=True)
return cwd_linea_folder
# TODO: add a special case for tests (or some scoping config)
linea_folder = Path.home() / FOLDER_NAME
if not linea_folder.exists():
logger.warning(
f"No {FOLDER_NAME} folder found. Creating a new folder in {Path.home()} directory."
)
linea_folder.mkdir(parents=False, exist_ok=True)
return linea_folder
24 changes: 0 additions & 24 deletions tests/unit/test_linea_folder.py

This file was deleted.