[enhancement] Check that the AS project path is a directory, not a file
I was testing a workflow today for Oriol, and accidentally pasted the location of a file. autosubmit create
fails with:
(autosubmit4) bdepaula@bsces107921:~/Development/python/workspace/autosubmit$ autosubmit create a004
/home/bdepaula/mambaforge/envs/autosubmit4/bin/autosubmit:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
__import__('pkg_resources').require('autosubmit==4.1.2')
Autosubmit is running with 4.1.2
Preparing .lock file to avoid multiple instances with same expid.
Copying /home/bdepaula/autosubmit/project/test.sh into /home/bdepaula/autosubmit/a004/proj
cp: cannot stat '/home/bdepaula/autosubmit/project/test.sh/*': Not a directory
Traceback (most recent call last):
File "/home/bdepaula/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 4925, in _copy_code
output = subprocess.check_output(
File "/home/bdepaula/mambaforge/envs/autosubmit4/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/home/bdepaula/mambaforge/envs/autosubmit4/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'cp -R /home/bdepaula/autosubmit/project/test.sh/* /home/bdepaula/autosubmit/a004/proj/local_project' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bdepaula/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 4627, in create
if not Autosubmit._copy_code(as_conf, expid, as_conf.experiment_data.get("PROJECT",{}).get("PROJECT_TYPE","none"), False):
File "/home/bdepaula/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 4932, in _copy_code
raise AutosubmitCritical(
log.log.AutosubmitCritical:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bdepaula/Development/python/workspace/autosubmit/bin/autosubmit", line 57, in main
return_value = Autosubmit.parse_args()
File "/home/bdepaula/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 703, in parse_args
return Autosubmit.create(args.expid, args.noplot, args.hide, args.output, args.group_by, args.expand,
File "/home/bdepaula/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 4798, in create
raise AutosubmitCritical(e.message, e.code, e.trace)
log.log.AutosubmitCritical:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bdepaula/Development/python/workspace/autosubmit/bin/autosubmit", line 37, in exit_from_error
Log.debug(traceback.format_exc())
File "/home/bdepaula/mambaforge/envs/autosubmit4/lib/python3.8/site-packages/log/log.py", line 295, in debug
Log.log.log(Log.DEBUG, msg.format(*args))
IndexError: Replacement index 0 out of range for positional args tuple
[CRITICAL] Can not copy /home/bdepaula/autosubmit/project/test.sh into /home/bdepaula/autosubmit/a004/proj. Exiting... [eCode=7063]
More info at https://autosubmit.readthedocs.io/en/master/troubleshooting/error-codes.htm
We can improve it by simply checking if the Path
object exists and is a directory, and failing with a nicer message to the user.