diff --git a/truss/cli/cli.py b/truss/cli/cli.py index fa38acee5..69cf18618 100644 --- a/truss/cli/cli.py +++ b/truss/cli/cli.py @@ -548,8 +548,9 @@ def push( model_name = remote_cli.inquire_model_name() if promote and environment: - promote_warning = "'promote' flag and 'environment' flag were both specified. Ignoring the value of 'promote'" - console.print(promote_warning, style="yellow") + raise click.UsageError( + "'promote' flag and 'environment' flag cannot both be specified." + ) if promote and not environment: environment = PRODUCTION_ENVIRONMENT_NAME diff --git a/truss/remote/baseten/api.py b/truss/remote/baseten/api.py index 7af664d81..8f1f227ef 100644 --- a/truss/remote/baseten/api.py +++ b/truss/remote/baseten/api.py @@ -199,6 +199,7 @@ def create_model_from_truss( allow_truss_download: bool = True, deployment_name: Optional[str] = None, origin: Optional[b10_types.ModelOrigin] = None, + environment: Optional[str] = None, ): query_string = f""" mutation ($trussUserEnv: String) {{ @@ -211,6 +212,7 @@ def create_model_from_truss( allow_truss_download: {"true" if allow_truss_download else "false"} {f'version_name: "{deployment_name}"' if deployment_name else ""} {f"model_origin: {origin.value}" if origin else ""} + {f'environment_name: "{environment}"' if environment else ""} ) {{ model_version {{ id diff --git a/truss/remote/baseten/core.py b/truss/remote/baseten/core.py index 85dbe7a91..dc148240e 100644 --- a/truss/remote/baseten/core.py +++ b/truss/remote/baseten/core.py @@ -438,9 +438,6 @@ def create_truss_service( ) if model_id is None: - if environment and environment != PRODUCTION_ENVIRONMENT_NAME: - raise ValueError(NO_ENVIRONMENTS_EXIST_ERROR_MESSAGING) - model_version_json = api.create_model_from_truss( model_name, s3_key, @@ -450,6 +447,7 @@ def create_truss_service( allow_truss_download=allow_truss_download, deployment_name=deployment_name, origin=origin, + environment=environment, ) return ModelVersionHandle(