cpee-logging-xes-yaml 1.5.2 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c27951cb51fe4d76a704f6b3d56c05503cfe760ebde414a2c6bfdb2991e2566d
4
- data.tar.gz: e596c6b80c788fed3d1449da6398b4aeb19651894bc3f774b96928b31ab79a8d
3
+ metadata.gz: 840f6e5d3bf6287284ca354a275258376be5d367a85fe2047888b4c76b484c9c
4
+ data.tar.gz: 4821fdb1a463b36f492c0833daabb9a407dbdf8d61d451429f7008914a23377b
5
5
  SHA512:
6
- metadata.gz: 70a342c2e56adcf99095d8cb9a0170719a3d4951dd3110c93b1f1adf871363a43d400be829344f8c41bc65e65827ef42118628863b2e545930e80975d90a578b
7
- data.tar.gz: a01d079c9a8d6a4fb5aac1ddf10900ba9677ebe3d25a1b299c51d6eb8e2afce85001427bc7df85ca007cc7ffa709f5c5fff10fdeb9fee46b073f99bc97045fb7
6
+ metadata.gz: 193ef726d7884d694b156d000732e412ebc7bd4dd74bc4877587252c71e75871e4be6c315bce8c38d684dac5168a748a2f185bc2d9ffbab77da3b1dfd1a6b273
7
+ data.tar.gz: 896fb27beff7796afd1cb4cb240bb022f781be840fd6a1b1610b336b83eb922b0740dcef20daf948fef68c1ead5d9677b63f3b85c0c302f37566dc174522195d
data/AUTHORS CHANGED
@@ -1,2 +1,4 @@
1
1
  Jürgen Mangler <juergen.mangler@gmail.com>
2
2
  Florian Stertz <florian.stertz@gmail.com>
3
+ Matthias Ehrendorfer <matthias.ehrendorfer@gmail.com>
4
+ Dominik Voigt <dominik.voigt@gmail.com>
data/README.md CHANGED
@@ -14,7 +14,7 @@ host, or local-only access, ...), create a file log.conf and add one
14
14
  or many of the following yaml keys:
15
15
 
