diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index e86e17d..ce6fd77 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -33,7 +33,7 @@ jobs: # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --count --max-complexity=10 --max-line-length=127 --statistics # - name: Test with pytest # run: | # pytest diff --git a/src/entities/algorithm.py b/src/entities/algorithm.py deleted file mode 100644 index 2465f14..0000000 --- a/src/entities/algorithm.py +++ /dev/null @@ -1,19 +0,0 @@ -from typing import List, Optional -from pydantic import BaseModel -from .meta import MetaInfo -from .parameter import Parameter - - -class Algorithm(BaseModel): - meta: Optional[MetaInfo] - ontological_classes: Optional[List[str]] - visible: Optional[bool] - temporary: Optional[str] - featured: Optional[str] - parameters: Optional[Parameter] - ranking: Optional[str] - bibtex: Optional[dict] - training_service: Optional[str] - prediction_service: Optional[str] - report_service: Optional[str] - _id: str diff --git a/src/entities/dataentry.py b/src/entities/dataentry.py deleted file mode 100644 index 1535424..0000000 --- a/src/entities/dataentry.py +++ /dev/null @@ -1,8 +0,0 @@ -from .entryid import EntryId -from pydantic import BaseModel -from typing import List, Optional - - -class DataEntry(BaseModel): - entryId: str - values: Optional[List[str]] diff --git a/src/entities/dataset.py b/src/entities/dataset.py deleted file mode 100644 index 35eae2d..0000000 --- a/src/entities/dataset.py +++ /dev/null @@ -1,22 +0,0 @@ -from .jaqpot_base import JaqpotEntity -from .dataentry import DataEntry -from .featureinfo import FeatureInfo -from .meta import MetaInfo -from typing import List, Optional -from pydantic import BaseModel - - -class Dataset(BaseModel): - meta: Optional[MetaInfo] - ontologicalClasses: Optional[List[str]] - visible: Optional[bool] - temporary: Optional[str] - featured: Optional[str] - datasetUri: Optional[str] - byModel: Optional[str] - dataEntry: Optional[DataEntry] - features: Optional[FeatureInfo] - totalRows: Optional[int] - totalColumns: Optional[int] - descriptors: Optional[List[str]] - id: str diff --git a/src/entities/entryid.py b/src/entities/entryid.py deleted file mode 100644 index 290e348..0000000 --- a/src/entities/entryid.py +++ /dev/null @@ -1,9 +0,0 @@ -from typing import List, Optional -from pydantic import BaseModel - - -class EntryId(BaseModel): - name: Optional[str] - ownerUUID: Optional[str] - URI: Optional[str] - type: Optional[str] diff --git a/src/entities/error_report.py b/src/entities/error_report.py deleted file mode 100644 index bd9e75a..0000000 --- a/src/entities/error_report.py +++ /dev/null @@ -1,19 +0,0 @@ -from .meta import MetaInfo # noqa: F401,E501 -from typing import List, Optional -from pydantic import BaseModel - - -class ErrorReport(BaseModel): - - meta : Optional[MetaInfo] - ontological_classes : Optional[List[str]] - visible : Optional[bool] - temporary : Optional[str] - featured : Optional[str] - code : Optional[str] - actor : Optional[str] - message : Optional[str] - details : Optional[List[str]] - http_status : Optional[int] - id : str - discriminator : Optional[str] diff --git a/src/entities/feature.py b/src/entities/feature.py deleted file mode 100644 index 0bdf2b1..0000000 --- a/src/entities/feature.py +++ /dev/null @@ -1,18 +0,0 @@ -from .meta import MetaInfo # noqa: F401,E501 -from typing import List, Optional -from pydantic import BaseModel - - -class Feature(BaseModel): - meta : Optional[MetaInfo] - ontologicalClasses : Optional[List[str]] - visible : Optional[bool] - temporary : Optional[str] - featured : Optional[str] - units : Optional[str] - predictorFor : Optional[str] - admissibleValues : Optional[str] - actualIndependentFeatureName : Optional[str] - fromPretrained : Optional[str] - id : str - discriminator : Optional[str] diff --git a/src/entities/featureinfo.py b/src/entities/featureinfo.py deleted file mode 100644 index 7ea4631..0000000 --- a/src/entities/featureinfo.py +++ /dev/null @@ -1,12 +0,0 @@ -from typing import List, Optional -from pydantic import BaseModel - - -class FeatureInfo(BaseModel): - name: Optional[str] - units: Optional[str] - conditions: Optional[List[str]] - category: Optional[str] - ont: Optional[str] - uri: Optional[str] - key: Optional[str] diff --git a/src/entities/jaqpot_base.py b/src/entities/jaqpot_base.py deleted file mode 100644 index f76192e..0000000 --- a/src/entities/jaqpot_base.py +++ /dev/null @@ -1,5 +0,0 @@ -from pydantic import BaseModel - - -class JaqpotEntity(BaseModel): - _id: str diff --git a/src/entities/meta.py b/src/entities/meta.py deleted file mode 100644 index a33aebf..0000000 --- a/src/entities/meta.py +++ /dev/null @@ -1,21 +0,0 @@ -from typing import List, Optional -from pydantic import BaseModel -import datetime - - -class MetaInfo(BaseModel): - identifiers: Optional[List[str]] - comments: Optional[List[str]] - descriptions: Optional[List[str]] - titles: Optional[List[str]] - subjects: Optional[List[str]] - publishers: Optional[List[str]] - creators: Optional[List[str]] - contributors: Optional[List[str]] - audiences: Optional[List[str]] - rights: Optional[List[str]] - sameAs: Optional[str] - seeAlso: Optional[str] - hasSources: Optional[List[str]] - doi: Optional[str] - date: Optional[datetime.datetime] diff --git a/src/entities/model.py b/src/entities/model.py deleted file mode 100644 index 348686b..0000000 --- a/src/entities/model.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import List, Optional -from pydantic import BaseModel - - -class PretrainedModel(BaseModel): - raw_model: Optional[str] - pmml_model: Optional[str] - additional_info: Optional[List[str]] - dependent_features: Optional[List[str]] - independent_features: Optional[List[str]] - predicted_features: Optional[List[str]] - implemented_in: Optional[str] - implemented_with: Optional[str] - title: Optional[str] - discription: Optional[str] - algorithm: Optional[str] - discriminator: Optional[str] diff --git a/src/entities/parameter.py b/src/entities/parameter.py deleted file mode 100644 index 4a6b490..0000000 --- a/src/entities/parameter.py +++ /dev/null @@ -1,12 +0,0 @@ -from typing import List, Optional -from pydantic import BaseModel - - -class Parameter(BaseModel): - required: Optional[str] - description: Optional[str] - vendor_extensions: Optional[List[str]] - pattern: Optional[str] - _in: Optional[str] - name: Optional[str] - discriminator: Optional[str] diff --git a/src/entities/task.py b/src/entities/task.py deleted file mode 100644 index 5721891..0000000 --- a/src/entities/task.py +++ /dev/null @@ -1,22 +0,0 @@ -from .error_report import ErrorReport # noqa: F401,E501 -from .meta import MetaInfo # noqa: F401,E501 -from typing import List, Optional -from pydantic import BaseModel - - -class Task(BaseModel): - meta: Optional[MetaInfo] - ontological_classes: Optional[List[str]] - visible: Optional[bool] - temporary: Optional[str] - featured: Optional[str] - result_uri: Optional[str] - result: Optional[str] - percentage_completed: Optional[float] - error_report: Optional[ErrorReport] - http_status: Optional[int] - duration: Optional[float] - type: Optional[str] - id: str - status: Optional[str] - discriminator: Optional[str] diff --git a/src/handlers/predict.py b/src/handlers/predict.py index 10a9231..985d7e4 100644 --- a/src/handlers/predict.py +++ b/src/handlers/predict.py @@ -1,6 +1,7 @@ from ..entities.prediction_request import PredictionRequestPydantic from ..helpers import model_decoder, json_to_predreq + def model_post_handler(request: PredictionRequestPydantic): model = model_decoder.decode(request.model['rawModel']) data_entry_all = json_to_predreq.decode(request, model) @@ -24,4 +25,4 @@ def model_post_handler(request: PredictionRequestPydantic): final_all = {"predictions": [dict(zip(results, t)) for t in zip(*results.values())]} - return final_all \ No newline at end of file + return final_all diff --git a/src/helpers/json_to_predreq.py b/src/helpers/json_to_predreq.py index 10d1826..7acdaa8 100644 --- a/src/helpers/json_to_predreq.py +++ b/src/helpers/json_to_predreq.py @@ -1,11 +1,12 @@ from jaqpotpy.datasets import JaqpotpyDataset import pandas as pd + def decode(request, model): df = pd.DataFrame(request.dataset['input']) - independentFeatures = request.model['independentFeatures'] - smiles_cols = [feature['key'] for feature in independentFeatures if feature['featureType'] == 'SMILES'] - x_cols = [feature['key'] for feature in independentFeatures if feature['featureType'] != 'SMILES'] + independent_features = request.model['independentFeatures'] + smiles_cols = [feature['key'] for feature in independent_features if feature['featureType'] == 'SMILES'] + x_cols = [feature['key'] for feature in independent_features if feature['featureType'] != 'SMILES'] dataset = JaqpotpyDataset(df=df, smiles_cols=smiles_cols, x_cols=x_cols, task=model.task, featurizer=model.featurizer) return dataset diff --git a/src/helpers/model_decoder.py b/src/helpers/model_decoder.py index bafbe8e..5af43bf 100644 --- a/src/helpers/model_decoder.py +++ b/src/helpers/model_decoder.py @@ -2,8 +2,9 @@ import pickle import compress_pickle -def decode(rawModel): - model = b64decode(rawModel) + +def decode(raw_model): + model = b64decode(raw_model) try: p_mod = compress_pickle.loads(model, compression='bz2') except Exception as e: