code: def _set_link(self, linkname, cls, **kwargs):
          
          val_copy = purge_dict(kwargs.copy())
          sub_link_prefix = val_copy.pop('link_prefix', '')
          link_prefix = self.link_prefix + sub_link_prefix
          create_args = dict(linkname=linkname,
                             link_prefix=link_prefix,
                             job_archive=val_copy.pop('job_archive', None),
                             file_stage=val_copy.pop('file_stage', None))
          job_args = val_copy
          if linkname in self._links:
              link = self._links[linkname]
              link.update_args(job_args)
          else:
              link = cls.create(**create_args)
              self._links[link.linkname] = link
              logfile_default = os.path.join('logs', '%s.log' % link.full_linkname)
              logfile = kwargs.setdefault('logfile', logfile_default)
              link._register_job(JobDetails.topkey, job_args,
                                 logfile, status=JobStatus.unknown)
          return link
docs: Transfer options kwargs to a `Link` object,
          optionally building the `Link if needed.
  
          Parameters
          ----------
  
          linkname : str
              Unique name of this particular link
  
          cls : type
              Type of `Link` being created or managed