<commit_before>$ ->
  window.upload = (file, options) ->
    if !file?
      $("#droplabel").html "that looks like an empty file :("
      window.isUploading = false
      return
    options = options or bulk: false
    $.ajax
      method: "POST"
      url: "/api/v4/runs"
      cache: false
      processData: false
      contentType: false
      success: (response, textStatus, xhr) ->
        localStorage.setItem "claim_tokens/" + response.id, response.claim_token

        formData = new FormData()
        for key, val of response.presigned_request.fields
          formData.append(key, val)
        formData.append('file', file)
        $.ajax
          method: response.presigned_request.method
          url: response.presigned_request.uri
          cache: false
          processData: false
          contentType: false
          data: formData
          success: ->
            window.location = response.uris.public_uri unless options.bulk

      error: (xhr, textStatus) ->
        if xhr.status is 400<commit_msg>Tell the user if there's an S3 upload error<commit_after>$ ->
  window.upload = (file, options) ->
    if !file?
      $("#droplabel").html "that looks like an empty file :("
      window.isUploading = false
      return
    options = options or bulk: false
    $.ajax
      method: "POST"
      url: "/api/v4/runs"
      cache: false
      processData: false
      contentType: false
      success: (response, textStatus, xhr) ->
        localStorage.setItem "claim_tokens/" + response.id, response.claim_token

        formData = new FormData()
        for key, val of response.presigned_request.fields
          formData.append(key, val)
        formData.append('file', file)
        $.ajax
          method: response.presigned_request.method
          url: response.presigned_request.uri
          cache: false
          processData: false
          contentType: false
          data: formData
          success: ->
            window.location = response.uris.claim_uri unless options.bulk
          error: (xhr, textStatus) ->
            window.isUploading = false
            $("#droplabel").html "oops, got a " + xhr.status + " (" + xhr.statusText + ").<br />try again, or contact glacials.<br />"
            window.spinner.stop()

      error: (xhr, textStatus) ->
        if xhr.status is 400
{'fraction_non_alphanumeric': 0.10639210639210639, 'fraction_numerical': 0.003861003861003861, 'mean_word_length': 2.0603674540682415, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5090977', 'n_tokens_mistral': 669, 'n_tokens_neox': 657, 'n_words': 179}