Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/ms_pred/dag_pred/iceberg_elucidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ def iceberg_prediction(
df.to_csv(save_dir / f'cands_df_{exp_name}.tsv', sep='\t', index=False)

# run iceberg to generate in-silico spectrum
cmd = (f'''{python_path} src/ms_pred/dag_pred/predict_smis.py \\
# Resolve predict_smis.py relative to this package, not the current working
# directory, so it also works when ms_pred is pip-installed (no src/ checkout).
predict_script = Path(__file__).resolve().parent / "predict_smis.py"
cmd = (f'''{python_path} {predict_script} \\
--batch-size {batch_size} \\
--num-workers {num_workers} \\
--dataset-labels {save_dir / f"cands_df_{exp_name}.tsv"} \\
Expand Down
5 changes: 3 additions & 2 deletions src/ms_pred/dag_pred/predict_smis.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def predict():
save_dir = Path(kwargs["save_dir"])
debug = kwargs["debug"]
common.setup_logger(save_dir, log_name="joint_pred.log", debug=debug)
pl.utilities.seed.seed_everything(kwargs.get("seed"))
pl.seed_everything(kwargs.get("seed"))

# Dump args
yaml_args = yaml.dump(kwargs)
Expand Down Expand Up @@ -195,7 +195,8 @@ def producer_func(batch):
else:
device = "cpu"
model.to(device)
torch.cuda.set_device(gpu_id) # avoids error in pe_embedding under multithreading.
if gpu and avail_gpu_num > 0:
torch.cuda.set_device(gpu_id) # avoids error in pe_embedding under multithreading

# for batch in batched_entries:
smis, spec_names, colli_eng_vals, adducts, instruments, precursor_mzs, h5_names = list(zip(*batch))
Expand Down