How to use list_jobs method in localstack

Best Python code snippet using localstack_python

Unicore_Jobset_Island_Finding_Script.py

Source:Unicore_Jobset_Island_Finding_Script.py Github

copy

Full Screen

1'''2****************** Finding Islands of Jobs for Uni-Core Analysis ****************3* Author: Muhammad Junaid Aslam4* Contact: junaidaslam1@gmail.com5* ---------------------------------------------------------------------6* This software is governed by the No license. You can use, modify |7* and redistribute the software under the condition of citing |8* or crediting the authors of this software in your work. |9* ---------------------------------------------------------------------10*11* This was part of a research project funded by the EWI EEMCS Group of12* Technical University of Delft, Netherlands.13**********************************************************************************14'''15import csv16import sys17import os18import copy19import threading20import time21import subprocess22from subprocess import Popen, PIPE23from fractions import gcd24# Global Variables25# Column Numbers for Original Source File26TASK_ID = 027JOB_ID = 128ARRIVAL_MIN = 229ARRIVAL_MAX = 330COST_MIN = 431COST_MAX = 532DEADLINE = 633PRIORITY = 734# Column Numbers for List_Jobs lists created in this script35TID = 036JID = 137ARR_MAX = 238CST_MAX = 339PERIOD= 440# Global Data41source_csv = ""42list_jobs = []43original_jobs = []44list_response_times = []45island_of_jobs = []46island_name = []47schedule_time = []48schedule_time_counter = 049island_job_list = []50first_job = 051last_job = 052island_counter = 053time_zero = 054# Path to nptest binary Bjorn Brandernburg55nptest_path = "/home/junaid/eclipse-workspace/np_schedulability/build/nptest --header -r "56def pause():57 input("System Paused! Press Enter to continue...")58 59def sortRmax(val): 60 return val[2]61def sort_jobs_wrt_Rmax():62 list_jobs.sort(key = sortRmax)63def custom_command(incommand):64 #g_str = ("Executing:",incommand)65 #print(g_str)66 p = subprocess.Popen(incommand, stdout=subprocess.PIPE,67stderr=subprocess.STDOUT)68 outstring = p.stdout.read()69 #print(outstring)70 return outstring71class NP_Test_Thread (threading.Thread):72 def __init__(self, name, filename):73 threading.Thread.__init__(self)74 self.name = name75 self.filename = filename76 def run(self):77 #print "Starting " + self.name78 #print(self.name)79 lvStr = nptest_path+self.filename80 print(custom_command(lvStr.split()))81def initialize_np_test(name,filename):82 nptest_thread = NP_Test_Thread(name, filename)83 nptest_thread.start()84 85def create_jobset(filename, job_set):86 jobWriter = 087 jobReader = 088 89 with open(source_csv, 'rb') as csvfile:90 jobReader = csv.reader(csvfile, delimiter=',', quotechar='|')91 next(jobReader)92 93 with open(filename, 'wb') as csvfile:94 jobWriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) 95 jobWriter.writerow(['Task ID', 'Job ID', 'Arrival Min', 'Arrival Max', 'Cost Min', 'Cost Max', 'Deadline', 'Priority'])96 for reader_row in jobReader:97 for writer_row in job_set: 98 if (writer_row[0] != ((int)(reader_row[0]))) or (writer_row[1] != ((int)(reader_row[1]))):99 continue100 else:101 jobWriter.writerow(reader_row)102 # Initialize thread to analyse the jobset island103 initialize_np_test(filename, filename)104# Parse jobs to get job list with specific characteristics listed 105def parse_jobs(input_file):106 counter = 0107 with open(input_file, 'rb') as csvfile:108 jobreader = csv.reader(csvfile, delimiter=',', quotechar='|')109 next(jobreader)110 for row in jobreader:111 job = []112 for item in row: 113 if (counter == COST_MIN) or (counter == ARRIVAL_MIN) or (counter == PRIORITY):114 counter = counter + 1115 continue 116 job.append(int(item)) 117 counter = counter + 1 118 counter = 0 119 list_jobs.append(job)120 original_jobs.append(job)121 print("TID, JID, ARR_MIN, ARR_MAX, Cmax")122 for item in list_jobs:123 print(item)124 print("--------------- NOW Sorted ---------------")125 sort_jobs_wrt_Rmax()126 for item in list_jobs:127 print(item)128def get_current_schedule_time():129 return get_schedule_time(schedule_time_counter)130def get_schedule_time(index):131 return schedule_time[index]132def append_schedule_time(inTime):133 global schedule_time_counter134# print("time provided:%d"%inTime)135 schedule_time.append(inTime)136# print("Counter:%d Appended Time:%d"%(schedule_time_counter, get_schedule_time(schedule_time_counter)))137 schedule_time_counter += 1138# print("Counter:%d Appended Time:%d"%(schedule_time_counter, get_schedule_time(schedule_time_counter)))139def check_recursion_condition(island_list):140 for item in island_list:141 if get_current_schedule_time() <= item[ARR_MAX]:142 return 0143 return 1144def remove_jobs_from_orig_list(island_job_list):145 lvList_Jobs = copy.deepcopy(list_jobs)146 lvCounter = 0147 for item in lvList_Jobs:148 for island_item in island_job_list:149 if (item[TID] == island_item[TID]) and (item[JID] == island_item[JID]):150 list_jobs.remove(item)151 lvCounter += 1152 break153 print("-- Removed:%d -- Remaining Jobs --"%lvCounter)154 for item in list_jobs:155 print(item)156 157def find_island():158 print("Finding Islands and launching threads to perform analysis")159 global first_job160 global island_counter161 162 global_time_summation = 0163 if first_job == 0:164 first_job = 1165 append_schedule_time(list_jobs[0][ARR_MAX])166 167 for item in list_jobs: 168 if (item[ARR_MAX] <= get_current_schedule_time()): 169 island_job_list.append(item)170 global_time_summation += item[CST_MAX]171 print(global_time_summation)172 append_schedule_time(get_current_schedule_time() + global_time_summation)173 174 print("Current Time:%d Previous_Time:%d"%(get_current_schedule_time(), get_schedule_time(schedule_time_counter - 1)))175 if (get_schedule_time(schedule_time_counter - 1) == get_current_schedule_time()) and (check_recursion_condition(island_job_list) == 1):176 print("Removing Jobs for Island")177 print(get_current_schedule_time())178 remove_jobs_from_orig_list(island_job_list)179 island_counter += 1180 filename = 'Island'+str(island_counter)+'.csv'181 create_jobset(filename, island_job_list)182 del island_job_list[:]183 else:184 remove_jobs_from_orig_list(island_job_list)185 find_island()186def find_island_new():187 #print("Finding New Islands and launching threads to perform analysis")188 list_Counter = 0189 190 global first_job191 global island_counter192 global time_zero193 global last_job194 195 global_time_summation = 0196 list_Counter = len(list_jobs)197 if list_Counter == 0:198 print("List_Jobs list is empty")199 200 if first_job == 0:201 first_job = 1202 append_schedule_time(list_jobs[0][ARR_MAX])203 print("New T_0 Value:%d get_current_schedule_time:%d"%(time_zero, get_current_schedule_time()))204 205 for item in list_jobs:206 if len(list_jobs) != 1:207 if ((item[ARR_MAX]+time_zero) <= get_current_schedule_time()):208 island_job_list.append(item)209 append_schedule_time(get_current_schedule_time() + item[CST_MAX])210 else:211 append_schedule_time(item[ARR_MAX] + time_zero)212 #print("An Island is Found. Next Job`s Rmax Time:")213 #print(get_current_schedule_time())214 remove_jobs_from_orig_list(island_job_list)215 island_counter += 1216 filename = 'Island'+str(island_counter)+'.csv'217 create_jobset(filename, island_job_list)218 #print("Flush the Island Job list to fill with new jobs")219 del island_job_list[:]220 else:221 island_job_list.append(item)222 append_schedule_time(item[PERIOD] + time_zero)223 #print("An Island is Found. final Job in the list:")224 #print(get_current_schedule_time())225 remove_jobs_from_orig_list(island_job_list)226 island_counter += 1227 filename = 'Island'+str(island_counter)+'.csv'228 create_jobset(filename, island_job_list)229 #print("Flush the Island Job list to fill with new jobs")230 del island_job_list[:] 231 last_job = 1232 233def get_hyper_period(numbers):234 return reduce(lambda x, y: (x*y)/gcd(x,y), numbers, 1) 235def get_col(arr, col):236 return map(lambda x : x[col], arr)237if __name__ == '__main__':238 global time_zero239 global last_job240 241 if len(sys.argv) > 1:242 243 print("JobSet Filename:"+sys.argv[1])244 source_csv = sys.argv[1]245 schedule_time.append(0)246 time_zero = get_schedule_time(0)247 248 parse_jobs(source_csv)249 list_of_deadlines = get_col(list_jobs, PERIOD)250 hyper_period = get_hyper_period(list_of_deadlines)251 252 print("HyperPeriod:%d"%hyper_period)253 last_job = 0254 Last_job_period = list_jobs[len(list_jobs) - 1][PERIOD]255 256 while get_current_schedule_time() < Last_job_period:257 if last_job == 1:258 list_jobs = copy.deepcopy(original_jobs)259 sort_jobs_wrt_Rmax()260 time_zero = get_current_schedule_time()261 last_job = 0262 find_island_new()263# time.sleep(0.5)264 else:265 print("Please provide Filename")266 exit()...