16
16
  ```yaml
17
- :port: 9250
17
+ :port: 9299
18
18
  :host: cpee.org
19
19
  :bind: 127.0.0.1
20
20
  :log_dir: /var/log/cpee
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-logging-xes-yaml"
3
- s.version = "1.5.2"
3
+ s.version = "1.5.4"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0-or-later"
6
6
  s.summary = "Logging for the cloud process execution engine (cpee.org)"
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.required_ruby_version = '>=2.4.0'
17
17
 
18
- s.authors = ['Juergen eTM Mangler','Florian Stertz']
18
+ s.authors = ['Juergen eTM Mangler','Florian Stertz','Matthias Ehrendorfer','Dominik Voigt']
19
19
 
20
20
  s.email = 'juergen.mangler@gmail.com'
21
21
  s.homepage = 'http://cpee.org/'
@@ -210,10 +210,12 @@ module CPEE
210
210
  end
211
211
  end
212
212
 
213
+ event['time:timestamp'] = notification['timestamp'] || Time.now.xmlschema(4)
214
+
213
215
  if topic == 'task' && event_name == 'probe'
214
216
  rs = WEEL::ReadStructure.new(content['data'],{},{},{})
215
217
  rc = CPEE::Logging::extract_result(receiving) if receiving && !receiving.empty?
216
- te = event.dup
218
+ te = event
217
219
 
218
220
  content['probes'].each do |p|
219
221
 
@@ -254,9 +256,6 @@ module CPEE
254
256
  end
255
257
  if te['stream:datastream'] && te['stream:datastream'].any?
256
258
  te['cpee:lifecycle:transition'] = 'stream/data'
257
- File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
258
- f << {'event' => te}.to_yaml
259
- end
260
259
  EM.defer do
261
260
  self::notify(
262
261
  opts,
@@ -274,19 +273,18 @@ module CPEE
274
273
  end
275
274
 
276
275
  end
277
-
278
- end
279
-
280
- if receiving && !receiving.empty?
281
- event['data'] = receiving
282
- end
283
- if content['data'] && !content['data'].empty?
284
- event['data'] = content['data']
276
+ event = nil if !event['stream:datastream']
277
+ else
278
+ if receiving && !receiving.empty?
279
+ event['data'] = receiving
280
+ end
281
+ if content['data'] && !content['data'].empty?
282
+ event['data'] = content['data']
283
+ end
285
284
  end
286
- event['time:timestamp']= notification['timestamp'] || Time.now.xmlschema(4)
287
285
  File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
288
286
  f << {'event' => event}.to_yaml
289
- end
287
+ end unless event.nil? # :-) for task/probes
290
288
  end
291
289
 
292
290
  end
@@ -190,11 +190,11 @@ def react(name,copy=false,deep=0,index=nil)
190
190
  end
191
191
  end
192
192
 
193
- def extract(path)
193
+ def ropen(path)
194
194
  unlink = false
195
195
  if path =~ /^http.*/
196
196
  unlink = true
197
- text = Tempfile.new('extract-model-download')
197
+ fhandle = Tempfile.new('extract-model-download')
198
198
  request = Typhoeus::Request.new(path)
199
199
  request.on_headers do |response|
200
200
  if response.code != 200
@@ -202,15 +202,20 @@ def extract(path)
202
202
  end
203
203
  end
204
204
  request.on_body do |chunk|
205
- text.write(chunk)
205
+ fhandle.write(chunk)
206
206
  end
207
207
  request.on_complete do |response|
208
- text.rewind
208
+ fhandle.rewind
209
209
  end
210
210
  request.run
211
211
  else
212
- text = File.open(path)
212
+ fhandle = File.open(path)
213
213
  end
214
+ [fhandle,unlink]
215
+ end
216
+
217
+ def extract(path)
218
+ text, unlink = ropen(path)
214
219
  yaml = Psych.load_stream(text)
215
220
  changes = []
216
221
 
@@ -278,6 +283,8 @@ ARGV.options { |opt|
278
283
  opt.on(wrap("index [LOG] creates an index for a log file, for more efficient parsing. When called without [LOG], indexes all log files in the current directory. Examples:\n#{exname} index https://cpee.org/log/123.xes.yaml\n#{exname} index ~/log/logs/456.xes.yaml"))
279
284
  opt.on("")
280
285
  opt.on(wrap("to-xes-xml [LOG] convert cpee xes-yaml to xes-xml. Works for local and remote logs. When called without [LOG], all log files in the current directory are converted. Examples:\n#{exname} to-xes-xml https://cpee.org/log/123.xes.yaml\n#{exname} to-xes-xml ~/log/logs/456.xes.yaml"))
286
+ opt.on("")
287
+ opt.on(wrap("sort [LOG] sort a cpee xes-yaml file by time:timestamp. Works for local and remote logs. When called without [LOG], all log files in the current directory are sorted. Examples:\n#{exname} sort https://cpee.org/log/123.xes.yaml\n#{exname} sort ~/log/logs/456.xes.yaml"))
281
288
  opt.parse!
282
289
  }
283
290
 
@@ -461,6 +468,44 @@ elsif command == 'to-xes-xml'
461
468
  File.write(fname, TEMPLATE_XES_XML_END, mode: 'a')
462
469
  puts "#{count}/#{total.to_i} 100% (took #{format_secs(duration)}) \n"
463
470
  end
471
+ elsif command == 'sort'
472
+ path = if path
473
+ [path]
474
+ else
475
+ Dir.glob('*.xes.yaml')
476
+ end
477
+ path.each do |f|
478
+ index = []
479
+ write_list = []
480
+ io,unlink = ropen(f)
481
+ while(io.eof?().!())
482
+ start = io.pos()
483
+ docs = io.readline("---\n",chomp: true)
484
+ doc = YAML::load(docs, permitted_classes: [Time])
485
+ if(doc.nil?().!()) then
486
+ ts = doc.dig('event','time:timestamp')
487
+ if(ts.nil?().!())
488
+ index.push({ :ts => ts, :s => start.to_i(), :l => docs.length().to_i() })
489
+ else
490
+ if(index.empty?())
491
+ write_list.push({ :s => start.to_i(), :l => docs.length().to_i() })
492
+ else
493
+ index.last()[:l] = index.last()[:l]+4+docs.length().to_i()
494
+ end
495
+ end
496
+ end
497
+ end
498
+ write_list.concat(index.sort() { |a,b| Time.parse(a[:ts]) <=> Time.parse(b[:ts]) })
499
+ output_file = File.open("#{File.basename(f,'.xes.yaml')}.sorted.xes.yaml", 'w')
500
+ write_list.each() { |el|
501
+ output_file.write("---\n")
502
+ io.seek(el[:s],IO::SEEK_SET)
503
+ output_file.write(io.read(el[:l]))
504
+ }
505
+ output_file.close()
506
+ io.close()
507
+ io.unlink() if unlink
508
+ end
464
509
  else
465
510
  puts ARGV.options
466
511
  end
metadata CHANGED
@@ -1,11 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-logging-xes-yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
8
8
  - Florian Stertz
9
+ - Matthias Ehrendorfer
10
+ - Dominik Voigt
9
11
  bindir: tools
10
12
  cert_chain: []
11
13
  date: 1980-01-02 00:00:00.000000000 Z