Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(JAQPOT-163): update inference request structure #7

Merged
merged 4 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/entities/prediction_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@

class PredictionRequest:

def __init__(self, dataset, model, rawModel, additionalInfo=None, doaMatrix=None):
def __init__(self, dataset, model, doaMatrix=None):
self.dataset = dataset
self.model = model
self.rawModel = rawModel
self.additionalInfo = additionalInfo
self.rawModel = model.rawModel
self.additionalInfo = model.additionalInfo
self.doaMatrix = doaMatrix


class PredictionRequestPydantic(BaseModel):
dataset: Any
model: Any
additionalInfo: Any
doaMatrix: Any = None
alarv marked this conversation as resolved.
Show resolved Hide resolved
rawModel: Any
2 changes: 1 addition & 1 deletion src/handlers/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def model_post_handler(request: PredictionRequestPydantic):
model = model_decoder.decode(request.rawModel)
model = model_decoder.decode(request.model['rawModel'])
data_entry_all = json_to_predreq.decode(request)
_ = model(data_entry_all)

Expand Down
10 changes: 7 additions & 3 deletions src/helpers/json_to_predreq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
def decode(request):
dataset = request.dataset
data_entries = dataset['input']
data_entry_all = [item['values'][0] for item in data_entries]
return data_entry_all
model = request.model

keys = [feature['key'] for feature in model['independentFeatures']]
transformed_values = [[data[key] for key in keys] for data in dataset['input']]

# TODO fix to support multiple rows
return transformed_values[0]
Loading