diff --git a/cadetrdm/cli_integration.py b/cadetrdm/cli_integration.py index 65990abe6b7a3d0c8b4f381309650dfbd0f72828..d2c85b0616d387d1f59cad3c1577cc8e03c1c259 100644 --- a/cadetrdm/cli_integration.py +++ b/cadetrdm/cli_integration.py @@ -97,11 +97,9 @@ def add_remote_to_repo(remote_url: str, path_to_repo="."): @cli.command() @click.argument('file_type') -def add_file_type_to_lfs(file_type: str, ): - init_lfs(lfs_filetypes=[file_type], path=".") +def add_filetype_to_lfs(file_type: str, ): repo = BaseRepo(".") - repo.add_all_files() - repo.commit(f"Add {file_type} to lfs") + repo.add_filetype_to_lfs(file_type) @cli.command() diff --git a/cadetrdm/repositories.py b/cadetrdm/repositories.py index 6fc2d69d6ed8f78a286a0272960334dfe546bf28..1c1d246d7d6f8b5eaf0db948a0af6318c3e7021f 100644 --- a/cadetrdm/repositories.py +++ b/cadetrdm/repositories.py @@ -15,6 +15,7 @@ from ipylab import JupyterFrontEnd from tabulate import tabulate import pandas as pd +from cadetrdm.initialize_repo import init_lfs from cadetrdm.io_utils import recursive_chmod, write_lines_to_file, wait_for_user from cadetrdm.jupyter_functionality import Notebook from cadetrdm.remote_integration import create_gitlab_remote @@ -145,7 +146,17 @@ class BaseRepo: project_repo.add_list_of_remotes_in_readme_file("output_repo", self.remote_urls) project_repo.commit("Add remote for output repo") + def add_filetype_to_lfs(self, file_type): + """ + Add the filetype given in file_type to the GIT-LFS tracking + :param file_type: + Wildcard formatted string. Examples: "*.png" or "*.xlsx" + :return: + """ + init_lfs(lfs_filetypes=[file_type], path=self.working_dir) + self.add_all_files() + self.commit(f"Add {file_type} to lfs") def import_remote_repo(self, source_repo_location, source_repo_branch, target_repo_location=None): """ diff --git a/docs/source/user_guide/getting-started.md b/docs/source/user_guide/getting-started.md index fa9060bfc9eb313e051ae5d49d8b3d0d65c7f8d4..6e0561fac4a8defed39a19dcb0f425eb84fdc3f9 100644 --- a/docs/source/user_guide/getting-started.md +++ b/docs/source/user_guide/getting-started.md @@ -35,3 +35,20 @@ repo.create_gitlab_remotes( name="e.g. API_test_project" ) ``` + +## Extending GIT-LFS scope + +Several common datatypes are included in GIT-LFS by default. These currently are +`"*.jpg", "*.png", "*.xlsx", "*.h5", "*.ipynb", "*.pdf", "*.docx", "*.zip", "*.html"` + +You can add datatypes you require by running: + +````python +repo.add_filetype_to_lfs("*.npy") +```` + +or + +````commandline +cadet-rdm add_filetype_to_lfs *.npy +````