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

flesh out setting up of configuration into dedicated 'set_up_configuration' function #2638

Merged
merged 6 commits into from Oct 26, 2018

Conversation

Projects
None yet
2 participants
@boegel
Copy link
Member

boegel commented Oct 24, 2018

This is basically just shuffling code around, no functional changes are included.

Having a dedicated function for setting up the EasyBuild configuration is useful to support using the EasyBuild framework as a library (see also the tests that have been added).

Before these changes, you'd run into problems like:

$ python -c "from easybuild.tools.run import run_cmd; run_cmd('echo hello')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Volumes/work/easybuild-framework/easybuild/tools/run.py", line 87, in cache_aware_func
    res = func(cmd, *args, **kwargs)
  File "/Volumes/work/easybuild-framework/easybuild/tools/run.py", line 127, in run_cmd
    if log_output or (trace and build_option('trace')):
  File "/Volumes/work/easybuild-framework/easybuild/tools/config.py", line 448, in build_option
    raise EasyBuildError("Undefined build option: %s", key)
easybuild.tools.build_log.EasyBuildError: 'Undefined build option: trace'

When set_up_configuration is used, things work as expected:

$ python -c "from easybuild.tools.options import set_up_configuration; 
set_up_configuration(silent=True); from easybuild.tools.run import run_cmd;
print run_cmd('echo hello')"
('hello\n', 0)

Also, a clearer error is now produced in case set_up_configuration was not called first:

easybuild.tools.build_log.EasyBuildError: "Undefined build option: 'trace'.
Make sure you have set up the EasyBuild configuration using set_up_configuration()
(from easybuild.tools.options) in case you're not using EasyBuild via the 'eb' CLI."

boegel added some commits Oct 23, 2018

@boegel boegel added this to the 3.8.0 milestone Oct 24, 2018

@boegel boegel requested a review from bartoldeman Oct 26, 2018

@bartoldeman
Copy link
Contributor

bartoldeman left a comment

I checked if you didn't miss deleting any obsolete imports but could not find any. It all looks good to me.

@bartoldeman

This comment has been minimized.

Copy link
Contributor

bartoldeman commented Oct 26, 2018

Going in, thanks @boegel !

@bartoldeman bartoldeman merged commit aca7d92 into easybuilders:develop Oct 26, 2018

2 checks passed

Hound No violations found. Woof!
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@boegel boegel deleted the boegel:eb_as_library branch Oct 26, 2018

@boegel

This comment has been minimized.

Copy link
Member

boegel commented Oct 26, 2018

@bartoldeman My local linter should have noticed if I did miss any obsolete imports ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment