ftr_ruby 0.1.10 → 0.1.12

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: e667a36034df0b5e34edc576681737cb36d010ad54ae6f71a9254823438ddf0e
4
- data.tar.gz: 48b56876e75bc26dd80c430f9a0e242538895aa239e5290ebbdd77253010bb64
3
+ metadata.gz: 59f547350dda6c8637f28caa54f6c2bfd2efac24a0392dae1f03da050d1e594c
4
+ data.tar.gz: 8c54b00e3f70e04a566508acbb5fed6bfa31271d34b87ddc7c058ada716016ca
5
5
  SHA512:
6
- metadata.gz: c26ebde15b974102fbf169f7d4a60118cdde56ceaa041306f5edf8c81f8c260b0deb389b1e36d9e7a5fbd4c11ca7e2f729dfdbd24bf59560a82f8c62d5f8de1a
7
- data.tar.gz: 6c5746418ab0aba173c1cd8f975ecaf71b4df961cc365570873d795b75d6ee414080ab2c78a253f3c4c58e07a713bc2800b4d0ce806659628749b2c7ef124568
6
+ metadata.gz: dd93ae6f08eff36fdfb17cdc07443338b5bf626bff5c70365c3c8469db49c14d94c1b8521a5d711d80989f70f4e6562d172d4b63c5dfd3ea4a0fa8a2d0da20d5
7
+ data.tar.gz: 7a48cd2953db78715f20133a2a88305529aecb83b343995af3989eee6a82059bb3065e487b33ef6db6f29e9114c8b7630a86406bbdebd4f1b55a5b9005953edf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.12] - 2026-05-27
4
+
5
+ ### Fixed
6
+ - `Output#createEvaluationResponse`: `score = "fail"` inside the `rescue` block and `summary = ...` inside the `if` block both introduced local variables that shadowed the `attr_accessor` methods for the entire method scope; replaced all references with `@score` and `@summary` to read and write the instance variables directly — this was causing `prov:value` to always be serialized as `nil` regardless of what callers set on `output.score`
7
+
8
+ ## [0.1.11] - 2026-05-26
9
+
10
+ ### Changed
11
+ - `TestInfra#get_tests_metrics` now fetches all test metrics in parallel using Ruby threads, significantly reducing latency when querying 40+ tests
12
+ - Refactored `TestInfra` internals into focused private helpers (`fetch_metric`, `fetch_metric_url`, `load_metric_graph`, `query_metric_graph`)
13
+ - `test_infrastructure.rb` now explicitly requires `jsonpath` rather than relying on transitive loading
14
+
15
+ ### Added
16
+ - RSpec tests for `TestInfra#get_tests_metrics` and `#fetch_metric_url` covering happy path, missing metadata, RDF load failures, and empty input
17
+
3
18
  ## [0.1.0] - 2026-03-28
4
19
 
5
20
  - Initial release
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FtrRuby
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.12"
5
5
  end
data/lib/output.rb CHANGED
@@ -80,9 +80,9 @@ module FtrRuby
80
80
 
81
81
  add_newline_to_comments
82
82
 
83
- if summary =~ /^Summary$/
84
- summary = "Summary of test results: #{comments[-1]}"
85
- summary ||= "Summary of test results: #{comments[-2]}"
83
+ if @summary =~ /^Summary$/
84
+ @summary = "Summary of test results: #{comments[-1]}"
85
+ @summary ||= "Summary of test results: #{comments[-2]}"
86
86
  end
87
87
 
88
88
  executionid = "urn:ostrails:testexecutionactivity:" + SecureRandom.uuid
@@ -99,7 +99,7 @@ module FtrRuby
99
99
  triplify(uniqueid, dct.title, "#{name} OUTPUT", g)
100
100
  triplify(uniqueid, dct.description, "OUTPUT OF #{description}", g)
101
101
  triplify(uniqueid, dct.license, license, g)
102
- triplify(uniqueid, prov.value, score, g)
102
+ triplify(uniqueid, prov.value, @score, g)
103
103
  triplify(uniqueid, ftr.summary, summary, g)
104
104
  triplify(uniqueid, RDF::Vocab::PROV.generatedAtTime, dt, g)
105
105
  triplify(uniqueid, ftr.log, comments.join, g)
@@ -134,10 +134,10 @@ module FtrRuby
134
134
  rescue StandardError
135
135
  triplify(uniqueid, ftr.assessmentTarget, "not a URI", g)
136
136
  triplify(executionid, prov.used, "not a URI", g)
137
- score = "fail"
137
+ @score = "fail"
138
138
  end
139
139
 
