Unverified Commit 942a0fb9 authored by hhzhang16's avatar hhzhang16 Committed by GitHub
Browse files

feat: allow users to add env vars to dynamo deployment (#862)


Signed-off-by: default avatarhhzhang16 <54051230+hhzhang16@users.noreply.github.com>
Co-authored-by: default avatarmohammedabdulwahhab <furkhan324@berkeley.edu>
parent 0756702a
...@@ -77,6 +77,7 @@ def create_deployment( ...@@ -77,6 +77,7 @@ def create_deployment(
timeout: int = 3600, timeout: int = 3600,
dev: bool = False, dev: bool = False,
args: Optional[List[str]] = None, args: Optional[List[str]] = None,
envs: Optional[List[str]] = None,
_cloud_client: BentoCloudClient = Provide[BentoMLContainer.bentocloud_client], _cloud_client: BentoCloudClient = Provide[BentoMLContainer.bentocloud_client],
) -> Deployment: ) -> Deployment:
# Load config from file and serialize to env # Load config from file and serialize to env
...@@ -87,6 +88,14 @@ def create_deployment( ...@@ -87,6 +88,14 @@ def create_deployment(
logger.info(f"Deployment service configuration: {config_json}") logger.info(f"Deployment service configuration: {config_json}")
env_dicts.append({"name": "DYN_DEPLOYMENT_CONFIG", "value": config_json}) env_dicts.append({"name": "DYN_DEPLOYMENT_CONFIG", "value": config_json})
# Add user-supplied envs
if envs:
for env in envs:
if "=" not in env:
raise CLIException(f"Invalid env format: {env}. Use KEY=VALUE.")
key, value = env.split("=", 1)
env_dicts.append({"name": key, "value": value})
config_params = DeploymentConfigParameters( config_params = DeploymentConfigParameters(
name=name, name=name,
bento=pipeline, bento=pipeline,
...@@ -296,6 +305,11 @@ def create( ...@@ -296,6 +305,11 @@ def create(
endpoint: str = typer.Option( endpoint: str = typer.Option(
..., "--endpoint", "-e", help="Dynamo Cloud endpoint", envvar="DYNAMO_CLOUD" ..., "--endpoint", "-e", help="Dynamo Cloud endpoint", envvar="DYNAMO_CLOUD"
), ),
envs: Optional[List[str]] = typer.Option(
None,
"--env",
help="Environment variable(s) to set (format: KEY=VALUE). Note: These environment variables will be set on ALL services in your Dynamo pipeline.",
),
) -> None: ) -> None:
"""Create a deployment on Dynamo Cloud. """Create a deployment on Dynamo Cloud.
...@@ -309,6 +323,7 @@ def create( ...@@ -309,6 +323,7 @@ def create(
wait=wait, wait=wait,
timeout=timeout, timeout=timeout,
args=ctx.args if hasattr(ctx, "args") else None, args=ctx.args if hasattr(ctx, "args") else None,
envs=envs,
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment