<commit_before>/* -------------------------------------------------------------------------- */
/* Copyright 2002-2006 GridWay Team, Distributed Systems Architecture         */
/* Group, Universidad Complutense de Madrid                                   */
/*                                                                            */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
/* not use this file except in compliance with the License. You may obtain    */
/* a copy of the License at                                                   */
/*                                                                            */
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
/*                                                                            */
/* Unless required by applicable law or agreed to in writing, software        */
/* distributed under the License is distributed on an "AS IS" BASIS,          */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
/* See the License for the specific language governing permissions and        */
/* limitations under the License.                                             */
/* -------------------------------------------------------------------------- */

#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <limits.h>

#include "gw_em_rsl.h"
#include "gw_job.h"
#include "gw_user_pool.h"


/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
 
char* gw_generate_wrapper_rsl (gw_job_t *job)
{
    char *rsl;
    char *job_environment; 
    char  rsl_buffer[GW_RSL_LENGTH];
    char  tmp_buffer[GW_RSL_LENGTH];
    int   print_queue = 0;
    char *jobtype;
    
    /* ---------------------------------------------------------------------- */
    /* 1.- Create dynamic job data environment                                */
    /* ---------------------------------------------------------------------- */
  
    job_environment = gw_job_rsl_environment(job);
    
    if ( job_environment == NULL )
        return NULL;
    
    /* ---------------------------------------------------------------------- */
    /* 2.- Build RSL String & Return it                                       */
    /* ---------------------------------------------------------------------- */

    if ( job->history->queue != NULL )
        if ( strcmp(job->history->queue,"-") != 0 )
            print_queue = 1;
    
    jobtype = strdup(gw_template_jobtype_string(job->template.type));
    
    snprintf(rsl_buffer, sizeof(char) * GW_RSL_LENGTH,
            "&(jobtype=\"%s\")"
            "(executable=\".gw_%s_%i/.wrapper\")"
            "(stdout=\".gw_%s_%i/stdout.wrapper\")"
            "(stderr=\".gw_%s_%i/stderr.wrapper\")"
            "(environment=%s)"
            "(count=%d)",
            jobtype,
            job->owner, job->id,
            job->owner, job->id,
            job->owner, job->id,
            job_environment,
            job->template.np);

    if ( print_queue )
    {
        snprintf(tmp_buffer, sizeof(char) * GW_RSL_LENGTH,
                "(queue=\"%s\")", job->history->queue);
        strncat(rsl_buffer, tmp_buffer, GW_RSL_LENGTH-strlen(rsl_buffer));<commit_msg>Hardcoded a 12 hour walltime<commit_after>/* -------------------------------------------------------------------------- */
/* Copyright 2002-2006 GridWay Team, Distributed Systems Architecture         */
/* Group, Universidad Complutense de Madrid                                   */
/*                                                                            */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
/* not use this file except in compliance with the License. You may obtain    */
/* a copy of the License at                                                   */
/*                                                                            */
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
/*                                                                            */
/* Unless required by applicable law or agreed to in writing, software        */
/* distributed under the License is distributed on an "AS IS" BASIS,          */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
/* See the License for the specific language governing permissions and        */
/* limitations under the License.                                             */
/* -------------------------------------------------------------------------- */

#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <limits.h>

#include "gw_em_rsl.h"
#include "gw_job.h"
#include "gw_user_pool.h"


/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
 
char* gw_generate_wrapper_rsl (gw_job_t *job)
{
    char *rsl;
    char *job_environment; 
    char  rsl_buffer[GW_RSL_LENGTH];
    char  tmp_buffer[GW_RSL_LENGTH];
    int   print_queue = 0;
    char *jobtype;
    
    /* ---------------------------------------------------------------------- */
    /* 1.- Create dynamic job data environment                                */
    /* ---------------------------------------------------------------------- */
  
    job_environment = gw_job_rsl_environment(job);
    
    if ( job_environment == NULL )
        return NULL;
    
    /* ---------------------------------------------------------------------- */
    /* 2.- Build RSL String & Return it                                       */
    /* ---------------------------------------------------------------------- */

    if ( job->history->queue != NULL )
        if ( strcmp(job->history->queue,"-") != 0 )
            print_queue = 1;
    
    jobtype = strdup(gw_template_jobtype_string(job->template.type));
    
    snprintf(rsl_buffer, sizeof(char) * GW_RSL_LENGTH,
            "&(jobtype=\"%s\")"
            "(executable=\".gw_%s_%i/.wrapper\")"
            "(stdout=\".gw_%s_%i/stdout.wrapper\")"
            "(stderr=\".gw_%s_%i/stderr.wrapper\")"
            "(maxWallTime=720)" //12 hours
            "(environment=%s)"
            "(count=%d)",
            jobtype,
            job->owner, job->id,
            job->owner, job->id,
            job->owner, job->id,
            job_environment,
            job->template.np);

    if ( print_queue )
    {
        snprintf(tmp_buffer, sizeof(char) * GW_RSL_LENGTH,
                "(queue=\"%s\")", job->history->queue);
        strncat(rsl_buffer, tmp_buffer, GW_RSL_LENGTH-strlen(rsl_buffer));
{'fraction_non_alphanumeric': 0.2916666666666667, 'fraction_numerical': 0.00591118800461361, 'mean_word_length': 0.8860793909733551, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7014228', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1540, 'n_words': 364}