<commit_before>class Scale
  class Api
    class Tasks < Struct.new(:client)
      def list(start_time: nil, end_time: nil, limit: 99, offset: 0, type: nil, status: nil)
        params = {
          start_time: start_time ? start_time.iso8601 : nil,
          end_time: end_time ? end_time.iso8601 : nil,
          limit: limit,
          offset: offset,
          status: status,
          type: type
        }

        response = client.get('tasks', params)
        body = JSON.parse(response.body)

        TaskList.new({
          client: client,
          docs: body['docs'],
          limit: body['limit'],
          offset: body['offset'],
          has_more: body['has_more'],
          params: params
        })
      end
      
      def find(task_id)
        response = client.get("task/#{task_id}")
        BaseTask.from_hash(JSON.parse(response.body).merge('client' => client))
      end

      def cancel(task_id)
        response = client.post("task/#{task_id}/cancel")
        BaseTask.from_hash(JSON.parse(response.body).merge('client' => client))
      end

      def create(args = {})
        raise ArgumentError.new('Task type is required') if (args[:type].nil? && args['type'].nil?)
        klass = ::Scale::Api::TaskList::TASK_TYPES_TO_CLASSNAMES[(args[:type] || args['type']).to_sym]
        
        unless klass
          raise ArgumentError.new('Unsupported task type. Supported task types: ' + ::Scale::Api::TaskList::TASK_TYPES_TO_CLASSNAMES.keys.join(','))
        end

        args.delete(:type)
        klass.create(args.merge(client: client))
      end

      alias_method :all, :list
      alias_method :where, :list
    end
  end
end

require 'scale/api/task_list'<commit_msg>to_sym => to_s<commit_after>class Scale
  class Api
    class Tasks < Struct.new(:client)
      def list(start_time: nil, end_time: nil, limit: 99, offset: 0, type: nil, status: nil)
        params = {
          start_time: start_time ? start_time.iso8601 : nil,
          end_time: end_time ? end_time.iso8601 : nil,
          limit: limit,
          offset: offset,
          status: status,
          type: type
        }

        response = client.get('tasks', params)
        body = JSON.parse(response.body)

        TaskList.new({
          client: client,
          docs: body['docs'],
          limit: body['limit'],
          offset: body['offset'],
          has_more: body['has_more'],
          params: params
        })
      end
      
      def find(task_id)
        response = client.get("task/#{task_id}")
        BaseTask.from_hash(JSON.parse(response.body).merge('client' => client))
      end

      def cancel(task_id)
        response = client.post("task/#{task_id}/cancel")
        BaseTask.from_hash(JSON.parse(response.body).merge('client' => client))
      end

      def create(args = {})
        raise ArgumentError.new('Task type is required') if (args[:type].nil? && args['type'].nil?)
        klass = ::Scale::Api::TaskList::TASK_TYPES_TO_CLASSNAMES[(args[:type] || args['type']).to_s]
        
        unless klass
          raise ArgumentError.new('Unsupported task type. Supported task types: ' + ::Scale::Api::TaskList::TASK_TYPES_TO_CLASSNAMES.keys.join(','))
        end

        args.delete(:type)
        klass.create(args.merge(client: client))
      end

      alias_method :all, :list
      alias_method :where, :list
    end
  end
end

require 'scale/api/task_list'
{'fraction_non_alphanumeric': 0.1351272301842644, 'fraction_numerical': 0.006434630008774495, 'mean_word_length': 2.3043478260869565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '2845359', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1052, 'n_words': 218}