Skip to content

Commit 8ce3b13

Browse files
committed
Log failures to find conda install folders
1 parent 8a79c63 commit 8ce3b13

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

crates/pet-conda/src/environments.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
package::{CondaPackageInfo, Package},
77
utils::{is_conda_env, is_conda_install},
88
};
9-
use log::warn;
9+
use log::{info, warn};
1010
use pet_core::{
1111
arch::Architecture,
1212
manager::EnvManager,
@@ -76,10 +76,40 @@ pub fn get_conda_environment_info(
7676
return None;
7777
}
7878
// If we know the conda install folder, then we can use it.
79+
let conda_install_folder2 = manager
80+
.clone()
81+
.and_then(|m| m.conda_dir)
82+
.or_else(|| get_conda_installation_used_to_create_conda_env(env_path));
7983
let mut conda_install_folder = match manager {
8084
Some(manager) => manager.conda_dir.clone(),
8185
None => get_conda_installation_used_to_create_conda_env(env_path),
8286
};
87+
match manager {
88+
Some(manager) => {
89+
if conda_install_folder.is_none() {
90+
warn!(
91+
"Given a conda Conda manager but no conda_install_folder for {:?} => {:?}",
92+
env_path, manager
93+
);
94+
} else {
95+
info!(
96+
"Given a conda Conda manager & found the conda_install_folder for {:?} => {:?}",
97+
env_path, manager
98+
);
99+
}
100+
}
101+
None => {
102+
warn!("No conda Conda manager given for {:?}", env_path);
103+
}
104+
}
105+
info!(
106+
"Got ({:?} & {:?}) install folder for {:?} => {:?} and install folder 2 as {:?}",
107+
conda_install_folder.is_some(),
108+
conda_install_folder2.is_some(),
109+
env_path,
110+
conda_install_folder,
111+
conda_install_folder2
112+
);
83113
if let Some(conda_dir) = &conda_install_folder {
84114
if !conda_dir.exists() {
85115
warn!(

crates/pet-conda/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use environment_locations::{
88
get_environments,
99
};
1010
use environments::{get_conda_environment_info, CondaEnvironment};
11-
use log::error;
11+
use log::{error, info};
1212
use manager::CondaManager;
1313
use pet_core::{
1414
env::PythonEnv,
@@ -245,16 +245,22 @@ impl Locator for Conda {
245245
if let Some(env) = environments.get(path) {
246246
return Some(env.clone());
247247
}
248+
info!("Getting conda env info for {:?}", path);
249+
248250
if let Some(env) = get_conda_environment_info(path, &None) {
251+
info!("Got conda env info for {:?} => {:?}", path, env);
249252
if let Some(conda_dir) = &env.conda_dir {
253+
info!("Got Conda dir and now Getting conda manager for {:?}", path);
250254
if let Some(manager) = self.get_manager(conda_dir) {
255+
info!("Got conda manager for {:?} => {:?}", path, manager);
251256
let env = env.to_python_environment(
252257
Some(conda_dir.clone()),
253258
Some(manager.to_manager()),
254259
);
255260
environments.insert(path.clone(), env.clone());
256261
return Some(env);
257262
} else {
263+
error!("Did not get conda manager for {:?}", path);
258264
// We will still return the conda env even though we do not have the manager.
259265
// This might seem incorrect, however the tool is about discovering environments.
260266
// The client can activate this env either using another conda manager or using the activation scripts
@@ -264,6 +270,7 @@ impl Locator for Conda {
264270
return Some(env);
265271
}
266272
} else {
273+
error!("Did not get conda dir for {:?}", path);
267274
// We will still return the conda env even though we do not have the manager.
268275
// This might seem incorrect, however the tool is about discovering environments.
269276
// The client can activate this env either using another conda manager or using the activation scripts
@@ -272,6 +279,8 @@ impl Locator for Conda {
272279
environments.insert(path.clone(), env.clone());
273280
return Some(env);
274281
}
282+
} else {
283+
error!("Did not get conda env info for {:?}", path);
275284
}
276285
}
277286
None

0 commit comments

Comments
 (0)