From 3c27a149a25b6c8930ce68cfeb2a6cbb9afb3359 Mon Sep 17 00:00:00 2001
From: Augustin Zidek <augustinzidek@google.com>
Date: Wed, 13 Nov 2024 10:24:20 +0000
Subject: [PATCH] Fix path handling in templates

PiperOrigin-RevId: 696046311
---
 src/alphafold3/data/templates.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/alphafold3/data/templates.py b/src/alphafold3/data/templates.py
index 06950ff..56d8a09 100644
--- a/src/alphafold3/data/templates.py
+++ b/src/alphafold3/data/templates.py
@@ -851,10 +851,11 @@ def package_template_features(
 
 def _resolve_path(path: os.PathLike[str] | str) -> str:
   """Resolves path for data dep paths, stringifies otherwise."""
-  try:
-    # Data dependency paths: db baked into the binary.
-    return resources.filename(path)
-  except (FileNotFoundError, ValueError):
+  # Data dependency paths: db baked into the binary.
+  resolved_path = resources.filename(path)
+  if os.path.exists(resolved_path):
+    return resolved_path
+  else:
     # Other paths, e.g. local.
     return str(path)
 
-- 
GitLab