Skip to content

Commit

Permalink
More error checking when creating env yml.
Browse files Browse the repository at this point in the history
  • Loading branch information
zshaheen committed Jun 27, 2018
1 parent fe1160c commit 72b1eb9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions acme_diags/acme_diags_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,17 @@ def _save_env_yml(results_dir):
cmd = 'conda env export'
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
output, err = p.communicate()

if err:
print('Error when creating env yml file:')
print(err)

fnm = os.path.join(results_dir, 'environment.yml')
with open(fnm, 'w') as f:
f.write(output.decode('utf-8'))
else:
fnm = os.path.join(results_dir, 'environment.yml')
with open(fnm, 'w') as f:
f.write(output.decode('utf-8'))

print('Saved environment yml file to: {}'.format(fnm))
print('Saved environment yml file to: {}'.format(fnm))


def _save_parameter_files(results_dir, parser):
Expand Down Expand Up @@ -125,7 +128,11 @@ def save_provenance(results_dir, parser):
if not os.path.exists(results_dir):
os.makedirs(results_dir, 0o775)

_save_env_yml(results_dir)
try:
_save_env_yml(results_dir)
except:
traceback.print_exc()

_save_parameter_files(results_dir, parser)


Expand Down

0 comments on commit 72b1eb9

Please sign in to comment.