Skip to content

Commit 07b8801

Browse files
committed
fixed error when loupe path is none
1 parent b2e976e commit 07b8801

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/loupepy/convert.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,15 @@ def create_loupe_from_anndata(anndata: AnnData, output_cloupe: str | PathLike =
118118
ValueError: If the obs keys are not valid.
119119
ValueError: If the feature ids are not valid.
120120
'''
121-
if loupe_converter_path is None and not test_mode:
122-
loupe_converter_path = _get_loupe_path()
123-
if not os.path.exists(loupe_converter_path) and not test_mode:
121+
if not test_mode:
124122
if loupe_converter_path is None:
125-
raise ValueError('Loupe converter Not found at default install location.'
126-
'Please run loupepy.setup() to install it or provide a path to the executable.')
127-
else:
128-
raise ValueError(f'Loupe converter not found at {loupe_converter_path}. Please provide a valid path.')
123+
loupe_converter_path = _get_loupe_path()
124+
if not os.path.exists(loupe_converter_path) and not test_mode:
125+
if loupe_converter_path is None:
126+
raise ValueError('Loupe converter Not found at default install location.'
127+
'Please run loupepy.setup() to install it or provide a path to the executable.')
128+
else:
129+
raise ValueError(f'Loupe converter not found at {loupe_converter_path}. Please provide a valid path.')
129130
if test_mode:
130131
logging.warning("Test mode is enabled. Loupe file will not be created.")
131132
clean_tmp_file = False
@@ -172,10 +173,11 @@ def create_loupe(mat: csc_matrix,
172173
_write_hdf5(mat, obs, var, obsm, tmp_file, feature_ids=feature_ids)
173174
if test_mode:
174175
return
175-
if loupe_converter_path is None:
176-
loupe_converter_path = _get_loupe_path()
177-
if not os.path.exists(loupe_converter_path):
178-
raise ValueError('Loupe converter path does not exist')
176+
if not test_mode:
177+
if loupe_converter_path is None:
178+
loupe_converter_path = _get_loupe_path()
179+
if not os.path.exists(loupe_converter_path):
180+
raise ValueError('Loupe converter path does not exist')
179181
cmd = f"{loupe_converter_path} create --input={tmp_file} --output={output_path}"
180182
if force:
181183
cmd += " --force"

0 commit comments

Comments
 (0)