class_docstr: FileTree creates a set of files with their contents in their subdirectories
  and cleans them up later.
class_docstr_tok: ["FileTree","creates","a","set","of","files","with","their","contents","in","their","subdirectories","and","cleans","them","up","later","."]
docstr: Creates FileTree and returns the root directory of the FileTree.
docstr_tok: ["Creates","FileTree","and","returns","the","root","directory","of","the","FileTree","."]
code: def __enter__(self) -> Path:
      """Creates FileTree and returns the root directory of the FileTree."""
      self.dir = Path(tempfile.mkdtemp(dir=str(self.tmp_path)))
      try:
          for name, contents in self.files.items():
              p = self.dir.joinpath(name)
              p.parent.mkdir(parents=True, exist_ok=True)
              p.write_text(contents)
      except OSError:
          shutil.rmtree(str(self.dir), ignore_errors=True)
  
      return self.dir
  
file_path: determined/harness/tests/filetree.py
imports: import contextlib
  import os
  import shutil
  import tempfile
  from pathlib import Path
  from types import TracebackType
  from typing import ContextManager, Dict, Iterator, Optional, Type, Union
label_desc: Use image node_id 2 for calling the FileTree obj's underlying member method code with example usage: obj.__enter__() and returns: self