generated from clemEssien/Bert-Phi-Annotator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix tag instruction * Small refactor * Fix tag * Fix ci workflow * Fix CI workflow * Fix model name in Dockerfile * Fix style * Fix remaining model name occurrences * Fix config name * Remove save_bert.py * Fix ci
- Loading branch information
1 parent
2c1ef0a
commit 3228faf
Showing
13 changed files
with
72 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
CONFIG_NAME=bert-base-ner | ||
MODEL_NAME=dslim/bert-base-NER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
CONFIG_NAME=bert-base-ner-uncased | ||
MODEL_NAME=dslim/bert-base-NER-uncased |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
CONFIG_NAME=bert-large-ner | ||
MODEL_NAME=dslim/bert-large-NER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
from enum import Enum | ||
|
||
defaultValues = { | ||
"CONFIG_NAME": "", | ||
"MODEL_NAME": "" | ||
} | ||
|
||
|
||
class ConfigName(Enum): | ||
BERT_BASE_NER = "bert-base-ner" | ||
BERT_BASE_NER_UNCASED = "bert-base-ner-uncased" | ||
BERT_LARGE_NER = "bert-large-ner" | ||
|
||
|
||
class AbstractConfig(object): | ||
""" | ||
Parent class containing get_property to return the environment variable or | ||
default value if not found. | ||
""" | ||
def __init__(self): | ||
self._defaultValues = defaultValues | ||
|
||
def get_property(self, property_name): | ||
if os.getenv(property_name) is not None: | ||
return os.getenv(property_name) | ||
# we don't want KeyError? | ||
if property_name not in self._defaultValues.keys(): | ||
return None # No default value found | ||
# return default value | ||
return self._defaultValues[property_name] | ||
|
||
|
||
class Config(AbstractConfig): | ||
""" | ||
This class is used to provide coniguration values to the application, first | ||
using environment variables and if not found, defaulting to those values | ||
provided in the defaultValues dictionary above. | ||
""" | ||
|
||
@property | ||
def config_name(self): | ||
return self.get_property('CONFIG_NAME') | ||
|
||
@property | ||
def model_name(self): | ||
return self.get_property('MODEL_NAME') | ||
|
||
|
||
config = Config() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
from openapi_server.models.tool_dependencies import ToolDependencies # noqa: E501 | ||
from openapi_server.models.tool_type import ToolType # noqa: E501 | ||
from openapi_server.models.license import License | ||
from openapi_server.nlp_config import bert | ||
from openapi_server.config import config | ||
|
||
|
||
def get_tool(): # noqa: E501 | ||
|
@@ -14,15 +14,14 @@ def get_tool(): # noqa: E501 | |
:rtype: Tool | ||
""" | ||
tool = Tool( | ||
name="phi-annotator-example", | ||
version="1.2.1", | ||
name=f"phi-annotator-huggingface-{config.config_name}", | ||
version="1.0.0", | ||
license=License.APACHE_2_0, | ||
repository="github:nlpsandbox/phi-annotator-example", | ||
description="Implementation of the NLP Sandbox PHI Annotator using " | ||
"HuggingFace Model: '%s'" % (bert.get_name()), | ||
repository="github:nlpsandbox/phi-annotator-huggingface", | ||
description="Hugging Face PHI annotator ({config.model_name})", | ||
author="NLP Sandbox Team", | ||
author_email="[email protected]", | ||
url="https://github.com/nlpsandbox/phi-annotator-example", | ||
url="https://github.com/nlpsandbox/phi-annotator-huggingface", | ||
type=ToolType.PHI_ANNOTATOR, | ||
api_version="1.2.0" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters