#12791·wandb

[Bug]: Molecule: preserve parent directories in pathlib.Path inputs

Author: humdrum00001010Created Sep 10, 2026Updated Sep 11, 2026

Describe the bug

wandb.Molecule advertises pathlib.Path input, but replaces it with .name, losing its parent directory. An existing PDB opens correctly as a string path; the identical Path raises FileNotFoundError for the bare basename when the file is outside the working directory.

This is visible in the current constructor: the file-handle .name shortcut also matches Path. Path support was explicitly added by #9692.

Minimal reproduction

python
from pathlib import Path
from tempfile import TemporaryDirectory
import wandb

with TemporaryDirectory() as root:
    path = Path(root) / "molecule.pdb"
    path.write_text("ATOM      1  N   ALA     1      -0.525   1.362   0.000  1.00  0.00           N\nEND\n")
    print(wandb.Molecule(str(path)).file_is_set())  # True
    wandb.Molecule(path)
True
FileNotFoundError: [Errno 2] No such file or directory: 'molecule.pdb'

Relative Path values containing parent directories fail the same way. No run, RDKit, login, or server is involved.

Expected behavior

Preserve the full path for the supported pathlib.Path input, as the equivalent string input does.

Environment

  • W&B SDK: 0.30.0; relevant source is identical on main 8f93d444e29e4d1a50a888899f51051012ee2679
  • Python: 3.12.12
  • OS: macOS 26.1, arm64
  • W&B server: not applicable