Skip to content

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

Description

@humdrum00001010

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions