code: def temporary_path(self):
          
          num = random.randrange(0, 1e10)
          slashless_path = self.path.rstrip('/').rstrip("\\")
          _temp_path = '{}-luigi-tmp-{:010}{}'.format(
              slashless_path,
              num,
              self._trailing_slash())
          # TODO: os.path doesn't make sense here as it's os-dependent
          tmp_dir = os.path.dirname(slashless_path)
          if tmp_dir:
              self.fs.mkdir(tmp_dir, parents=True, raise_if_exists=False)
  
          yield _temp_path
          # We won't reach here if there was an user exception.
          self.fs.rename_dont_move(_temp_path, self.path)
docs: A context manager that enables a reasonably short, general and
          magic-less way to solve the :ref:`AtomicWrites`.
  
           * On *entering*, it will create the parent directories so the
             temporary_path is writeable right away.
             This step uses :py:meth:`FileSystem.mkdir`.
           * On *exiting*, it will move the temporary file if there was no exception thrown.
             This step uses :py:meth:`FileSystem.rename_dont_move`
  
          The file system operations will be carried out by calling them on :py:attr:`fs`.
  
          The typical use case looks like this:
  
          .. code:: python
  
              class MyTask(luigi.Task):
                  def output(self):
                      return MyFileSystemTarget(...)
  
                  def run(self):
                      with self.output().temporary_path() as self.temp_output_path:
                          run_some_external_command(output_path=self.temp_output_path)