From 9d1569115cf96cccf3bbfaa6e01998f0c102eef0 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Tue, 13 Feb 2024 11:45:36 +0100 Subject: [PATCH 1/3] Add API for individual tools mapped to servers --- _plugins/api.rb | 15 +++++++ api/swagger.json | 99 +++++++++++++++++++++++++++++++++++++++++++ metadata/swagger.yaml | 66 +++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+) diff --git a/_plugins/api.rb b/_plugins/api.rb index 8f42c0b72a5dbb..36597f1705a7f9 100644 --- a/_plugins/api.rb +++ b/_plugins/api.rb @@ -375,6 +375,21 @@ def generate(site) Jekyll::Hooks.register :site, :post_write do |site| dir = File.join(site.dest, 'api', 'workflows') + # Public tool listing: reorganised + site.data['public-server-tools']['tools'].each do |tool, version_data| + path = File.join(site.dest, 'api', 'psl', "#{tool}.json") + dir = File.dirname(path) + FileUtils.mkdir_p(dir) unless File.directory?(dir) + + d = version_data.dup + d.keys.each do |k| + # Replace the indexes with the server URLs from site['public-server-tools']['servers'] + d[k] = d[k].map { |v| site.data['public-server-tools']['servers'][v] } + end + + File.write(path, JSON.generate(d)) + end + # ro-crate-metadata.json TopicFilter.list_all_materials(site).select { |m| m['workflows'] }.each do |material| material['workflows'].each do |workflow| diff --git a/api/swagger.json b/api/swagger.json index 27e6a39ac17ce9..ed10cef2accb5e 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -345,6 +345,58 @@ } } } + }, + "/psl.json": { + "get": { + "tags": [ + "tools" + ], + "summary": "Get the GTN's public server tool listing. It lists all known public servers that are reachable at the time of the GTN's deployment, and which tool versions are installed on each of those servers.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Psl" + } + } + } + } + } + } + }, + "/psl/{toolId}.json": { + "get": { + "tags": [ + "tools" + ], + "parameters": [ + { + "name": "toolId", + "in": "path", + "example": "toolshed.g2.bx.psu.edu/repos/iuc/abricate/abricate", + "description": "Tool ID WITHOUT the version component!!", + "required": true, + "schema": { + "type": "string" + } + } + ], + "summary": "Get the GTN's public server tool listing for a specific tool ID. It lists all known public servers that are reachable at the time of the GTN's deployment, and which versions of this tool are available. It's very important that you strip the version component!", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PslIndividual" + } + } + } + } + } + } } }, "components": { @@ -571,6 +623,53 @@ } } } + }, + "Psl": { + "type": "object", + "properties": { + "servers": { + "$ref": "#/components/schemas/ArrayOfServers" + }, + "tools": { + "$ref": "#/components/schemas/ArrayOfToolVersions" + } + } + }, + "PslIndividual": { + "$ref": "#/components/schemas/ToolVersionClear" + }, + "ArrayOfServers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Server" + } + }, + "Server": { + "type": "object", + "properties": { + "url": { + "type": "string", + "description": "A url for the server" + }, + "name": { + "type": "string", + "description": "A human readable description" + } + } + }, + "ArrayOfToolVersions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ToolVersionOpaque" + } + }, + "ToolVersionOpaque": { + "type": "object", + "description": "A hash/dict where the top level keys are the known versions of that tool (or '_' for built in tools), and then the servers that have that tool. Note that the servers are actually a list of integers which refer to the Server listing field." + }, + "ToolVersionClear": { + "type": "object", + "description": "A hash/dict where the top level keys are the known versions of that tool (or '_' for built in tools), and then the servers that have that tool." } } } diff --git a/metadata/swagger.yaml b/metadata/swagger.yaml index b0862370408f34..2156405bc22b7b 100644 --- a/metadata/swagger.yaml +++ b/metadata/swagger.yaml @@ -225,6 +225,40 @@ paths: 200: description: successful operation + /psl.json: + get: + tags: + - tools + summary: Get the GTN's public server tool listing. It lists all known public servers that are reachable at the time of the GTN's deployment, and which tool versions are installed on each of those servers. + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Psl' + + /psl/{toolId}.json: + get: + tags: + - tools + parameters: + - name: toolId + in: path + example: toolshed.g2.bx.psu.edu/repos/iuc/abricate/abricate + description: Tool ID WITHOUT the version component!! Also when you call it properly you do NOT need to encode the /. + required: true + schema: + type: string + summary: Get the GTN's public server tool listing for a specific tool ID. It lists all known public servers that are reachable at the time of the GTN's deployment, and which versions of this tool are available. It's very important that you strip the version component! + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/PslIndividual' + components: schemas: TrainingMaterial: @@ -389,3 +423,35 @@ components: type: array items: $ref: '#/components/schemas/TrainingMaterial' + Psl: + type: object + properties: + servers: + $ref: '#/components/schemas/ArrayOfServers' + tools: + $ref: '#/components/schemas/ArrayOfToolVersions' + PslIndividual: + $ref: '#/components/schemas/ToolVersionClear' + ArrayOfServers: + type: array + items: + $ref: "#/components/schemas/Server" + Server: + type: object + properties: + url: + type: string + description: A url for the server + name: + type: string + description: A human readable description + ArrayOfToolVersions: + type: array + items: + $ref: "#/components/schemas/ToolVersionOpaque" + ToolVersionOpaque: + type: object + description: A hash/dict where the top level keys are the known versions of that tool (or '_' for built in tools), and then the servers that have that tool. Note that the servers are actually a list of integers which refer to the Server listing field. + ToolVersionClear: + type: object + description: A hash/dict where the top level keys are the known versions of that tool (or '_' for built in tools), and then the servers that have that tool. From 14592cdcceaac844a59686ee506eeddacc2e9fc8 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Tue, 13 Feb 2024 12:07:00 +0100 Subject: [PATCH 2/3] add abbr --- _includes/instance-dropdown.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/instance-dropdown.html b/_includes/instance-dropdown.html index 42f307c21d5a15..f97b4073477bc4 100644 --- a/_includes/instance-dropdown.html +++ b/_includes/instance-dropdown.html @@ -19,7 +19,7 @@ {% for inst in usegalaxy_exact %}
  • - {{ inst.name }} ⭐️ + {{ inst.name }} ⭐️
  • {% endfor %} From a71e0dcb239a8ac466aad636d4a8fe79b054ebf3 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Tue, 13 Feb 2024 15:03:14 +0100 Subject: [PATCH 3/3] add logging/ci support --- _plugins/api.rb | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/_plugins/api.rb b/_plugins/api.rb index 36597f1705a7f9..480817611fb61d 100644 --- a/_plugins/api.rb +++ b/_plugins/api.rb @@ -376,18 +376,23 @@ def generate(site) dir = File.join(site.dest, 'api', 'workflows') # Public tool listing: reorganised - site.data['public-server-tools']['tools'].each do |tool, version_data| - path = File.join(site.dest, 'api', 'psl', "#{tool}.json") - dir = File.dirname(path) - FileUtils.mkdir_p(dir) unless File.directory?(dir) - - d = version_data.dup - d.keys.each do |k| - # Replace the indexes with the server URLs from site['public-server-tools']['servers'] - d[k] = d[k].map { |v| site.data['public-server-tools']['servers'][v] } - end + if site.data['public-server-tools'] and site.data['public-server-tools']['tools'] + site.data['public-server-tools']['tools'].each do |tool, version_data| + path = File.join(site.dest, 'api', 'psl', "#{tool}.json") + dir = File.dirname(path) + FileUtils.mkdir_p(dir) unless File.directory?(dir) + + d = version_data.dup + d.keys.each do |k| + # Replace the indexes with the server URLs from site['public-server-tools']['servers'] + d[k] = d[k].map { |v| site.data['public-server-tools']['servers'][v] } + end - File.write(path, JSON.generate(d)) + File.write(path, JSON.generate(d)) + end + Jekyll.logger.debug "[GTN/API/PSL] PSL written" + else + Jekyll.logger.debug "[GTN/API/PSL] PSL Dataset not available, are you in a CI environment?" end # ro-crate-metadata.json