Enabled filtering of paths in the CPATH variable generated for the wrapper#1436
Conversation
easybuild/easyblocks/t/tensorflow.py
Outdated
| # filter out paths from CPATH | ||
| wrapper_filter = self.cfg['wrapper_filter'] | ||
| cpath = os.getenv('CPATH').split(':') | ||
| filtered_cpath = [path for fil in wrapper_filter for path in cpath if not fil in path] |
There was a problem hiding this comment.
test for membership should be 'not in'
|
@damianam Do you have an example of how you use this, and which exact problem/errors it fixes? |
|
We have |
|
@akesandgren Thoughts on this? |
|
It should do the same regardless of toolchain used or people will get confused |
|
Agreed. We should filter Regarding |
easybuild/easyblocks/t/tensorflow.py
Outdated
| icc_wrapper_txt = INTEL_COMPILER_WRAPPER % { | ||
| 'compiler_path': which('icc'), | ||
| 'cpath': os.getenv('CPATH'), | ||
| 'cpath': cpath, |
easybuild/easyblocks/t/tensorflow.py
Outdated
| package_filter = self.cfg['package_filter'] | ||
| for var in ['CPATH', 'LIBRARY_PATH']: | ||
| path = os.getenv(var).split(':') | ||
| filtered_path = [p for fil in package_filter for p in path if fil not in p] |
There was a problem hiding this comment.
@damianam Please log the value of the environment variable before and after filtering.
easybuild/easyblocks/t/tensorflow.py
Outdated
| extra_vars = { | ||
| # see https://developer.nvidia.com/cuda-gpus | ||
| 'cuda_compute_capabilities': [[], "List of CUDA compute capabilities to build with", CUSTOM], | ||
| 'package_filter': [[], "List of paths to filter out", CUSTOM], |
There was a problem hiding this comment.
It's actually a list of filter patterns for paths (since you're checking with if fil not in p), please clarify that and maybe also rename to cpath_libpath_filter_patterns to make it more explicit?
easybuild/easyblocks/t/tensorflow.py
Outdated
|
|
||
| tmpdir = tempfile.mkdtemp(suffix='-bazel-configure') | ||
|
|
||
| # filter out paths from CPATH and LIBRARY_PATH |
There was a problem hiding this comment.
please add an extra comment line or two explaining why this may be needed
easybuild/easyblocks/t/tensorflow.py
Outdated
| for var in ['CPATH', 'LIBRARY_PATH']: | ||
| path = os.getenv(var).split(':') | ||
| filtered_path = [p for fil in package_filter for p in path if fil not in p] | ||
| os.environ[var] = ':'.join(filtered_path) |
There was a problem hiding this comment.
please use setvar from easybuild.tools.environment (which logs), and use os.pathsep
setvar(var, os.pathsep.join(filtered_path))
easybuild/easyblocks/t/tensorflow.py
Outdated
| self.log.info("$%s old value was %s" % (var, path)) | ||
| filtered_path = os.pathsep.join([p for fil in path_filter for p in path if fil not in p]) | ||
| self.log.info("$%s new value is %s" % (var, filtered_path)) | ||
| setvar(var, filtered_path) |
|
@boegel @akesandgren please review again. |
|
Code looks sane, though I don't know what one would put in the filter. (Literally that is) |
|
Our easyconfig has this: |
easybuild/easyblocks/t/tensorflow.py
Outdated
| # might conflict with dependencies on the system and/or installed with EB. For example: protobuf | ||
| path_filter = self.cfg['path_filter'] | ||
| if len(path_filter > 0): | ||
| self.log.info("Filtering $CPATH and $LIBRARY_PATH") |
There was a problem hiding this comment.
@damianam Please change to:
if path_filter:
self.log.info("Filtering $CPATH and $LIBRARY_PATH with path filter %s", path_filter)
easybuild/easyblocks/t/tensorflow.py
Outdated
| path = os.getenv(var).split(':') | ||
| self.log.info("$%s old value was %s" % (var, path)) | ||
| filtered_path = os.pathsep.join([p for fil in path_filter for p in path if fil not in p]) | ||
| self.log.info("$%s new value is %s" % (var, filtered_path)) |
There was a problem hiding this comment.
@damianam env.setvar already logs both new & old value, so this extra logging is overkill?
easybuild/easyblocks/t/tensorflow.py
Outdated
| if len(path_filter > 0): | ||
| self.log.info("Filtering $CPATH and $LIBRARY_PATH") | ||
| for var in ['CPATH', 'LIBRARY_PATH']: | ||
| path = os.getenv(var).split(':') |
There was a problem hiding this comment.
Please also use os.pathsep here, like you do below:
path = os.getenv(var).split(os.pathsep)|
Reviewed & tested with an existing |
As we know, bazel pulls a lot of stuff on its own. In the existing setup, these versions might conflict with packages already installed and included in the CPATH variable generated for the
iccwrapper. This PR enables package filtering there. What this does not do is filtering CPATH when usinggcc-based toolchains. Input? Should we extend the filter to work also under other toolchains where a wrapper is not generated?