Closed ptrebert closed 2 years ago
This issue required additional code at two different locations in the functions.smk
has been changed to:
if not refcon_md:
base_image_name = [(key.split('_')[-1], metadata) for key, metadata in config.items() if key.startswith('metadata_')]
base_image_name = [(base_image, metadata) for base_image, metadata in base_image_name if base_image in select_names]
base_container_path = pl.Path(f'container/{base_image_name}.sif')
if not base_container_path.is_file():
raise ValueError('No base container found. Please follow instructions above to create base container!')
else:
raise ValueError('No "metadata_" keys found in config. Did you forget to load a reference container config?')
also triggered a misleading error message and where therefore changed into:
def select_container_readme(wildcards):
_, refcon_md = _get_container_metadata(wildcards.rc_name_version)[0]
if 'base' in {wildcards.rc_name_version}:
base_container_path = pl.Path(f'container/{wildcards.rc_name_version}.sif')
if not base_container_path.is_file():
raise ValueError('No base container found. Please follow instructions above to create base container')
if 'readme' in refcon_md:
readme_path = f'container/{wildcards.rc_name_version}/README.txt'
else:
readme_path = []
return readme_path
Now the error message looks like this and should make it clearer that an action is required to resolve the problem:
ACTION REQUIRED --- missing base container detected: base_v0.sif
Please run the following build command in the "container" folder:
$ cd /home/sven/Desktop/sandbox/ref-container/container
$ sudo singularity build base_v0.sif base_v0.def
InputFunctionException in line 42 of /home/sven/Desktop/sandbox/ref-container/workflow/rules/packaging.smk:
Error:
ValueError: No base container found. Please follow instructions above to create base container
Wildcards:
rc_name_version=base_v0
Traceback:
File "/home/sven/Desktop/sandbox/ref-container/workflow/rules/functions.smk", line 388, in select_container_readme
File "/home/sven/Desktop/sandbox/ref-container/workflow/rules/functions.smk", line 24, in _get_container_metadata
Commit message: added information when base container is missing
This raises even when the actual problem is that no base image has been built yet, which gives a misleading error message. There should be a point in the code where the decision can be made (= base image does not exist, raise)
https://github.com/core-unit-bioinformatics/reference-container/blob/11ca727a798b2673edf3077587644586d9d242d5/workflow/rules/functions.smk#L20