Skip to content

Commit

Permalink
Improve the supported.rb for admins
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Jun 23, 2024
1 parent 61e7b9b commit 38e0921
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions _plugins/gtn/supported.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 38e0921

Please sign in to comment.