code: def save(self, fname, mode=None, validate=True, encoding='utf-8',
               wd=False, inline=False, relative=False, pack=False):
          self._closed()
          if mode is None:
              mode = 'abs'
              if pack:
                  mode = 'pack'
              elif wd:
                  mode = 'wd'
              elif relative:
                  mode = 'rel'
              msg = 'Using deprecated save method. Please save the workflow ' \
                    'with: wf.save(\'{}\', mode=\'{}\'). Redirecting to new ' \
                    'save method.'.format(fname, mode)
              warnings.warn(msg, DeprecationWarning)
          modes = ('rel', 'abs', 'wd', 'inline', 'pack')
          if mode not in modes:
              msg = 'Illegal mode "{}". Choose one of ({}).'\
                    .format(mode, ','.join(modes))
              raise ValueError(msg)
          if validate:
              self.validate()
          dirname = os.path.dirname(os.path.abspath(fname))
          if not os.path.exists(dirname):
              os.makedirs(dirname)
          if mode == 'inline':
              msg = ('Inline saving is deprecated. Please save the workflow '
                     'using mode=\'pack\'. Setting mode to pack.')
              warnings.warn(msg, DeprecationWarning)
              mode = 'pack'
          if mode == 'rel':
              relpath = dirname
              save_yaml(fname=fname, wf=self, pack=False, relpath=relpath,
                        wd=False)
          if mode == 'abs':
              save_yaml(fname=fname, wf=self, pack=False, relpath=None,
                        wd=False)
          if mode == 'pack':
              self._pack(fname, encoding)
          if mode == 'wd':
              if self.get_working_dir() is None:
                  raise ValueError('Working directory not set.')
              else:
                  bn = os.path.basename(fname)
                  wd_file = os.path.join(self.working_dir, bn)
                  save_yaml(fname=wd_file, wf=self, pack=False, relpath=None,
                            wd=True)
                  try:
                      shutil.copy2(wd_file, fname)
                  except shutil.Error:
                      pass