Skip to content

Commit

Permalink
Merge branch 'NOAA-GFDL:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nishsilva authored Apr 29, 2024
2 parents 8da5902 + c739670 commit c6b2ed2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/environment_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def __init__(self, config: util.NameSpace, log):
if file_.endswith('.yml'):
name, _ = os.path.splitext(file_)
self.env_list.append(name.split('env_')[-1])


# find conda executable
# conda_init for bash defines conda as a shell function; will get error
Expand Down Expand Up @@ -168,7 +167,7 @@ def __init__(self, config: util.NameSpace, log):
# find where environments are installed
self.conda_env_root = config.conda_env_root
if not os.path.isdir(self.conda_env_root):
self.log.warning("Conda env directory '%s' not found; creating.",
self.log.log.warning("Conda env directory '%s' not found; creating.",
self.conda_env_root)
os.makedirs(self.conda_env_root) # recursive mkdir if needed
else:
Expand All @@ -179,8 +178,8 @@ def create_environment(self, env_name):
# check to see if conda env exists, and if not, try to create it
conda_prefix = os.path.join(self.conda_env_root, env_name)
if not os.path.exists(conda_prefix):
self.log.warning(("Conda env '%s' not found (grepped for '%s'); "
"continuing."), env_name, conda_prefix)
self.log.log.warning(("Conda env '%s' not found (grepped for '%s'); "
"continuing."), env_name, conda_prefix)

def _call_conda_create(self, env_name):
if env_name.startswith(self.env_name_prefix):
Expand All @@ -189,10 +188,10 @@ def _call_conda_create(self, env_name):
short_name = env_name
path = f"{self.conda_dir}/env_{short_name}.yml"
if not os.path.exists(path):
self.log.error("Can't find %s", path)
self.log.log.error("Can't find %s", path)
else:
conda_prefix = os.path.join(self.conda_env_root, env_name)
self.log.info("Creating conda env '%s' in '%s'.", env_name, conda_prefix)
self.log.log.info("Creating conda env '%s' in '%s'.", env_name, conda_prefix)
cmd = (
f'source {self.conda_dir}/conda_init.sh {self.conda_root} && '
f'{self.conda_exe} env create --force -q -p "{conda_prefix}" -f "{path}"'
Expand Down

0 comments on commit c6b2ed2

Please sign in to comment.