-
Notifications
You must be signed in to change notification settings - Fork 305
add generic Dataset easyblock #3246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
akesandgren
merged 9 commits into
easybuilders:develop
from
smoors:20240303140713_new_pr_dataset
May 9, 2025
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9dd8e39
add generic Dataset easyblock
63bb474
set cleanup_data_sources to False by default; use easyblock_type
e9aeef4
bug fix
8835694
implement object storage
6862d7e
add debug log
31a5ff3
Merge branch 'develop' of https://github.com/easybuilders/easybuild-e…
jfgrimm 4e2021b
make suggested changes
c5db2b5
increase subdirs to 8
377dabc
use puppet style; update copyright
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| ## | ||
| # Copyright 2009-2023 Ghent University | ||
| # | ||
| # This file is part of EasyBuild, | ||
| # originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), | ||
| # with support of Ghent University (http://ugent.be/hpc), | ||
| # the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), | ||
| # Flemish Research Foundation (FWO) (http://www.fwo.be/en) | ||
| # and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). | ||
| # | ||
| # https://github.com/easybuilders/easybuild | ||
| # | ||
| # EasyBuild is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation v2. | ||
| # | ||
| # EasyBuild is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. | ||
| ## | ||
| """ | ||
| EasyBuild support for installing datasets | ||
|
|
||
| @author: Samuel Moors (Vrije Universiteit Brussel) | ||
| """ | ||
| import os | ||
|
|
||
| from easybuild.framework.easyblock import EasyBlock | ||
| from easybuild.easyblocks.generic.binary import Binary | ||
| from easybuild.framework.easyconfig.default import CUSTOM | ||
| from easybuild.tools.build_log import EasyBuildError | ||
| from easybuild.tools.filetools import compute_checksum, create_index, is_readable, mkdir, move_file, remove_file | ||
| from easybuild.tools.filetools import symlink | ||
| from easybuild.tools.utilities import trace_msg | ||
|
|
||
|
|
||
| class Dataset(Binary): | ||
| """Support for installing datasets""" | ||
|
|
||
| @staticmethod | ||
| def extra_options(extra_vars=None): | ||
| """Extra easyconfig parameters specific to Data easyblock.""" | ||
| extra_vars = EasyBlock.extra_options(extra_vars) | ||
| extra_vars.update({ | ||
| 'extract_sources': [True, "Whether or not to extract data sources", CUSTOM], | ||
| 'data_install_path': [None, "Custom installation path for datasets", CUSTOM], | ||
| 'cleanup_data_sources': [False, "Whether or not to delete the data sources after installation", CUSTOM] | ||
| }) | ||
| return extra_vars | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| """Initialize Dataset-specific variables.""" | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| if self.cfg['sources']: | ||
| raise EasyBuildError( | ||
| "Easyconfig parameter 'sources' is not supported for this EasyBlock. Use 'data_sources' instead.") | ||
|
|
||
| if self.cfg['data_install_path']: | ||
| self.installdir = self.cfg['data_install_path'] | ||
|
|
||
| # extract/copy sources directly into installation directory | ||
| self.build_in_installdir = True | ||
|
|
||
| def install_step(self): | ||
| """No install step, datasets are extracted directly into installdir""" | ||
| pass | ||
|
|
||
| def post_processing_step(self): | ||
| """Add files to object_storage, remove duplicates, add symlinks""" | ||
| trace_msg('adding files to object_storage...') | ||
|
|
||
| # creating object storage at root of software name to reuse identical files in different versions | ||
| object_storage = os.path.join(os.pardir, 'object_storage') | ||
| datafiles = create_index(os.curdir) | ||
|
|
||
| for datafile in datafiles: | ||
| cks = compute_checksum(datafile, checksum_type='sha256') | ||
| objstor_file = os.path.join( | ||
| object_storage, cks[0], cks[1], cks[2], cks[3], cks[4], cks[5], cks[6], cks[7], cks[8:]) | ||
smoors marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mkdir(os.path.dirname(objstor_file), parents=True) | ||
| if is_readable(objstor_file): | ||
| remove_file(datafile) | ||
| else: | ||
| move_file(datafile, objstor_file) | ||
| # use relative paths for symlinks to easily relocate data installations later on if needed | ||
| symlink(objstor_file, datafile, use_abspath_source=False) | ||
| self.log.debug(f"Created symlink {datafile} to {objstor_file}") | ||
|
|
||
| def cleanup_step(self): | ||
| """Cleanup sources after installation""" | ||
| if self.cfg['cleanup_data_sources']: | ||
| for src in self.src: | ||
| self.log.info(f"Removing data source {src['name']}") | ||
| remove_file(src['path']) | ||
| super().cleanup_step() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.