code: def _add_batch(x, sample):
      
      added = False
      for batch in sorted(dd.get_batches(sample) or [], key=len, reverse=True):
          if batch and os.path.basename(x["path"]).startswith(("%s-" % batch, "%s.vcf" % batch)):
              x["batch"] = batch
              added = True
              break
      if not added:
          x["batch"] = dd.get_sample_name(sample)
      return x
docs: Potentially add batch name to an upload file.