-
Notifications
You must be signed in to change notification settings - Fork 24
Enable multiprocessing #801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
statuses.append(st) | ||
energies.append(en) | ||
xyzs.append(read_rdkit_embedded_conformer_i(rd_mol, i)) | ||
except (RuntimeError, ValueError) as e: |
Check notice
Code scanning / CodeQL
Empty except Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix the problem, modify the empty except
block to at least log the exception using the logger already present in the file (i.e., logger.warning
). This maintains the current program flow (i.e., swallowing the error and proceeding to other fallbacks) but ensures that failures do not go unnoticed during development or in production logs.
The block to change is on line 1681-1682. Replace the pass
with a warning log call, including error details (the captured e
) and context about which label or molecule failed. Use a similar message and approach as the MMFF block above it for consistency.
No new imports or method definitions are needed, as the logger is already set up as logger = get_logger()
.
-
Copy modified line R1682
@@ -1679,7 +1679,7 @@ | ||
energies.append(en) | ||
xyzs.append(read_rdkit_embedded_conformer_i(rd_mol, i)) | ||
except (RuntimeError, ValueError) as e: | ||
pass | ||
logger.warning(f"UFF optimization failed for {label} with error: {e}") | ||
|
||
if optimize and not xyzs and try_ob: | ||
logger.warning(f'Using OpenBabel (instead of RDKit) as a fall back method to generate conformers for {label}. ' |
import time | ||
from typing import Tuple | ||
|
||
from rdkit import Chem |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix the problem, simply remove the unused import statement from rdkit import Chem
on line 19 of benchmark.py
. This will clean up the file by eliminating a redundant module dependency and improve readability and maintainability, as recommended. No other edits, imports, or changes are necessary, since no code in the visible regions depends on this import.
@@ -16,7 +16,6 @@ | ||
import time | ||
from typing import Tuple | ||
|
||
from rdkit import Chem | ||
|
||
# ARC imports | ||
import arc.species.conformers as conformers |
import numpy as np | ||
diff = np.nanmean(np.abs(np.array(new_energies) - np.array(old_energies))) | ||
print(f"Mean |ΔE| (new-old): {diff:.6g}") | ||
except Exception: |
Check notice
Code scanning / CodeQL
Empty except Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
The best way to fix the issue is to handle exceptions in a more informative way. This can be achieved by adding a comment above the except Exception:
block explaining why the exception is being caught and ignored, and by printing/logging an informative error message when an exception occurs. This ensures that if an error happens, the user is aware of the failure and has enough information to debug it, while not interrupting the main benchmarking flow.
How to fix:
- Update the
except Exception:
block at lines 139-140 to print an error message (e.g., to stderr or just as a print statement), including the exception message and optionally a suggestion on how to resolve (e.g., "numpy is required for energy difference calculation"). - Add a brief explanatory comment about why the exception is caught and not re-raised.
Required changes:
- Add a comment above line 139.
- Replace the
pass
statement with a print statement or a logging statement, e.g.,print(f"Failed to compute mean |ΔE|: {e}")
. - Optionally, if you choose to use logging, import the standard library
logging
module at the top (allowed as it's well-known).
-
Copy modified lines R139-R141
@@ -136,9 +136,9 @@ | ||
import numpy as np | ||
diff = np.nanmean(np.abs(np.array(new_energies) - np.array(old_energies))) | ||
print(f"Mean |ΔE| (new-old): {diff:.6g}") | ||
except Exception: | ||
pass | ||
|
||
except Exception as e: | ||
# numpy may be missing, or unexpected math/shape error: fail gracefully and inform the user. | ||
print(f"Could not compute mean |ΔE| (new-old): {e}") | ||
# Simple speed ratio | ||
if s_old["mean"] > 0: | ||
ratio = s_old["mean"] / s_new["mean"] |
…n in conformers module
Running
conformers.rdkit_force_field