Skip to content

Conversation

calvinp0
Copy link
Member

@calvinp0 calvinp0 commented Sep 29, 2025

Running conformers.rdkit_force_field

=== ARC RDKit FF Benchmark ===
SMILES:         CCCCCCCCCCCCCO
Conformers:     200
Repeats:        3
Force field:    MMFF94s
Optimize:       True
Try OpenBabel:  False

New path: rdkit_force_field (batch MMFF)
  mean:   0.017445s   (0.087 ms/conf)
  median: 0.017603s
  min:    0.016794s
  max:    0.017939s

Old path: old_rdkit_force_field (per-conf loop)
  mean:   0.099527s   (0.498 ms/conf)
  median: 0.095866s
  min:    0.093265s
  max:    0.109452s

--- Sanity checks ---
New returned: 200 xyzs, 200 energies
Old returned: 200 xyzs, 200 energies
Energies length match nconfs? True
Mean |ΔE| (new-old): 6.39197e-06

Speedup (old/new mean): 5.71×
=== ARC RDKit FF Benchmark ===
SMILES:         c1ccccc1CCCCCC
Conformers:     200
Repeats:        3
Force field:    MMFF94s
Optimize:       True
Try OpenBabel:  False

New path: rdkit_force_field (batch MMFF)
  mean:   0.014951s   (0.075 ms/conf)
  median: 0.015199s
  min:    0.013868s
  max:    0.015787s

Old path: old_rdkit_force_field (per-conf loop)
  mean:   0.073333s   (0.367 ms/conf)
  median: 0.073987s
  min:    0.071841s
  max:    0.074170s

--- Sanity checks ---
New returned: 200 xyzs, 200 energies
Old returned: 200 xyzs, 200 energies
Energies length match nconfs? True
Mean |ΔE| (new-old): 3.17977e-06

Speedup (old/new mean): 4.90×

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

'except' clause does nothing but pass and there is no explanatory comment.

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().


Suggested changeset 1
arc/species/conformers.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/arc/species/conformers.py b/arc/species/conformers.py
--- a/arc/species/conformers.py
+++ b/arc/species/conformers.py
@@ -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}. '
EOF
@@ -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}. '
Copilot is powered by AI and may make mistakes. Always verify output.
import time
from typing import Tuple

from rdkit import Chem

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'Chem' is not used.

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.

Suggested changeset 1
benchmark.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/benchmark.py b/benchmark.py
--- a/benchmark.py
+++ b/benchmark.py
@@ -16,7 +16,6 @@
 import time
 from typing import Tuple
 
-from rdkit import Chem
 
 # ARC imports
 import arc.species.conformers as conformers
EOF
@@ -16,7 +16,6 @@
import time
from typing import Tuple

from rdkit import Chem

# ARC imports
import arc.species.conformers as conformers
Copilot is powered by AI and may make mistakes. Always verify output.
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

'except' clause does nothing but pass and there is no explanatory comment.

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).

Suggested changeset 1
benchmark.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/benchmark.py b/benchmark.py
--- a/benchmark.py
+++ b/benchmark.py
@@ -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"]
EOF
@@ -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"]
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant