-
Notifications
You must be signed in to change notification settings - Fork 23
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
fix(ui): Fix incorrect steps to remove ensembler fields #382
fix(ui): Fix incorrect steps to remove ensembler fields #382
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #382 +/- ##
==========================================
- Coverage 68.07% 62.27% -5.80%
==========================================
Files 149 124 -25
Lines 11809 9774 -2035
==========================================
- Hits 8039 6087 -1952
+ Misses 3032 2949 -83
Partials 738 738
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
4cef9be
to
3565471
Compare
if (obj.config.ensembler.resource_request?.cpu_limit === "") { | ||
delete obj.config.ensembler.resource_request.cpu_limit; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire check was ineffective and was doing nothing since it was checking a field that doesn't exist - obj.config.ensembler.resource_request
does not exist. The intended path should've been obj.config.ensembler.docker_config.resource_request
or obj.config.ensembler.pyfunc_config.resource_request
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The delete is done is ensembler.is instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's right, because toJSON
in Ensembler.js
gets called after the entire return value of toJSON
in TuringRouter.js
gets returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
Context
Certain fields in a router's ensembler config need to be removed manually before being stringified into a JSON object that will be sent to the Turing API server as the payload in various HTTP calls (e.g. update router, create new router version, etc.):
ensembler
(the entire ensembler config)ensembler.standard_config.fallback_response_route_id
ensembler.docker_config
ensembler.docker_config.resource_request.cpu_limit
/ensembler.pyfunc_config.resource_request.cpu_limit
This was previously handled in the
toJson
method of the aTuringRouter
object which gets called whenJSON.stringify
gets called on theTuringRouter
object. However, in reality, this did not remove any of the ensembler configs listed above.When
JSON.stringify
gets called on an object (TuringRouter
) that has nested objects which also have their owntoJson
methods implemented (Ensembler
),JSON.stringify
actually callstoJSON
recursively from the original object all the way down to their nested objects. However, because we actually perform a deep copy of theTuringRouter
object intoJSON
, we actually also copy a boundedtoJSON
belonging to its ensembler. As such, even when we try to delete fields in the deep copied router's ensembler, nothing happens because the boundedtoJSON
gets called, and returns all fields as part of the original ensembler.For example, given an instance of the class
Parent
:As such, this is some conflicting behaviour as a result of us performing both the deep-cloning AND the binding of
toJSON
, which (unexpectedly or not) caused the boundedtoJSON
function to be cloned and used. Of course we can either: 1) not clone the boundedtoJSON
function, but this is hard since we're using a deep cloning library, and if we don't clonetoJSON
, we still need to replicate the logic contained within it, or 2) don't bindtoJSON
but I don't know what the original intent of the binding is for, and removing it might break other stuff unexpectedly.As such, I'll simply move all the ensembler-related deletion logic into the
toJSON
method of the ensembler to ensure that all the necessary fields get removed properly, without having to deal with either the cloning library or the binding.