Skip to content

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

Merged
bartoldeman merged 6 commits intoeasybuilders:developfrom
boegel:eb_as_library
Oct 26, 2018
Merged

flesh out setting up of configuration into dedicated 'set_up_configuration' function#2638
bartoldeman merged 6 commits intoeasybuilders:developfrom
boegel:eb_as_library

Conversation

@boegel
Copy link
Copy Markdown
Member

@boegel 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 boegel added this to the 3.8.0 milestone Oct 24, 2018
@boegel boegel requested a review from bartoldeman October 26, 2018 07:15
Copy link
Copy Markdown
Contributor

@bartoldeman bartoldeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bartoldeman
Copy link
Copy Markdown
Contributor

Going in, thanks @boegel !

@bartoldeman bartoldeman merged commit aca7d92 into easybuilders:develop Oct 26, 2018
@boegel boegel deleted the eb_as_library branch October 26, 2018 21:05
@boegel
Copy link
Copy Markdown
Member Author

boegel commented Oct 26, 2018

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

@boegel boegel mentioned this pull request May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants