From 63af69195149ae6f406d62212d48a6132a7d5974 Mon Sep 17 00:00:00 2001 From: Daniel Beltran Mora Date: Thu, 29 Nov 2018 16:35:21 +0100 Subject: [PATCH] Added Warnings at copy process if git model repository is not updated, #266 closed --- autosubmit/autosubmit.py | 12 +++++++++++ autosubmit/git/autosubmit_git.py | 34 ++++++++++++++++++++++++++++++++ docs/source/installation.rst | 1 + 3 files changed, 47 insertions(+) diff --git a/autosubmit/autosubmit.py b/autosubmit/autosubmit.py index ca3a2a955..a669492a5 100644 --- a/autosubmit/autosubmit.py +++ b/autosubmit/autosubmit.py @@ -510,6 +510,7 @@ class Autosubmit: os.mkdir(os.path.join(BasicConfig.LOCAL_ROOT_DIR, exp_id, 'conf')) Log.info("Copying config files...") + # autosubmit config and experiment copied from AS. files = resource_listdir('autosubmit.config', 'files') for filename in files: @@ -550,6 +551,17 @@ class Autosubmit: content = open(os.path.join(conf_copy_id, filename), 'r').read() open(os.path.join(dir_exp_id, "conf", new_filename), 'w').write(content) Autosubmit._prepare_conf_files(exp_id, hpc, Autosubmit.autosubmit_version, dummy) + ##### + autosubmit_config = AutosubmitConfig(copy_id, BasicConfig, ConfigParserFactory()) + if autosubmit_config.check_conf_files(): + project_type = autosubmit_config.get_project_type() + if project_type == "git": + autosubmit_config.check_proj() + autosubmit_git = AutosubmitGit(copy_id[0]) + Log.info("checking model version...") + if not autosubmit_git.check_commit(autosubmit_config): + return False + ##### else: Log.critical("The previous experiment directory does not exist") return '' diff --git a/autosubmit/git/autosubmit_git.py b/autosubmit/git/autosubmit_git.py index 283644fc4..31a5bed2e 100644 --- a/autosubmit/git/autosubmit_git.py +++ b/autosubmit/git/autosubmit_git.py @@ -78,7 +78,41 @@ class AutosubmitGit: else: Log.debug("Not a directory... SKIPPING!") return True + @staticmethod + def check_commit(as_conf): + """ + Function to check uncommited changes + + :param as_conf: experiment configuration + :type as_conf: autosubmit.config.AutosubmitConfig + """ + proj_dir = os.path.join(BasicConfig.LOCAL_ROOT_DIR, as_conf.expid, BasicConfig.LOCAL_PROJ_DIR) + dirname_path = as_conf.get_project_dir() + if path.isdir(dirname_path): + Log.debug("Checking git directory status...") + Log.info("test") + if path.isdir(os.path.join(dirname_path, '.git')): + try: + output = subprocess.check_output("cd {0}; git diff-index HEAD --".format(dirname_path), + shell=True) + except subprocess.CalledProcessError: + Log.info("This is not a git experiment") + return True + if output: + Log.warning("There are commits pending to Git") + return True + else: + output = subprocess.check_output("cd {0}; git log --branches --not --remotes".format(dirname_path), + shell=True) + if output: + Log.warning("Last commits are not pushed to Git") + return True + else: + Log.info("Model Git repository is updated") + Log.result("Model Git repository is updated") + + return True @staticmethod def clone_repository(as_conf, force): """ diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 46fbb5f28..63fe60929 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -8,6 +8,7 @@ How to install The Autosubmit code is maintained in *PyPi*, the main source for python packages. - Pre-requisties: These packages (bash, python2, sqlite3, git-scm > 1.8.2, subversion, dialog and GraphViz) must be available at local host machine. + These packages (argparse, python-dateutil, pyparsing, numpy, pydotplus, matplotlib, paramiko, saga-python, python2-pythondialog and portalocker) must be available for python runtime. .. important:: The host machine has to be able to access HPC's/Clusters via password-less ssh. -- GitLab