accasim.experimentation.schedule_writer module

MIT License

Copyright (c) 2017 cgalleguillosm

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

class accasim.experimentation.schedule_writer.DefaultWriter(path, max_time=14400, overwrite=False, append=False)[source]

Bases: accasim.experimentation.schedule_writer.WorkloadWriter

Implementation of the WorkloadWriter class targeted at writing workload files in SWF format

ALLOCATED_PROCESSORS = ('allocated_processors', 0)
AVG_CPU_TIME = ('avg_cpu_time', -1)
DURATION = ('duration', 0)
EXECUTABLE_NUMBER = ('executable_number', -1)
GROUP_ID = ('group_id', -1)
JOB_NUMBER = ('job_number', 0)
PARTITION_NUMBER = ('partition_number', -1)
PRECEDING_JOB_NUMBER = ('preceding_job_number', -1)
QUEUE_NUMBER = ('queue_number', -1)
REQUESTED_MEMORY = ('requested_memory', -1)
REQUESTED_NUMBER_PROCESSORS = ('requested_number_processors', -1)
REQUESTED_TIME = ('requested_time', -1)
STATUS = ('status', 1)
SUBMIT_TIME = ('submit_time', 0)
SWF_ATTRIBUTES = [('job_number', 0), ('submit_time', 0), ('wait_time', -1), ('duration', 0), ('allocated_processors', 0), ('avg_cpu_time', -1), ('used_memory', 0), ('requested_number_processors', -1), ('requested_time', -1), ('requested_memory', -1), ('status', 1), ('user_id', -1), ('group_id', -1), ('executable_number', -1), ('queue_number', -1), ('partition_number', -1), ('preceding_job_number', -1), ('think_time_prejob', -1)]
THINK_TIME_PREJOB = ('think_time_prejob', -1)
USED_MEMORY = ('used_memory', 0)
USER_ID = ('user_id', -1)
WAIT_TIME = ('wait_time', -1)
prepare_data(job_dict, attr_name, default_value)[source]

Method used to prepare specific SWF attributes, by converting entries from the original job dictionary

Parameters:
  • job_dict – The job dictionary
  • attr_name – The name of the attribute to be processed
  • default_value – Default value to be used for the attribute, if not present in job_dict
Returns:

The processed value for attr_name, if present, or default_value otherwise

process_dictionary(job_dict)[source]

Converts a job dictionary to a string to be written in the workload.

Parameters:job_dict – The job dictionary
Returns:A properly formatted SWF string entry
class accasim.experimentation.schedule_writer.WorkloadWriter(path, overwrite=False, append=False)[source]

Bases: abc.ABC

add_newline(job_dict)[source]

Writes a new line corresponding to a job dictionary given as input

Parameters:job_dict – The input job dictionary
close_file()[source]

Closes the output file stream

classmethod process_dictionary(job_dict)[source]

This method must convert the job dictionary to a string formatted in a specific way, according to the implementation

Parameters:job_dict – Dictionary related to one specific job
Returns:The string corresponding to the input dictionary