set priority in add_task
This commit is contained in:
parent
085efb0537
commit
397dbfaffe
|
@ -11,6 +11,7 @@ class BatchJob(object):
|
||||||
self.task_finished = []
|
self.task_finished = []
|
||||||
self.job_id = None
|
self.job_id = None
|
||||||
self.job_name = job_info['jobName']
|
self.job_name = job_info['jobName']
|
||||||
|
self.job_priority = int(job_info['jobPriority'])
|
||||||
self.status = 'pending'
|
self.status = 'pending'
|
||||||
self.create_time = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
|
self.create_time = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
|
||||||
self.top_sort()
|
self.top_sort()
|
||||||
|
@ -83,7 +84,6 @@ class JobMgr(threading.Thread):
|
||||||
# user: username
|
# user: username
|
||||||
# job_data: a json string
|
# job_data: a json string
|
||||||
# user submit a new job, add this job to queue and database
|
# user submit a new job, add this job to queue and database
|
||||||
# call add_task to add task information
|
|
||||||
def add_job(self, user, job_info):
|
def add_job(self, user, job_info):
|
||||||
try:
|
try:
|
||||||
job = BatchJob(user, job_info)
|
job = BatchJob(user, job_info)
|
||||||
|
@ -137,7 +137,8 @@ class JobMgr(threading.Thread):
|
||||||
if not task_info:
|
if not task_info:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
self.taskmgr.add_task(job.user, task_name, task_info)
|
task_priority = self.job_priority
|
||||||
|
self.taskmgr.add_task(job.user, task_name, task_info, task_priority)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# this is a thread to schedule the jobs
|
# this is a thread to schedule the jobs
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/user/bin/python3
|
#!/user/bin/python3
|
||||||
import json
|
import json
|
||||||
|
|
||||||
job_data = {'image_1': 'base_base_base', 'mappingRemoteDir_2_2': 'sss', 'dependency_1': 'aaa', 'mappingLocalDir_2_1': 'xxx', 'mappingLocalDir_1_2': 'aaa', 'mappingLocalDir_1_1': 'aaa', 'mappingLocalDir_2_3': 'fdsffdf', 'mappingRemoteDir_1_1': 'ddd', 'mappingRemoteDir_2_3': 'sss', 'srcAddr_1': 'aaa', 'mappingSource_2_1': 'Aliyun', 'cpuSetting_1': '1', 'mappingSource_2_2': 'Aliyun', 'retryCount_2': '1', 'mappingSource_1_1': 'Aliyun', 'expTime_1': '60', 'diskSetting_2': '1024', 'diskSetting_1': '1024', 'dependency_2': 'ddd', 'memorySetting_1': '1024', 'command_2': 'ccc', 'mappingRemoteDir_1_2': 'ddd', 'gpuSetting_2': '0', 'memorySetting_2': '1024', 'gpuSetting_1': '0', 'mappingLocalDir_2_2': 'bbb', 'mappingSource_1_2': 'Aliyun', 'expTime_2': '60', 'mappingRemoteDir_2_1': 'vvv', 'srcAddr_2': 'fff', 'cpuSetting_2': '1', 'instCount_1': '1', 'mappingSource_2_3': 'Aliyun', 'token': 'ZXlKaGJHY2lPaUpJVXpJMU5pSXNJbWxoZENJNk1UVXpNelE0TVRNMU5Td2laWGh3SWpveE5UTXpORGcwT1RVMWZRLmV5SnBaQ0k2TVgwLkF5UnRnaGJHZXhJY2lBSURZTUd5eXZIUVJnUGd1ZTA3OEtGWkVoejJVMkE=', 'instCount_2': '1', 'retryCount_1': '1', 'command_1': 'aaa', 'taskPriority': '0', 'image_2': 'base_base_base', 'jobName': 'aaa'}
|
job_data = {'image_1': 'base_base_base', 'mappingRemoteDir_2_2': 'sss', 'dependency_1': 'aaa', 'mappingLocalDir_2_1': 'xxx', 'mappingLocalDir_1_2': 'aaa', 'mappingLocalDir_1_1': 'aaa', 'mappingLocalDir_2_3': 'fdsffdf', 'mappingRemoteDir_1_1': 'ddd', 'mappingRemoteDir_2_3': 'sss', 'srcAddr_1': 'aaa', 'mappingSource_2_1': 'Aliyun', 'cpuSetting_1': '1', 'mappingSource_2_2': 'Aliyun', 'retryCount_2': '1', 'mappingSource_1_1': 'Aliyun', 'expTime_1': '60', 'diskSetting_2': '1024', 'diskSetting_1': '1024', 'dependency_2': 'ddd', 'memorySetting_1': '1024', 'command_2': 'ccc', 'mappingRemoteDir_1_2': 'ddd', 'gpuSetting_2': '0', 'memorySetting_2': '1024', 'gpuSetting_1': '0', 'mappingLocalDir_2_2': 'bbb', 'mappingSource_1_2': 'Aliyun', 'expTime_2': '60', 'mappingRemoteDir_2_1': 'vvv', 'srcAddr_2': 'fff', 'cpuSetting_2': '1', 'instCount_1': '1', 'mappingSource_2_3': 'Aliyun', 'token': 'ZXlKaGJHY2lPaUpJVXpJMU5pSXNJbWxoZENJNk1UVXpNelE0TVRNMU5Td2laWGh3SWpveE5UTXpORGcwT1RVMWZRLmV5SnBaQ0k2TVgwLkF5UnRnaGJHZXhJY2lBSURZTUd5eXZIUVJnUGd1ZTA3OEtGWkVoejJVMkE=', 'instCount_2': '1', 'retryCount_1': '1', 'command_1': 'aaa', 'jobPriority': '0', 'image_2': 'base_base_base', 'jobName': 'aaa'}
|
||||||
|
|
||||||
def parse(job_data):
|
def parse(job_data):
|
||||||
job_info = {}
|
job_info = {}
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<br/>
|
<br/>
|
||||||
<div class="form-group"><label class="col-sm-2 control-label">Priority</label>
|
<div class="form-group"><label class="col-sm-2 control-label">Priority</label>
|
||||||
<div class="col-sm-10"><select id="priority_selector" class="form-control" name="taskPriority">
|
<div class="col-sm-10"><select id="priority_selector" class="form-control" name="jobPriority">
|
||||||
{% for priority in range(10) %}
|
{% for priority in range(10) %}
|
||||||
<option value="{{priority}}">{{priority}}</option>
|
<option value="{{priority}}">{{priority}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in New Issue