140
- unless score == "pass"
140
+ unless @score == "pass"
141
141
  guidance.each do |advice, label|
142
142
  adviceid = "urn:ostrails:testexecutionactivity:advice:" + SecureRandom.uuid
143
143
  triplify(uniqueid, ftr.suggestion, adviceid, g)
@@ -1,3 +1,5 @@
1
+ require "jsonpath"
2
+
1
3
  module FtrRuby
2
4
  class TestInfra
3
5
  attr_accessor :test_protocol, :test_host, :basepath
@@ -8,46 +10,57 @@ module FtrRuby
8
10
  @basepath = basepath
9
11
  end
10
12
 
11
- # there is a need to map between a test and its registered Metric in FS. This will return the label for the test
12
- # in principle, we cojuld return a more complex object, but all I need now is the label
13
+ # there is a need to map between a test and its registered Metric in FS.
14
+ # This will return the label for the test
15
+ # in principle, we cojuld return a more complex object,
16
+ # but all I need now is the label
13
17
  def get_tests_metrics(tests:)
18
+ threads = tests.map { |testid| Thread.new(testid) { |tid| fetch_metric(tid) } }
19
+
14
20
  labels = {}
15
21
  landingpages = {}
16
- tests.each do |testid|
17
- warn "getting dcat for #{testid} #{test_protocol}://#{test_host}/#{basepath}/#{testid}"
18
- dcat = RestClient::Request.execute({
19
- method: :get,
20
- url: "#{test_protocol}://#{test_host}/#{basepath}/#{testid}",
21
- headers: { "Accept" => "application/json" }
22
- }).body
23
- parseddcat = JSON.parse(dcat)
24
- # this next line should probably be done with SPARQL
25
- # # TODO TODO TODO
26
- jpath = JsonPath.new('[0]["http://semanticscience.org/resource/SIO_000233"][0]["@id"]') # is implementation of
27
- metricurl = jpath.on(parseddcat).first
28
-
29
- begin
30
- g = RDF::Graph.load(metricurl, format: :turtle)
31
- rescue StandardError => e
32
- warn "DCAT Metric loading failed #{e.inspect}"
33
- g = RDF::Graph.new
34
- end
35
-
36
- title = g.query([nil, RDF::Vocab::DC.title, nil])&.first&.object&.to_s
37
- lp = g.query([nil, RDF::Vocab::DCAT.landingPage, nil])&.first&.object&.to_s
38
-
39
- labels[testid] = if title != ""
40
- title
41
- else
42
- "Metric label not available"
43
- end
44
- landingpages[testid] = if lp != ""
45
- lp
46
- else
47
- ""
48
- end
22
+ threads.each do |t|
23
+ tid, label, lpage = t.value
24
+ labels[tid] = label
25
+ landingpages[tid] = lpage
49
26
  end
50
27
  [labels, landingpages]
51
28
  end
29
+
30
+ private
31
+
32
+ def fetch_metric(testid)
33
+ metricurl = fetch_metric_url(testid)
34
+ g = load_metric_graph(metricurl)
35
+ title, lp = query_metric_graph(g)
36
+ label = title.to_s != "" ? title : "Metric label not available"
37
+ [testid, label, lp.to_s]
38
+ end
39
+
40
+ def fetch_metric_url(testid)
41
+ warn "getting dcat for #{testid} #{test_protocol}://#{test_host}/#{basepath}/#{testid}"
42
+ dcat = RestClient::Request.execute({
43
+ method: :get,
44
+ url: "#{test_protocol}://#{test_host}/#{basepath}/#{testid}",
45
+ headers: { "Accept" => "application/json" }
46
+ }).body
47
+ parseddcat = JSON.parse(dcat)
48
+ # TODO: this should probably be done with SPARQL
49
+ jpath = JsonPath.new('[0]["http://semanticscience.org/resource/SIO_000233"][0]["@id"]') # is implementation of
50
+ jpath.on(parseddcat).first
51
+ end
52
+
53
+ def load_metric_graph(metricurl)
54
+ RDF::Graph.load(metricurl, format: :turtle)
55
+ rescue StandardError => e
56
+ warn "DCAT Metric loading failed #{e.inspect}"
57
+ RDF::Graph.new
58
+ end
59
+
60
+ def query_metric_graph(graph)
61
+ title = graph.query([nil, RDF::Vocab::DC.title, nil])&.first&.object&.to_s
62
+ lp = graph.query([nil, RDF::Vocab::DCAT.landingPage, nil])&.first&.object&.to_s
63
+ [title, lp]
64
+ end
52
65
  end
53
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftr_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - markwilkinson