Skip to content

Commit

Permalink
Update to schemas 1.2.0 (#20)
Browse files Browse the repository at this point in the history
* Run npm run generate:server:latest

* Update schemas and annotator version

* Update npm scripts

* Update tool description
  • Loading branch information
tschaffter authored Jun 21, 2021
1 parent 882c936 commit b098e59
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .nlpsandbox-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.2
1.2.0
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ performance -- just don't expect a high performance!

## Specification

- NLP Sandbox schemas version: 1.1.2
- NLP Sandbox tool version: 1.1.2
- NLP Sandbox schemas version: 1.2.0
- NLP Sandbox tool version: 1.2.0
- Docker image: [docker.synapse.org/syn22277123/id-annotator-example]


Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"

services:
id-annotator:
image: docker.synapse.org/syn22277123/id-annotator-example:1.1.2
image: docker.synapse.org/syn22277123/id-annotator-example:1.2.0
build:
context: server
dockerfile: Dockerfile
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
},
"private": true,
"scripts": {
"generate:server": "openapi-generator-cli generate -g python-flask -o server -i $npm_config_specification",
"generate:server": "openapi-generator-cli generate -g python-flask -o server -i $npm_config_openapi",
"generate:server:latest": "openapi-generator-cli generate -g python-flask -o server -i https://nlpsandbox.github.io/nlpsandbox-schemas/id-annotator/latest/openapi.json",
"generate:server:edge": "openapi-generator-cli generate -g python-flask -o server -i https://nlpsandbox.github.io/nlpsandbox-schemas/id-annotator/edge/openapi.json",
"generate:server:version": "openapi-generator-cli generate -g python-flask -o server -i https://nlpsandbox.github.io/nlpsandbox-schemas/id-annotator/$npm_config_schemas_version/openapi.json",
"lint": "cd server && flake8",
"test": "cd server && tox",
"install:dependencies": "npm ci && cd server && pip install -r requirements.txt",
Expand Down
10 changes: 6 additions & 4 deletions server/openapi_server/controllers/tool_controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from openapi_server.models.tool import Tool # noqa: E501
from openapi_server.models.tool_dependencies import ToolDependencies # noqa: E501
from openapi_server.models.tool_type import ToolType
from openapi_server.models.license import License


Expand All @@ -13,15 +14,16 @@ def get_tool(): # noqa: E501
"""
tool = Tool(
name="id-annotator-example",
version="1.1.2",
version="1.2.0",
license=License.APACHE_2_0,
repository="github:nlpsandbox/id-annotator-example",
description="Example implementation of the NLP Sandbox ID Annotator",
description="Example implementation of the NLP Sandbox ID Annotator " +
" API",
author="NLP Sandbox Team",
author_email="[email protected]",
url="https://github.com/nlpsandbox/id-annotator-example",
type="nlpsandbox:id-annotator",
api_version="1.1.2"
type=ToolType.ID_ANNOTATOR,
api_version="1.2.0"
)
return tool, 200

Expand Down
1 change: 1 addition & 0 deletions server/openapi_server/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
from openapi_server.models.text_id_annotation_response import TextIdAnnotationResponse
from openapi_server.models.tool import Tool
from openapi_server.models.tool_dependencies import ToolDependencies
from openapi_server.models.tool_type import ToolType
22 changes: 8 additions & 14 deletions server/openapi_server/models/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

from openapi_server.models.base_model_ import Model
from openapi_server.models.license import License
from openapi_server.models.tool_type import ToolType
import re
from openapi_server import util

from openapi_server.models.license import License # noqa: E501
from openapi_server.models.tool_type import ToolType # noqa: E501
import re # noqa: E501

class Tool(Model):
Expand Down Expand Up @@ -39,7 +41,7 @@ def __init__(self, name=None, version=None, license=None, repository=None, descr
:param url: The url of this Tool. # noqa: E501
:type url: str
:param type: The type of this Tool. # noqa: E501
:type type: str
:type type: ToolType
:param api_version: The api_version of this Tool. # noqa: E501
:type api_version: str
"""
Expand All @@ -52,7 +54,7 @@ def __init__(self, name=None, version=None, license=None, repository=None, descr
'author': str,
'author_email': str,
'url': str,
'type': str,
'type': ToolType,
'api_version': str
}

Expand Down Expand Up @@ -221,8 +223,8 @@ def description(self, description):
"""
if description is None:
raise ValueError("Invalid value for `description`, must not be `None`") # noqa: E501
if description is not None and len(description) > 100:
raise ValueError("Invalid value for `description`, length must be less than or equal to `100`") # noqa: E501
if description is not None and len(description) > 280:
raise ValueError("Invalid value for `description`, length must be less than or equal to `280`") # noqa: E501

self._description = description

Expand Down Expand Up @@ -305,30 +307,22 @@ def url(self, url):
def type(self):
"""Gets the type of this Tool.
The type of this tool # noqa: E501
:return: The type of this Tool.
:rtype: str
:rtype: ToolType
"""
return self._type

@type.setter
def type(self, type):
"""Sets the type of this Tool.
The type of this tool # noqa: E501
:param type: The type of this Tool.
:type type: str
:type type: ToolType
"""
if type is None:
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
if type is not None and len(type) > 60:
raise ValueError("Invalid value for `type`, length must be less than or equal to `60`") # noqa: E501
if type is not None and len(type) < 3:
raise ValueError("Invalid value for `type`, length must be greater than or equal to `3`") # noqa: E501
if type is not None and not re.search(r'^[a-z0-9]+(?:-[a-z0-9]+)*(:)[a-z0-9]+(?:-[a-z0-9]+)*$', type): # noqa: E501
raise ValueError("Invalid value for `type`, must be a follow pattern or equal to `/^[a-z0-9]+(?:-[a-z0-9]+)*(:)[a-z0-9]+(?:-[a-z0-9]+)*$/`") # noqa: E501

self._type = type

Expand Down
49 changes: 49 additions & 0 deletions server/openapi_server/models/tool_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# coding: utf-8

from __future__ import absolute_import
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401

from openapi_server.models.base_model_ import Model
from openapi_server import util


class ToolType(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Do not edit the class manually.
"""

"""
allowed enum values
"""
CONTACT_ANNOTATOR = "nlpsandbox:contact-annotator"
COVID_SYMPTOM_ANNOTATOR = "nlpsandbox:covid-symptom-annotator"
DATA_NODE = "nlpsandbox:data-node"
DATE_ANNOTATOR = "nlpsandbox:date-annotator"
ID_ANNOTATOR = "nlpsandbox:id-annotator"
LOCATION_ANNOTATOR = "nlpsandbox:location-annotator"
PERSON_NAME_ANNOTATOR = "nlpsandbox:person-name-annotator"
PHI_ANNOTATOR = "nlpsandbox:phi-annotator"
PHI_DEIDENTIFIER = "nlpsandbox:phi-deidentifier"
def __init__(self): # noqa: E501
"""ToolType - a model defined in OpenAPI
"""
self.openapi_types = {
}

self.attribute_map = {
}

@classmethod
def from_dict(cls, dikt) -> 'ToolType':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The ToolType of this ToolType. # noqa: E501
:rtype: ToolType
"""
return util.deserialize_model(dikt, cls)
45 changes: 24 additions & 21 deletions server/openapi_server/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ info:
url: https://nlpsandbox.io
description: |
# Introduction
An ID Annotator takes as input a clinical note and outputs a list of predicted ID annotations found in the clinical note. This OpenAPI document describes the specification of a ID Annotator. This specification includes the schemas of the input and output data, and the conditions that this annotator must meet if you want to benchmark its performance on [nlpsandbox.io](https://nlpsandbox.io).
An ID annotator takes as input a clinical note and outputs a list of predicted ID annotations found in the clinical note. This OpenAPI document describes the specification of the NLP Sandbox ID Annotator API. This specification includes the schemas of the input and output data, and the requirements that this annotator must meet if you want to benchmark its performance on [nlpsandbox.io](https://nlpsandbox.io).
# Getting Started
The GitHub repository (will be added later) [nlpsandbox/id-annotator-example](https://github.com/nlpsandbox/id-annotator-example) provides a simple example implementation of a Python-Flask ID Annotator. By the end of the tutorial available in the README, you will have built a Docker image for a simple ID Annotator. You will then be able to submit this image to [nlpsandbox.io](https://nlpsandbox.io) to benchmark its performance.
The GitHub repository [nlpsandbox/id-annotator-example](https://github.com/nlpsandbox/id-annotator-example) provides an example implementation of the NLP Sandbox ID Annotator API in Python-Flask. By the end of the tutorial available in the README, you will have built a Docker image for this NLP Sandbox tool. You will then be able to submit this image to [nlpsandbox.io](https://nlpsandbox.io) to benchmark its performance.
# Benchmarking Requirements
Your NLP Sandbox tool must meet the following conditions before evaluating its performance on [nlpsandbox.io](https://nlpsandbox.io).
Your NLP Sandbox tool must meet the following requirements before evaluating its performance on [nlpsandbox.io](https://nlpsandbox.io).
- The endpoint `/` must redirect to `/api/v1/tool`.
- The endpoint `/ui` must redirect to the web interface (UI).
- The endpoint `/ui` must redirect to the Swagger User Interface (UI).
- The output of this tool must be reproducible: a given input should always
generate the same output.
Expand All @@ -22,14 +22,14 @@ info:
connect to remote servers.
# Examples
- [ID Annotator Example (Python)](https://github.com/nlpsandbox/id-annotator-example)
- [NLP Sandbox ID Annotator Example (Python)](https://github.com/nlpsandbox/id-annotator-example)
license:
name: Apache 2.0
url: https://github.com/nlpsandbox/nlpsandbox-schemas/blob/develop/LICENSE
url: https://github.com/nlpsandbox/nlpsandbox-schemas/blob/main/LICENSE
title: NLP Sandbox ID Annotator API
version: 1.1.2
version: 1.2.0
x-logo:
url: https://nlpsandbox.github.io/nlpsandbox-schemas/logo.png
url: https://github.com/nlpsandbox/nlpsandbox-schemas/raw/main/docs/logo.png
servers:
- url: http://example.com/api/v1
- url: https://example.com/api/v1
Expand Down Expand Up @@ -395,10 +395,18 @@ components:
type: string
ToolType:
description: The type of this tool
enum:
- nlpsandbox:contact-annotator
- nlpsandbox:covid-symptom-annotator
- nlpsandbox:data-node
- nlpsandbox:date-annotator
- nlpsandbox:id-annotator
- nlpsandbox:location-annotator
- nlpsandbox:person-name-annotator
- nlpsandbox:phi-annotator
- nlpsandbox:phi-deidentifier
example: nlpsandbox:date-annotator
maxLength: 60
minLength: 3
pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*(:)[a-z0-9]+(?:-[a-z0-9]+)*$
title: ToolType
type: string
Tool:
description: Information about an NLP tool
Expand All @@ -412,7 +420,7 @@ components:
authorEmail: [email protected]
url: https://example.com
type: nlpsandbox:date-annotator
apiVersion: 1.1.2
apiVersion: 1.2.0
properties:
name:
description: The tool name
Expand All @@ -432,7 +440,7 @@ components:
type: string
description:
description: A short, one-sentence summary of the tool
maxLength: 100
maxLength: 280
type: string
author:
description: The author of the tool
Expand All @@ -446,12 +454,7 @@ components:
format: uri
type: string
type:
description: The type of this tool
example: nlpsandbox:date-annotator
maxLength: 60
minLength: 3
pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*(:)[a-z0-9]+(?:-[a-z0-9]+)*$
type: string
$ref: '#/components/schemas/ToolType'
apiVersion:
description: The version of the tool OpenAPI specification
minLength: 1
Expand Down Expand Up @@ -483,7 +486,7 @@ components:
authorEmail: [email protected]
url: https://example.com
type: nlpsandbox:date-annotator
apiVersion: 1.1.2
apiVersion: 1.2.0
- name: awesome-nlp-tool
version: 1.0.6
license: apache-2.0
Expand All @@ -493,7 +496,7 @@ components:
authorEmail: [email protected]
url: https://example.com
type: nlpsandbox:date-annotator
apiVersion: 1.1.2
apiVersion: 1.2.0
properties:
tools:
description: A list of tools
Expand Down

0 comments on commit b098e59

Please sign in to comment.