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
Changes from 1 commit
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
Next Next commit
put linea dir in root
  • Loading branch information
yifanwu committed Apr 14, 2022
commit 3a7ae43449bd2761ec3c2ed48cc87db0301307a4
24 changes: 8 additions & 16 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
linea_folder = Path.home() / FOLDER_NAME
if not linea_folder.exists():
logger.warning(
"No .linea folder found. Creating a new folder in current directory."
)
linea_folder.mkdir(parents=False, exist_ok=True)
return linea_folder