-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from dapomeroy/redirect_prints
Redirect prints from Spack to log file
- Loading branch information
Showing
17 changed files
with
284 additions
and
145 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -113,12 +113,14 @@ def _software_install_requested_compilers(self, workspace): | |
for pkg_name in workspace.software_environments.get_env_packages(app_context): | ||
pkg_spec = workspace.software_environments.get_spec(pkg_name) | ||
if 'compiler' in pkg_spec: | ||
tty.debug(f'Trying to install compiler: {pkg_spec["compiler"]}') | ||
tty.msg('Installing compilers') | ||
tty.debug(f'Compilers: {pkg_spec["compiler"]}') | ||
comp_spec = workspace.software_environments.get_spec(pkg_spec['compiler']) | ||
self.spack_runner.install_compiler(comp_spec['spack_spec']) | ||
|
||
except ramble.spack_runner.RunnerError as e: | ||
tty.die(e) | ||
with self.logger.force_echo(): | ||
tty.die(e) | ||
|
||
def _software_create_env(self, workspace): | ||
"""Create the spack environment for this experiment | ||
|
@@ -127,6 +129,8 @@ def _software_create_env(self, workspace): | |
file for it. | ||
""" | ||
|
||
tty.msg('Creating Spack environment') | ||
|
||
# See if we cached this already, and if so return | ||
env_path = self.expander.env_path | ||
if not env_path: | ||
|
@@ -178,23 +182,26 @@ def _software_create_env(self, workspace): | |
added_packages = set(self.spack_runner.added_packages()) | ||
for pkg in self.required_packages.keys(): | ||
if pkg not in added_packages: | ||
tty.die(f'Software spec {pkg} is not defined ' | ||
f'in environment {env_context}, but is required ' | ||
f'to by the {self.name} application ' | ||
'definition') | ||
with self.logger.force_echo(): | ||
tty.die(f'Software spec {pkg} is not defined ' | ||
f'in environment {env_context}, but is required ' | ||
f'to by the {self.name} application ' | ||
'definition') | ||
|
||
for mod_inst in self._modifier_instances: | ||
for pkg in mod_inst.required_packages.keys(): | ||
if pkg not in added_packages: | ||
tty.die(f'Software spec {pkg} is not defined ' | ||
f'in environment {env_context}, but is required ' | ||
f'to by the {mod_inst.name} modifier ' | ||
'definition') | ||
with self.logger.force_echo(): | ||
tty.die(f'Software spec {pkg} is not defined ' | ||
f'in environment {env_context}, but is required ' | ||
f'to by the {mod_inst.name} modifier ' | ||
'definition') | ||
|
||
self.spack_runner.deactivate() | ||
|
||
except ramble.spack_runner.RunnerError as e: | ||
tty.die(e) | ||
with self.logger.force_echo(): | ||
tty.die(e) | ||
|
||
def _software_configure(self, workspace): | ||
"""Concretize the spack environment for this experiment | ||
|
@@ -203,6 +210,8 @@ def _software_configure(self, workspace): | |
for this experiment. | ||
""" | ||
|
||
tty.msg('Concretizing Spack environment') | ||
|
||
# See if we cached this already, and if so return | ||
env_path = self.expander.env_path | ||
|
||
|
@@ -224,7 +233,8 @@ def _software_configure(self, workspace): | |
self.spack_runner.concretize() | ||
|
||
except ramble.spack_runner.RunnerError as e: | ||
tty.die(e) | ||
with self.logger.force_echo(): | ||
tty.die(e) | ||
|
||
def _software_install(self, workspace): | ||
"""Install application's software using spack""" | ||
|
@@ -243,10 +253,13 @@ def _software_install(self, workspace): | |
self.spack_runner.set_dry_run(workspace.dry_run) | ||
self.spack_runner.set_env(env_path) | ||
|
||
tty.msg('Installing software') | ||
|
||
self.spack_runner.activate() | ||
self.spack_runner.install() | ||
except ramble.spack_runner.RunnerError as e: | ||
tty.die(e) | ||
with self.logger.force_echo(): | ||
tty.die(e) | ||
|
||
def _define_package_paths(self, workspace): | ||
"""Define variables containing the path to all spack packages | ||
|
@@ -266,6 +279,9 @@ def _define_package_paths(self, workspace): | |
Would define a variable `wrf` that contains the installation path of | ||
[email protected] | ||
""" | ||
|
||
tty.msg('Defining Spack variables') | ||
|
||
try: | ||
self.spack_runner.set_dry_run(workspace.dry_run) | ||
self.spack_runner.set_env(self.expander.env_path) | ||
|
@@ -281,12 +297,15 @@ def _define_package_paths(self, workspace): | |
self.variables[spack_pkg_name] = package_path | ||
|
||
except ramble.spack_runner.RunnerError as e: | ||
tty.die(e) | ||
with self.logger.force_echo(): | ||
tty.die(e) | ||
|
||
def _mirror_software(self, workspace): | ||
"""Mirror software source for this experiment using spack""" | ||
import re | ||
|
||
tty.msg('Mirroring software') | ||
|
||
# See if we cached this already, and if so return | ||
env_path = self.expander.env_path | ||
if not env_path: | ||
|
@@ -305,7 +324,8 @@ def _mirror_software(self, workspace): | |
|
||
self.spack_runner.activate() | ||
|
||
mirror_output = self.spack_runner.mirror_environment(workspace._software_mirror_path) | ||
mirror_output = self.spack_runner \ | ||
.mirror_environment(workspace._software_mirror_path) | ||
|
||
present = 0 | ||
added = 0 | ||
|
@@ -339,7 +359,8 @@ def _mirror_software(self, workspace): | |
workspace._software_mirror_stats.errors.add(i) | ||
|
||
except ramble.spack_runner.RunnerError as e: | ||
tty.die(e) | ||
with self.logger.force_echo(): | ||
tty.die(e) | ||
|
||
def _write_inventory(self, workspace): | ||
"""Add software environment information to hash inventory""" | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.