<commit_before># Top level module for all of the core Cyclid code.
module Cyclid
  # Module for the Cyclid API
  module API
    # Module for all Organization related API endpoints
    module Organizations
      # API endpoints for Organization Jobs
      module Jobs
        # Sinatra callback
        def self.registered(app)
          include Errors::HTTPErrors
          include Constants::JobStatus

          # @macro [attach] sinatra.post
          #   @overload post "$1"
          # @method post_organizations_organization_jobs
          # Create and run a job.
          app.post do
            authorized_for!(params[:name], Operations::WRITE)

            payload = parse_request_body
            Cyclid.logger.debug payload

            halt_with_json_response(400, INVALID_JOB, 'invalid job definition') \
              unless payload.key? 'sequence' and \
                     payload.key? 'environment'

            begin
              job_data = job_from_definition(job_definition)
            rescue StandardError => ex
              halt_with_json_response(500, INVALID_JOB, 'job failed')
            end

            return job_data
          end

          # @macro [attach] sinatra.get
          #   @overload get "$1"
          # @method get_organizations_organization_job
          # @return [String] JSON represention of the job record for the job ID.
          # Get the complete JobRecord for the given job ID.
          app.get '/:id' do
            authorized_for!(params[:name], Operations::READ)

            org = Organization.find_by(name: params[:name])
            halt_with_json_response(404, INVALID_ORG, 'organization does not exist') \
              if org.nil?

            job_record = org.job_records.find(params[:id])
            halt_with_json_response(404, INVALID_JOB, 'job does not exist') \
              if job_record.nil?

            # XXX The "job" itself is a serialised internal representation and
            # probably not very useful to the user, so we might want to process
            # it into something more helpful here.
            return job_record.to_json
          end<commit_msg>Fix the call to job_from_definition<commit_after># Top level module for all of the core Cyclid code.
module Cyclid
  # Module for the Cyclid API
  module API
    # Module for all Organization related API endpoints
    module Organizations
      # API endpoints for Organization Jobs
      module Jobs
        # Sinatra callback
        def self.registered(app)
          include Errors::HTTPErrors
          include Constants::JobStatus

          # @macro [attach] sinatra.post
          #   @overload post "$1"
          # @method post_organizations_organization_jobs
          # Create and run a job.
          app.post do
            authorized_for!(params[:name], Operations::WRITE)

            payload = parse_request_body
            Cyclid.logger.debug payload

            halt_with_json_response(400, INVALID_JOB, 'invalid job definition') \
              unless payload.key? 'sequence' and \
                     payload.key? 'environment'

            begin
              job_data = job_from_definition(payload)
            rescue StandardError => ex
              halt_with_json_response(500, INVALID_JOB, 'job failed')
            end

            return job_data
          end

          # @macro [attach] sinatra.get
          #   @overload get "$1"
          # @method get_organizations_organization_job
          # @return [String] JSON represention of the job record for the job ID.
          # Get the complete JobRecord for the given job ID.
          app.get '/:id' do
            authorized_for!(params[:name], Operations::READ)

            org = Organization.find_by(name: params[:name])
            halt_with_json_response(404, INVALID_ORG, 'organization does not exist') \
              if org.nil?

            job_record = org.job_records.find(params[:id])
            halt_with_json_response(404, INVALID_JOB, 'job does not exist') \
              if job_record.nil?

            # XXX The "job" itself is a serialised internal representation and
            # probably not very useful to the user, so we might want to process
            # it into something more helpful here.
            return job_record.to_json
          end
{'fraction_non_alphanumeric': 0.06736353077816493, 'fraction_numerical': 0.0065040650406504065, 'mean_word_length': 1.9635237439779767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6529953', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1084, 'n_words': 357}