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

Add env vars support to Pyfunc ensembler #181

Merged

Conversation

deadlycoconuts
Copy link
Contributor

@deadlycoconuts deadlycoconuts commented Mar 15, 2022

In PR #164, PR #165, PR #170, PR #171, and PR #174 an automated pyfunc ensembler building feature was introduced for Turing. However, the existing implementation lacked support for passing environment variables specified by the user to the running pyfunc ensembler service in its container.

This PR introduces support for the aforementioned feature, by adding an extra env field to the EnsemblerPyfuncConfig/pyfuncConfig/pyfunc_config struct/model/schema used in Turing API/UI/SDK. Turing API/UI/SDK has also been correspondingly updated to allow users to specify the new field when deploying/viewing routers with pyfunc ensemblers.

Additions

  • api/api* - Changes to the OpenAPI specs from the addition of the new env field
  • api/turing/models/ensembler.go - Addition of the new env field to EnsemblerPyfuncConfig
  • api/turing/service/router_deployment_service.go - Slight changes to the buildEnsemblerServiceImage to store env as part of an EnsemblerDockerConfig
  • ui/src/router/components/configuration/components/pyfunc_config_section/PyFuncConfigViewGroup.js - Addition of a new field to display environment variables in the configuration details panel
  • ui/src/router/components/form/components/pyfunc_config/PyFuncConfigFormGroup.js - Addition of a new field for users to input environment variables when configuring Pyfunc ensemblers as part of a router deployment
  • ui/src/services/ensembler/PyFuncEnsembler.js - Addition of the new env field to PyFuncEnsembler
  • sdk/turing/generated/model/ensembler_pyfunc_config.py - Changes to the OpenAPI autogenerated class corresponding to the pyfunc ensembler configuration
  • sdk/turing/router/config/router_ensembler_config.py - Addition of the new env field to pyfunc_config

@deadlycoconuts deadlycoconuts requested a review from a team March 15, 2022 08:47
@deadlycoconuts deadlycoconuts self-assigned this Mar 15, 2022
@deadlycoconuts deadlycoconuts force-pushed the add_env_vars_pyfunc_ensembler branch 5 times, most recently from c442fa9 to bf34ecb Compare March 22, 2022 10:39
@deadlycoconuts deadlycoconuts force-pushed the add_env_vars_pyfunc_ensembler branch from bf34ecb to 1215fe3 Compare March 22, 2022 10:48
@deadlycoconuts deadlycoconuts marked this pull request as ready for review March 22, 2022 10:49
-- Migrate pyfunc_config data from old schema to new schema (with new 'env' field set as an empty array by default)
UPDATE ensembler_configs
SET pyfunc_config = (SELECT json_build_object(
'env', '[]'::jsonb,
Copy link
Contributor Author

@deadlycoconuts deadlycoconuts Mar 23, 2022

Choose a reason for hiding this comment

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

Not sure if this is really necessary since the only pyfunc ensemblers that have been created without this field are the ones in dev, but for consistency's sake I thought having a migration script for this would make things neater. Alternatively, we could consider implementing some lazy migration of the saved pyfunc ensemblers in the API?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I feel it's better to not have this in the migration, just to keep the migration history lean.

This feature is still under development. :) We don't really need to worry since we haven't cut any release with migration file # 10 (and as a consequence, we also haven't released this feature to our internal users, as you've noted). We can run this data migration manually on the internal dev DB.

@@ -2,7 +2,7 @@ import React, { useContext } from "react";
import { EuiDescriptionList } from "@elastic/eui";
import EnsemblersContext from "../../../../../providers/ensemblers/context";

export const PyFuncRefConfigTable = ({ config: { ensembler_id } }) => {
export const PyFuncConfigTable = ({ config: { ensembler_id } }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this for consistency

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! 🚀

@@ -0,0 +1,9 @@
-- Migrate pyfunc_config data from new schema to old schema (remove the env column)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tip: this can be simplified using the - operator like: https://stackoverflow.com/a/35283553

-- Migrate pyfunc_config data from old schema to new schema (with new 'env' field set as an empty array by default)
UPDATE ensembler_configs
SET pyfunc_config = (SELECT json_build_object(
'env', '[]'::jsonb,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I feel it's better to not have this in the migration, just to keep the migration history lean.

This feature is still under development. :) We don't really need to worry since we haven't cut any release with migration file # 10 (and as a consequence, we also haven't released this feature to our internal users, as you've noted). We can run this data migration manually on the internal dev DB.

@deadlycoconuts
Copy link
Contributor Author

Thanks for the comments @krithika369 ! FYI, I'm also going to bring in the tiny little refactoring commit from the SDK minor release into this PR :) I'll be merging this if the pipeline passes 🚀

@deadlycoconuts deadlycoconuts merged commit 0763ebb into caraml-dev:main Mar 23, 2022
@deadlycoconuts deadlycoconuts deleted the add_env_vars_pyfunc_ensembler branch March 24, 2022 04:14
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.

2 participants