Top Level Namespace

Defined Under Namespace

Modules: Autoflow Classes: BashManager, Batch, Program, QueueManager, SlurmManager, SlurmManager2, Stack

Instance Method Summary collapse

Instance Method Details

#fill_attrib(attribs, mode, set_length) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/autoflow/logging.rb', line 33

def fill_attrib(attribs, mode, set_length)
	query = attribs[mode]
	if query.nil?
		attribs[mode] = Array.new(set_length, 0)
	elsif query.length < set_length
		(set_length - query.length).times do
			query << 0
		end
	end
end

#parse_log(log_path) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/autoflow/logging.rb', line 1

def parse_log(log_path)
	log = {}
	if Dir.exists?(log_path)
		Dir.entries(log_path).each do |entry|
			next if entry == '.' || entry == '..'
			File.open(File.join(log_path, entry)).each do |line|
				line.chomp!
				name, status, time_int = line.split("\t")
				time = time_int.to_i
				query = log[name]
				if query.nil?
					log[name] = {status => [time]}
				else
					query_status = query[status]
					if query_status.nil?
						query[status] = [time]
					else
						query[status] << time
					end
				end
			end
		end
	end
	log.each do |task, attribs|
		#puts "#{attribs.inspect}"
		set_length = attribs['set'].length
		fill_attrib(attribs, 'start', set_length)
		fill_attrib(attribs, 'end', set_length)
	end
	return log
end

#write_log(log, log_path, job_relations_with_folders) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/autoflow/logging.rb', line 44

def write_log(log, log_path, job_relations_with_folders)
	Dir.mkdir(log_path) if !Dir.exists?(log_path)
	job_relations_with_folders.each do |name, folder_deps|
		if !log[name].nil? #Control check when the wk_log folder has been deleted
			folder, deps = folder_deps
			f = File.open([log_path, File.basename(folder)].join('/'), 'w') 
			log[name].each do |mode, times|
				times.each do |time|
					f.puts "#{name}\t#{mode}\t#{time}"
				end
			end
			f.close
		end
	end
end