<commit_before>#!/usr/bin/ruby

# Author: <NAME>
#
# Test file
#
# This sinatra app is a mock-up of our HPC modelling API.
#
# It allows for early testing of the HPC scripts in a controlled
# environment.

require 'rubygems'
require 'sinatra'
require 'thread'
require 'monitor'

@@species = Queue.new
@@species.extend(MonitorMixin)

SLEEP_TIME = 10


# Request URI for the next job on the queue (what needs to be modelled)
get '/species/next_job' do
    content_type 'text/plain'
    return_body = nil
    @@species.synchronize do
        if @@species.empty?
            halt 503, {'Content-Type' => 'text/plain'}, "No species modelling required"
        else
            halt 200, {'Content-Type' => 'text/plain'}, @@species.pop()
        end
    end
end

# Thread to keep increasing the number of species in the queue.
# Generates random 8 character long species_id
Thread.new do
    while true
        @@species.synchronize do
            species_string = (0...8).map{65.+(rand(25)).chr}.join
            @@species.push(species_string)
        end
        sleep SLEEP_TIME
    end
end
<commit_msg>Added test sinatra app to repo.<commit_after>#!/usr/bin/ruby

# Author: <NAME>
#
# Test file
#
# This sinatra app is a mock-up of our HPC modelling API.
#
# It allows for early testing of the HPC scripts in a controlled
# environment.

require 'rubygems'
require 'sinatra'
require 'thread'
require 'monitor'

@@species = Queue.new
@@species.extend(MonitorMixin)

SLEEP_TIME = 10


# Request URI for the next job on the queue (what needs to be modelled)
get '/species/next_job' do
    content_type 'text/plain'
    @@species.synchronize do
        if @@species.empty?
            halt 503, {'Content-Type' => 'text/plain'}, "No species modelling required"
        else
            halt 200, {'Content-Type' => 'text/plain'}, @@species.pop()
        end
    end
end

# Thread to keep increasing the number of species in the queue.
# Generates random 8 character long species_id
Thread.new do
    while true
        @@species.synchronize do
            species_string = (0...8).map{65.+(rand(25)).chr}.join
            @@species.push(species_string)
        end
        sleep SLEEP_TIME
    end
end

{'fraction_non_alphanumeric': 0.10746812386156648, 'fraction_numerical': 0.01366120218579235, 'mean_word_length': 2.814236111111111, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5485371', 'n_tokens_mistral': 730, 'n_tokens_neox': 665, 'n_words': 233}