Skip to content
Snippets Groups Projects
Commit a4c29854 authored by r.jaepel's avatar r.jaepel
Browse files

Ensure git-lfs is installed whenever repo is used.

parent badd2bde
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,6 @@ except ImportError:
import cadetrdm
from cadetrdm.repositories import ProjectRepo, OutputRepo
from cadetrdm.web_utils import ssh_url_to_http_url
from cadetrdm.io_utils import write_lines_to_file, is_tool, wait_for_user, init_lfs
......@@ -33,11 +32,7 @@ def initialize_repo(path_to_repo: str | Path, output_folder_name: (str | bool) =
Include gitignore, gitattributes, and lfs_filetypes kwargs.
:return:
"""
if not is_tool("git-lfs"):
raise RuntimeError("Git LFS is not installed. Please install it via e.g. apt-get install git-lfs or the "
"instructions found below \n"
"https://docs.github.com/en/repositories/working-with-files"
"/managing-large-files/installing-git-large-file-storage")
test_for_lfs()
if gitignore is None:
gitignore = get_default_gitignore() + ["*.ipynb"]
......@@ -109,6 +104,14 @@ def initialize_repo(path_to_repo: str | Path, output_folder_name: (str | bool) =
os.chdir(starting_directory)
def test_for_lfs():
if not is_tool("git-lfs"):
raise RuntimeError("Git LFS is not installed. Please install it via e.g. apt-get install git-lfs or the "
"instructions found below \n"
"https://docs.github.com/en/repositories/working-with-files"
"/managing-large-files/installing-git-large-file-storage")
def initialize_git(folder="."):
starting_directory = os.getcwd()
if folder != ":":
......
......@@ -5,12 +5,14 @@ import os
import shutil
import sys
import traceback
import warnings
from datetime import datetime
from pathlib import Path
from stat import S_IREAD, S_IWRITE
from urllib.request import urlretrieve
import cadetrdm
from cadetrdm.initialize_repo import test_for_lfs
from cadetrdm.io_utils import delete_path
from cadetrdm.io_utils import recursive_chmod, write_lines_to_file, wait_for_user, init_lfs
from cadetrdm.jupyter_functionality import Notebook
......@@ -627,6 +629,8 @@ class ProjectRepo(BaseRepo):
"""
super().__init__(repository_path, search_parent_directories=search_parent_directories, *args, **kwargs)
test_for_lfs()
if output_folder is not None:
print("Deprecation Warning. Setting the outputfolder manually during repo instantiation is deprecated"
" and will be removed in a future update.")
......@@ -635,7 +639,8 @@ class ProjectRepo(BaseRepo):
raise RuntimeError(f"Folder {self.path} does not appear to be a CADET-RDM repository.")
metadata = self.load_metadata()
self._project_uuid = metadata["project_uuid"]
self._output_uuid = metadata["output_uuid"]
self._output_folder = metadata["output_remotes"]["output_folder_name"]
if not (self.path / self._output_folder).exists():
print("Output repository was missing, cloning now.")
......@@ -698,7 +703,7 @@ class ProjectRepo(BaseRepo):
ssh_remotes = list(output_remotes["output_remotes"].values())
http_remotes = [ssh_url_to_http_url(url) for url in ssh_remotes]
if len(ssh_remotes + http_remotes) == 0:
raise RuntimeError("No output remotes configured in .cadet-rdm-data.json")
warnings.warn("No output remotes configured in .cadet-rdm-data.json")
for output_remote in ssh_remotes + http_remotes:
try:
print(f"Attempting to clone {output_remote} into {output_path}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment