@@ -47,7 +49,7 @@ class PhenValidationException(Exception):
super().__init__(message)
self.validation_errors=validation_errors
definit(phen_dir):
definit(phen_dir,remote_url):
"""Initial phenotype directory as git repo with standard structure"""
print(f"Initialising Phenotype in directory: {phen_dir}")
phen_path=Path(phen_dir)
...
...
@@ -55,7 +57,7 @@ def init(phen_dir):
# check if directory already exists and ask user if they want to recreate it
configure=False
ifphen_path.exists()andphen_path.is_dir():# Check if it exists and is a directory
user_input=input(f"The phen directory '{phen_path}' already exists. Do you want to reinitialise, deleting all current configuration? (yes/no): ").strip().lower()
user_input=input(f"The phen directory '{phen_path}' already exists. Do you want to reinitialise? (yes/no): ").strip().lower()
ifuser_inputin['yes','y']:
shutil.rmtree(phen_path)
configure=True;
...
...
@@ -66,9 +68,27 @@ def init(phen_dir):
# configure the phen directories
ifconfigure:
# create root phen directory
repo=None
# remote then clone the repo
ifremote_url!=None:
try:
repo=git.cmd.Git()
repo.clone(remote_url,phen_path)
repo=git.Repo(phen_path)
exceptException:
raiseException(f"Error: remote_url for the repo {remote_url}")
else:
# local then create the directories and init
phen_path.mkdir(parents=True,exist_ok=True)
print(f"Phen directory '{phen_path}' has been created.")