From 38e09215e3e40353a2b15f17140b1a17c8cf3051 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Sun, 23 Jun 2024 15:45:29 +0200 Subject: [PATCH 1/2] Improve the supported.rb for admins --- _plugins/gtn/supported.rb | 43 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/_plugins/gtn/supported.rb b/_plugins/gtn/supported.rb index b851010fe0b099..641adda68e45f0 100644 --- a/_plugins/gtn/supported.rb +++ b/_plugins/gtn/supported.rb @@ -121,8 +121,47 @@ def test_exact end end else + server = ARGV[0] + workflow = ARGV[1] + + def short_id(tool_id) + if tool_id.count('/') > 4 + tool_id.split('/')[0..-2].join('/') + else + tool_id + end + end + require 'json' - pp ARGV - pp Gtn::Supported.calculate(JSON.parse(File.open('metadata/public-server-tools.json')), ARGV) + tool_list = JSON.parse(`curl -s #{server}/api/tools?in_panel=False`).map{|x| x['id']} + pp "Found #{tool_list.length} tools" + + version_smash = tool_list.map{|x| + if x.count('/') > 4 + [x.split('/')[0..-2].join('/'), x.split('/')[-1]] + else + [x, []] + end + } + version_smash = version_smash.group_by{|x, y| x}.to_a.map{|k, v| [k, v.map{|x, y| y}]}.to_h + + workflow_tools = JSON.parse(File.open(workflow).read)['steps'].map{|_, x| x['tool_id']} + workflow_tools.select!{|x| x && x.length.positive?} + pp "Found #{workflow_tools.length} tools in the workflow" + + workflow_tools.each do |tool| + if tool_list.include?(tool) + puts "✅ #{tool} is supported" + else + if version_smash.key?(short_id(tool)) + puts "❔ #{tool} is not supported, but #{version_smash[short_id(tool)]} are" + else + puts "❌ #{tool} is not supported" + end + end + end + + + # pp Gtn::Supported.calculate(JSON.parse(File.open('metadata/public-server-tools.json')), ARGV[1]) end end From 08223b923974cc875f76fbd2e27b45a9e82e7142 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Sun, 23 Jun 2024 15:50:04 +0200 Subject: [PATCH 2/2] better debugging --- _plugins/gtn/supported.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/_plugins/gtn/supported.rb b/_plugins/gtn/supported.rb index 641adda68e45f0..444896aade0731 100644 --- a/_plugins/gtn/supported.rb +++ b/_plugins/gtn/supported.rb @@ -134,7 +134,7 @@ def short_id(tool_id) require 'json' tool_list = JSON.parse(`curl -s #{server}/api/tools?in_panel=False`).map{|x| x['id']} - pp "Found #{tool_list.length} tools" + puts "Found #{tool_list.length} tools in #{server}" version_smash = tool_list.map{|x| if x.count('/') > 4 @@ -147,7 +147,7 @@ def short_id(tool_id) workflow_tools = JSON.parse(File.open(workflow).read)['steps'].map{|_, x| x['tool_id']} workflow_tools.select!{|x| x && x.length.positive?} - pp "Found #{workflow_tools.length} tools in the workflow" + puts "Found #{workflow_tools.length} tools in the #{workflow}" workflow_tools.each do |tool| if tool_list.include?(tool) @@ -161,7 +161,21 @@ def short_id(tool_id) end end + metadata = { + "servers" => [{"url" => server, "name" => "CLI Tested Server"}], + "tools" => {} + } + version_smash.each do |k, v| + if k.count('/') > 3 + metadata["tools"][k] = v.map{|x| [x, [0]]}.to_h + else + metadata["tools"][k] = { + "_" => [0] + } + end + end - # pp Gtn::Supported.calculate(JSON.parse(File.open('metadata/public-server-tools.json')), ARGV[1]) + puts "GTN Rendering:" + pp Gtn::Supported.calculate(metadata, workflow_tools) end end