Full Screen

Full Screen

ORCAQ_button.py

Source:ORCAQ_button.py Github

copy

Full Screen

1from tkinter import filedialog2from subprocess import run, CalledProcessError3from os.path import isfile4from ORCAQ_setting import read_ini5from psutil import process_iter, Process6from tkinter import messagebox7list_jobs = []8out = []9def add_job(treeview):10 global list_jobs11 addjob = filedialog.askopenfilenames(title="Add Jobs", initialdir="C:\\Orca\\", filetypes=(("ORCA Input File", "*.inp"),))12 if(addjob!=None):13 ai = list(addjob)14 for j in range(len(ai)):15 ai[j] = ai[j].replace("/","\\")16 lt = list(ai)17 if(list_jobs==[]):18 list_jobs = list(ai)19 for w in range(0,len(list_jobs)):20 chg = list_jobs[w].replace(".inp", ".out")21 out.append(chg)22 else:23 for i in lt:24 if(i not in list_jobs):25 list_jobs.append(i) 26 chg = i.replace(".inp", ".out")27 out.append(chg)28 n_pal, direc = read_ini() 29 for i in lt: 30 if(treeview.exists(i)==False):31 treeview.insert("", "end", text=i, values=(str(n_pal), "0%"), iid=i)32def cleanup_jobs(treeview):33 global list_jobs34 if(list_jobs!=[]):35 for i in list_jobs:36 treeview.delete(i)37 list_jobs = []38def remove_jobs(treeview):39 global list_jobs40 global out41 if(list_jobs!=[]):42 list_remove = treeview.selection()43 list_remove = list(list_remove)44 for rem in list_remove:45 treeview.delete(rem)46 list_jobs.remove(rem) 47 out.remove(rem.replace(".inp", ".out"))48def info_job():49 messagebox.showinfo("All processor files")50def start_b(treeview, bt3, menu):51 global list_jobs52 global out53 if(list_jobs!=[]):54 menu.entryconfig(2, state="disabled") 55 bt3.config(state="disabled")56 N_pal, exe_dir = read_ini()57 pal_list = []58 for w in list_jobs:59 x , y = treeview.item(w, option='values')60 pal_list.append(x)61 #dir = "C:\\Program Files\\CCleaner\\CCleaner.exe"62 if(isfile(exe_dir)==True):63 for j in range(len(list_jobs)): 64 if(int(pal_list[j])==2): 65 caller = exe_dir + ' ' + list_jobs[j] + ' > ' + out[j]66 execute = run(caller, shell=True)67 try:68 execute.check_returncode()69 treeview.item(list_jobs[j], values=[2, "100%"]) 70 except CalledProcessError:71 treeview.item(list_jobs[j], values=[2, "error"]) 72 73 if(int(pal_list[j])==1):74 caller = "orca.exe " + list_jobs[j] + ' > ' + out[j]75 execute = run(caller, shell=True)76 try:77 execute.check_returncode()78 treeview.item(list_jobs[j], values=[1, "100%"]) 79 except CalledProcessError:80 treeview.item(list_jobs[j], values=[1, "error"])81 menu.entryconfig(2, state="active") 82 bt3.config(state="active")83 info_job() 84 #print(caller)85 86def cancell_ORCA():87 if(list_jobs!=[]):88 for itera in process_iter():89 if(itera.name()=="orca.exe"):90 p = Process(itera.pid)...

Full Screen

Full Screen

weighted-job-scheduling-algorithm.py

Source:weighted-job-scheduling-algorithm.py Github

copy

Full Screen

1class Job:2 def __init__(self, name, start, end, profit):3 self.name = name4 self.start_end = (start, end)5 self.profit = profit6 self.acc_prof = profit7list_jobs = [Job('A', 2, 5, 6),8 Job('B', 6, 7, 4),9 Job('C', 7, 9, 2),10 Job('D', 1, 3, 5),11 Job('E', 5, 8, 11),12 Job('F', 4, 6, 5),13 ]14list_jobs = sorted(list_jobs, key=lambda job: job.start_end[1])15#print(len(list_jobs))16acc_prof = []17for i in range(1, len(list_jobs)):18 for j in range(0, (i-1)):19 if list_jobs[j].start_end[1] <= list_jobs[i].start_end[0]:20 if list_jobs[j].acc_prof + list_jobs[i].profit > list_jobs[i].acc_prof:21 list_jobs[i].acc_prof = list_jobs[j].acc_prof + list_jobs[i].profit22max_profit = 023for i in range(0, len(list_jobs)):24 if max_profit < list_jobs[i].acc_prof:25 max_profit = list_jobs[i].acc_prof26print(max_profit)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful