Skip to content

Commit 2448db5

Browse files
author
Samuel Moors
committed
remove easyblock_type
1 parent b26c69e commit 2448db5

File tree

1 file changed

+25
-30
lines changed

1 file changed

+25
-30
lines changed

easybuild/framework/easyblock.py

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@
125125
class EasyBlock(object):
126126
"""Generic support for building and installing software, base class for actual easyblocks."""
127127

128-
# indicates whether or not this represents an EasyBlock for data or software
129-
# set default value as class attribute, allowing custom easyblocks to override it
130-
easyblock_type = SOFTWARE
131-
132128
# static class method for extra easyconfig parameter definitions
133129
# this makes it easy to access the information without needing an instance
134130
# subclasses of EasyBlock should call this method with a dictionary
@@ -163,6 +159,7 @@ def __init__(self, ec):
163159
# list of patch/source files, along with checksums
164160
self.patches = []
165161
self.src = []
162+
self.data_src = []
166163
self.checksums = []
167164
self.json_checksums = None
168165

@@ -182,11 +179,6 @@ def __init__(self, ec):
182179
# may be set to True by ExtensionEasyBlock
183180
self.is_extension = False
184181

185-
known_easyblock_types = [DATA, SOFTWARE]
186-
if self.easyblock_type not in known_easyblock_types:
187-
raise EasyBuildError(
188-
"EasyBlock type %s is not in list of known types %s", self.easyblock_type, known_easyblock_types)
189-
190182
# easyconfig for this application
191183
if isinstance(ec, EasyConfig):
192184
self.cfg = ec
@@ -215,9 +207,6 @@ def __init__(self, ec):
215207
# determine install subdirectory, based on module name
216208
self.install_subdir = None
217209

218-
# indicates whether build should be performed in installation dir
219-
self.build_in_installdir = self.cfg['buildininstalldir']
220-
221210
# list of locations to include in RPATH filter used by toolchain
222211
self.rpath_filter_dirs = []
223212

@@ -270,6 +259,16 @@ def __init__(self, ec):
270259
# initialize logger
271260
self._init_log()
272261

262+
if self.cfg['sources'] and self.cfg['data_sources']:
263+
raise EasyBuildError("Either easyconfig parameter sources or data_sources should be provided, not both.")
264+
265+
# build_in_installdir indicates whether build should be performed in installation dir
266+
if self.cfg['data_sources']:
267+
self.build_in_installdir = True
268+
self.log.info("Setting build_in_installdir to True for data installations.")
269+
else:
270+
self.build_in_installdir = self.cfg['buildininstalldir']
271+
273272
# try and use the specified group (if any)
274273
group_name = build_option('group')
275274
group_spec = self.cfg['group']
@@ -286,17 +285,6 @@ def __init__(self, ec):
286285
if group_name is not None:
287286
self.group = use_group(group_name)
288287

289-
if self.easyblock_type == SOFTWARE and self.cfg['data_sources']:
290-
raise EasyBuildError(
291-
"Easyconfig parameter 'data_sources' not supported for software installations. Use 'sources' instead.")
292-
if self.easyblock_type == DATA and self.cfg['sources']:
293-
raise EasyBuildError(
294-
"Easyconfig parameter 'sources' not supported for data installations. Use 'data_sources' instead.")
295-
296-
# use 'data_sources' as alias for 'sources'
297-
if self.cfg['data_sources']:
298-
self.cfg['sources'] = self.cfg['data_sources']
299-
300288
# generate build/install directories
301289
self.gen_builddir()
302290
self.gen_installdir()
@@ -488,11 +476,11 @@ def fetch_sources(self, sources=None, checksums=None):
488476
Add a list of source files (can be tarballs, isos, urls).
489477
All source files will be checked if a file exists (or can be located)
490478
491-
:param sources: list of sources to fetch (if None, use 'sources' easyconfig parameter)
479+
:param sources: list of sources to fetch (if None, use 'sources' or 'data_sources' easyconfig parameter)
492480
:param checksums: list of checksums for sources
493481
"""
494482
if sources is None:
495-
sources = self.cfg['sources']
483+
sources = self.cfg['sources'] or self.cfg['data_sources']
496484
if checksums is None:
497485
checksums = self.cfg['checksums']
498486

@@ -773,8 +761,10 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
773761
:param download_instructions: instructions to manually add source (used for complex cases)
774762
:param alt_location: alternative location to use instead of self.name
775763
"""
776-
srcpaths_map = {SOFTWARE: source_paths, DATA: source_paths_data}
777-
srcpaths = srcpaths_map[self.easyblock_type]()
764+
if self.cfg['data_sources']:
765+
srcpaths = source_paths_data()
766+
else:
767+
srcpaths = source_paths()
778768

779769
update_progress_bar(PROGRESS_BAR_DOWNLOAD_ALL, label=filename)
780770

@@ -986,7 +976,7 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
986976
msg = "\nDownload instructions:\n\n" + download_instructions + '\n'
987977
print_msg(msg, prefix=False, stderr=True)
988978
error_msg += "please follow the download instructions above, and make the file available "
989-
error_msg += "in the active source path (%s)" % ':'.join(srcpaths_map[self.easyblock_type]())
979+
error_msg += "in the active source path (%s)" % ':'.join(source_paths())
990980
else:
991981
# flatten list to string with '%' characters escaped (literal '%' desired in 'sprintf')
992982
failedpaths_msg = ', '.join(failedpaths).replace('%', '%%')
@@ -1128,7 +1118,10 @@ def gen_installdir(self):
11281118
"""
11291119
Generate the name of the installation directory.
11301120
"""
1131-
basepath = install_path(self.easyblock_type)
1121+
if self.cfg['data_sources']:
1122+
basepath = install_path(DATA)
1123+
else:
1124+
basepath = install_path(SOFTWARE)
11321125
if basepath:
11331126
self.install_subdir = ActiveMNS().det_install_subdir(self.cfg)
11341127
self.installdir = os.path.join(os.path.abspath(basepath), self.install_subdir)
@@ -2407,8 +2400,10 @@ def fetch_step(self, skip_checksums=False):
24072400
# fetch sources
24082401
if self.cfg['sources']:
24092402
self.fetch_sources(self.cfg['sources'], checksums=self.cfg['checksums'])
2403+
elif self.cfg['data_sources']:
2404+
self.fetch_sources(self.cfg['data_sources'], checksums=self.cfg['checksums'])
24102405
else:
2411-
self.log.info('no sources provided')
2406+
self.log.info('no sources or data_sources provided')
24122407

24132408
if self.dry_run:
24142409
# actual list of patches is printed via _obtain_file_dry_run method

0 commit comments

Comments
 (0)