class_docstr: Wandb class for 3D Molecular data.
  
  Arguments:
      data_or_path: (string, io)
          Molecule can be initialized from a file name or an io object.
      caption: (string)
          Caption associated with the molecule for display.
class_docstr_tok: ["Wandb","class","for","3D","Molecular","data",".","Arguments",":","data_or_path",":","(","string",",","io",")","Molecule","can","be","initialized","from","a","file","name","or","an","io","object",".","caption",":","(","string",")","Caption","associated","with","the","molecule","for","display","."]
code: def __init__(
      self,
      data_or_path: Union[str, "TextIO"],
      caption: Optional[str] = None,
      **kwargs: str,
  ) -> None:
      super().__init__()
  
      self._caption = caption
  
      if hasattr(data_or_path, "name"):
          # if the file has a path, we just detect the type and copy it from there
          data_or_path = data_or_path.name
  
      if hasattr(data_or_path, "read"):
          if hasattr(data_or_path, "seek"):
              data_or_path.seek(0)
          molecule = data_or_path.read()
  
          extension = kwargs.pop("file_type", None)
          if extension is None:
              raise ValueError(
                  "Must pass file_type keyword argument when using io objects."
              )
          if extension not in Molecule.SUPPORTED_TYPES:
              raise ValueError(
                  "Molecule 3D only supports files of the type: "
                  + ", ".join(Molecule.SUPPORTED_TYPES)
              )
  
          tmp_path = os.path.join(
              MEDIA_TMP.name, runid.generate_id() + "." + extension
          )
          with open(tmp_path, "w") as f:
              f.write(molecule)
  
          self._set_file(tmp_path, is_tmp=True)
      elif isinstance(data_or_path, str):
          extension = os.path.splitext(data_or_path)[1][1:]
          if extension not in Molecule.SUPPORTED_TYPES:
              raise ValueError(
                  "Molecule only supports files of the type: "
                  + ", ".join(Molecule.SUPPORTED_TYPES)
              )
  
          self._set_file(data_or_path, is_tmp=False)
      else:
          raise ValueError("Data must be file name or a file object")
  
file_path: wandb/wandb/sdk/data_types/molecule.py
imports: import io
  import os
  import pathlib
  from typing import TYPE_CHECKING, Optional, Sequence, Type, Union
  from wandb import util
  from wandb.sdk.lib import runid
  from wandb.sdk.lib.paths import LogicalPath
  from ._private import MEDIA_TMP
  from .base_types.media import BatchableMedia, Media
label_desc: Use image node_id 1 to create a new Molecule object from inherited base classes: BatchableMedia with example: obj = Molecule(data_or_path, caption)