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

[inferno-ml] Fix query to allow for scripts without models #156

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
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
17 changes: 13 additions & 4 deletions inferno-ml-server/src/Inferno/ML/Server/Inference.hs
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,23 @@ getInferenceParamWithModels ipid =
-- "model1": "00001-0000..."
-- }
-- ```
--
-- If a script has no model attached, a default empty JSON object is
-- returned
q :: Query
q =
[sql|
SELECT P.*, jsonb_object_agg(MS.ident, MS.model) mversions
SELECT
P.*,
coalesce
( jsonb_object_agg(MS.ident, MS.model)
FILTER (WHERE MS.ident IS NOT NULL)
, '{}'::jsonb
) mversions
FROM params P
INNER JOIN scripts S ON P.script = S.id
INNER JOIN mselections MS ON MS.script = S.id
INNER JOIN mversions MV ON MV.id = MS.model
LEFT OUTER JOIN scripts S ON P.script = S.id
LEFT OUTER JOIN mselections MS ON MS.script = S.id
LEFT OUTER JOIN mversions MV ON MV.id = MS.model
WHERE P.id = ?
AND P.terminated IS NULL
GROUP BY
Expand Down
Loading