MaastrichtU-IDS / trapi-predict-kit

🧰 A package to help create and deploy Translator Reasoner APIs (TRAPI) from any prediction model exposed as a regular python function.
https://maastrichtu-ids.github.io/trapi-predict-kit
MIT License
1 stars 2 forks source link

running default predict generates type error #4

Closed micheldumontier closed 3 months ago

micheldumontier commented 3 months ago

@vemonet

out of the box :

$ hatch run predict
Traceback (most recent call last):
  File "/home/micheldumontier/code/predict-drug-disease-emb/src/predict_drug_disease_emb/predict.py", line 69, in <module>
    print(get_predictions(input_id, PredictOptions()))
TypeError: get_predictions() takes 1 positional argument but 2 were given

if i comment out the @trapi_predict annotation, the code runs though. any ideas?

@trapi_predict(path='/predict',
    name="Get predicted targets for a given entity",
    description="Return the predicted targets for a given entity: drug (DrugBank ID) or disease (OMIM ID), with confidence scores.",
    # Define which edges can be predicted by this function in a TRAPI query
    edges=[
        {
            'subject': 'biolink:Drug',
            'predicate': 'biolink:treats',
            'object': 'biolink:Disease',
        },
        {
            'subject': 'biolink:Disease',
            'predicate': 'biolink:treated_by',
            'object': 'biolink:Drug',
        },
    ],
    nodes={
        "biolink:Disease": {
            "id_prefixes": [
                "OMIM"
            ]
        },
        "biolink:Drug": {
            "id_prefixes": [
                "DRUGBANK"
            ]
        }
    }
)
def get_predictions(
        input_id: str, options: Optional[PredictOptions] = None
    ) -> PredictOutput:

 ...
micheldumontier commented 3 months ago

ok, i see from the documentation on this project that the call is:

def get_predictions(request: PredictInput) -> PredictOutput:

instead of the cookiecutter output of

def get_predictions(
        input_id: str, options: Optional[PredictOptions] = None
    ) -> PredictOutput:
micheldumontier commented 3 months ago

The cookiecutter code needs to be modified: https://github.com/MaastrichtU-IDS/cookiecutter-trapi-predict-kit/blob/main/%7B%7Bcookiecutter.package_name%7D%7D/src/%7B%7Bcookiecutter.module_name%7D%7D/predict.py

micheldumontier commented 3 months ago

fixed in 65cb44056fc7e14865483372deba1b52aedf65c6