Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the supported.rb for admins #5065

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions _plugins/gtn/supported.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,61 @@ 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']}
puts "Found #{tool_list.length} tools in #{server}"

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?}
puts "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

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

puts "GTN Rendering:"
pp Gtn::Supported.calculate(metadata, workflow_tools)
end
end
Loading