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

Apply new Standard Ensembler routing policy with Custom Experiment Engines #237

Conversation

deadlycoconuts
Copy link
Contributor

@deadlycoconuts deadlycoconuts commented Sep 9, 2022

Context

With the introduction of changes to the routing strategy of the Turing Router to support Standard Ensemblers for Custom Experiment Engines in #233, this PR introduces follow-up modifications to allow the API to set up Turing Routers that use a Standard Ensembler and a Custom Experiment Engine. The API also performs additional validation checks to ensure that any router create/update request payload does not contain both experiment_mappings and route_name_path specified in the EnsemblerStandardConfig.

Minor Fixes

This PR also includes the replacement of deprecated io/util functions from go 1.16/1.17 with their corresponding io or os counterparts:

  • ioutil.NopCloser -> io.NopCloser
  • ioutil.ReadAll -> io.ReadAll
  • ioutil.ReadFile -> os.ReadFile
  • ioutil.TempFile -> os.CreateTemp
  • ioutil.WriteFile -> os.WriteFile

Main Modifications

  • api/api/specs/routers.yaml - Addition of the route_name_path field to EnsemblerStandardConfig
  • api/turing/api/request/request.go - Addition of validation step to ensure ExperimentMappings and RouteNamePath are not both set at the same time
  • api/turing/cluster/servicebuilder/router.go - Addition of step to add route_name_path to the config map that will be used by the Turing Router upon deployment
  • api/turing/models/ensembler.go - Addition of RouteNamePath to the db model EnsemblerStandardConfig struct

Future Changes (Not included in this PR)

  • Addition of the route_name_path field to Standard Ensemblers within the Turing SDK
  • Addition of the new e2e test (api/e2e/test/09_deploy_router_with_route_name_path_std_ensembler_test.go) as a Turing SDK e2e test

@deadlycoconuts deadlycoconuts self-assigned this Sep 9, 2022
@deadlycoconuts deadlycoconuts force-pushed the apply_std_ensembler_routing_policy_with_router_deployments branch from f539d5f to 1efe78c Compare September 9, 2022 09:00
@deadlycoconuts deadlycoconuts changed the title Apply new Standard Ensembler routing policy with router deployments Apply new Standard Ensembler routing policy with Custom Experiment Engines Sep 12, 2022
Comment on lines 801 to 824
route_name_path:
type: "string"
pattern: '^\w*(?:\.\w+)*$'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex pattern here allows only period-delimited words of letters (or underscores) to be accepted as a valid route_name_path. Specifying this here also dispenses the need for manually crafting regex checks on the API for this field.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh what if the nested path actually has a key with "-" in it? Shall we remove this check and keep it flexible like the TrafficRuleCondition ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm if it's just dashes we can make it ^[\w\-]*(?:\.[\w\-]+)*$ instead? Are you referring to field within TrafficRuleCondition? That one doesn't have any checks right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay as discussed earlier, I'll be removing the regex changes to allow users more flexibility (at their own discretion) at specifying the route path names. Any resultant errors from any incorrect parsing of the path would be returned by the router itself.

Comment on lines 57 to 84
"image": "asia.gcr.io/gcp-project-id/echo:1.0.2",
"resource_request": {
"min_replica": 1,
"max_replica": 2,
"cpu_request": "200m",
"memory_request": "256Mi"
},
"endpoint": "echo?delay=10ms",
"timeout": "2s",
"port": 8080,
"env": [
{
"name": "TEST_ENV",
"value": "ensembler"
}
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the schema to reflect the current schema of an ensembler. The previous schema was incorrect but it didn't break anything because another (earlier) section of the router config was causing the test to fail as expected.

@deadlycoconuts deadlycoconuts requested a review from a team September 12, 2022 06:11
@deadlycoconuts deadlycoconuts marked this pull request as ready for review September 12, 2022 06:11
testEnsembler models.Ensembler
err string
}{
"failure | both experiment mappings and route name path are set": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a positive to test case to ensure it is passing when expected to be?

@deadlycoconuts deadlycoconuts marked this pull request as draft September 12, 2022 10:04
@deadlycoconuts deadlycoconuts force-pushed the apply_std_ensembler_routing_policy_with_router_deployments branch 6 times, most recently from 755d8f1 to 7f1c050 Compare September 13, 2022 06:22
@deadlycoconuts deadlycoconuts marked this pull request as ready for review September 13, 2022 07:54
@deadlycoconuts deadlycoconuts force-pushed the apply_std_ensembler_routing_policy_with_router_deployments branch from 06355c0 to 12b24e1 Compare September 13, 2022 10:15
Copy link
Collaborator

@krithika369 krithika369 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the whole, the PR looks good! Thanks for meticulously updating all the test scenarios too. I left some small comments. Will have another quick look once they are reviewed / addressed.

api/api/specs/routers.yaml Outdated Show resolved Hide resolved
api/turing/api/request/request.go Outdated Show resolved Hide resolved
api/turing/models/ensembler.go Show resolved Hide resolved
@deadlycoconuts deadlycoconuts force-pushed the apply_std_ensembler_routing_policy_with_router_deployments branch 7 times, most recently from c4668b8 to 9ef2e8b Compare September 16, 2022 04:17
Comment on lines +494 to +500
if ver.Ensembler.StandardConfig.ExperimentMappings != nil &&
len(ver.Ensembler.StandardConfig.ExperimentMappings) != 0 {
propsMap["experiment_mappings"] = ver.Ensembler.StandardConfig.ExperimentMappings
}
if ver.Ensembler.StandardConfig.RouteNamePath != "" {
propsMap["route_name_path"] = ver.Ensembler.StandardConfig.RouteNamePath
}
Copy link
Contributor Author

@deadlycoconuts deadlycoconuts Sep 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These conditional statements ensure that only non-nil/non-empty values are passed to the fiber config.

Copy link
Collaborator

@krithika369 krithika369 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the changes.

Since we haven't yet added the route_name_path to the SDK, can we do that in a separate PR? https://github.com/caraml-dev/turing/blob/main/sdk/turing/router/config/router_ensembler_config.py#L35

api/turing/validation/validator.go Show resolved Hide resolved
@deadlycoconuts deadlycoconuts force-pushed the apply_std_ensembler_routing_policy_with_router_deployments branch from d397131 to c0c66db Compare September 19, 2022 00:59
@deadlycoconuts
Copy link
Contributor Author

Thanks a lot for reviewing the PR and for all the comments! I'll be merging this right now and will be following up with a separate PR for the SDK-related changes and e2e tests! 🚀🚀

@deadlycoconuts deadlycoconuts merged commit 9aedab8 into caraml-dev:main Sep 19, 2022
@deadlycoconuts deadlycoconuts deleted the apply_std_ensembler_routing_policy_with_router_deployments branch September 19, 2022 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants