def Create(versions_client, operations_client, version_id, model=None, origin=None, staging_bucket=None, runtime_version=None, config_file=None, asyncronous=None, labels=None, machine_type=None, description=None, framework=None, python_version=None): """Create a version, optionally waiting for creation to finish.""" if origin: try: origin = uploads.UploadDirectoryIfNecessary(origin, staging_bucket) except uploads.MissingStagingBucketException: raise InvalidArgumentCombinationError( 'If --origin is provided as a local path, --staging-bucket must be ' 'given as well.') model_ref = models_util.ParseModel(model) version = versions_client.BuildVersion(version_id, path=config_file, deployment_uri=origin, runtime_version=runtime_version, labels=labels, description=description, machine_type=machine_type, framework=framework, python_version=python_version) if not version.deploymentUri: raise InvalidArgumentCombinationError( 'Either `--origin` must be provided or `deploymentUri` must be ' 'provided in the file given by `--config`.') op = versions_client.Create(model_ref, version) return WaitForOpMaybe( operations_client, op, asyncronous=asyncronous, message='Creating version (this might take a few minutes)...')
def Create(versions_client, operations_client, version_id, model=None, origin=None, staging_bucket=None, runtime_version=None, config_file=None, asyncronous=None, labels=None, machine_type=None, description=None, framework=None, python_version=None, prediction_class=None, package_uris=None, accelerator_config=None, service_account=None, explanation_method=None, num_integral_steps=None, num_paths=None): """Create a version, optionally waiting for creation to finish.""" if origin: try: origin = uploads.UploadDirectoryIfNecessary(origin, staging_bucket) except uploads.MissingStagingBucketException: raise InvalidArgumentCombinationError( 'If --origin is provided as a local path, --staging-bucket must be ' 'given as well.') if explanation_method is not None: log.status.Print( 'Explanations reflect patterns in your model, but don\'t necessarily ' 'reveal fundamental relationships about your data population. See ' 'https://cloud.google.com/ml-engine/docs/ai-explanations/limitations ' 'for more information.') model_ref = models_util.ParseModel(model) version = versions_client.BuildVersion(version_id, path=config_file, deployment_uri=origin, runtime_version=runtime_version, labels=labels, description=description, machine_type=machine_type, framework=framework, python_version=python_version, package_uris=package_uris, prediction_class=prediction_class, accelerator_config=accelerator_config, service_account=service_account, explanation_method=explanation_method, num_integral_steps=num_integral_steps, num_paths=num_paths) if not version.deploymentUri: raise InvalidArgumentCombinationError( 'Either `--origin` must be provided or `deploymentUri` must be ' 'provided in the file given by `--config`.') op = versions_client.Create(model_ref, version) return WaitForOpMaybe( operations_client, op, asyncronous=asyncronous, message='Creating version (this might take a few minutes)...')
def Create(versions_client, operations_client, version, model=None, origin=None, staging_bucket=None, runtime_version=None, async_=None): """Create a version, optionally waiting for creation to finish.""" try: origin = uploads.UploadDirectoryIfNecessary(origin, staging_bucket) except uploads.MissingStagingBucketException: raise InvalidArgumentCombinationError( 'If --origin is provided as a local path, --staging-bucket must be ' 'given as well.') model_ref = models_util.ParseModel(model) op = versions_client.Create(model_ref, version, origin, runtime_version) return WaitForOpMaybe( operations_client, op, async_=async_, message='Creating version (this might take a few minutes)...')
def Create(versions_client, operations_client, version_id, model=None, origin=None, staging_bucket=None, runtime_version=None, config_file=None, asyncronous=None, labels=None, machine_type=None, description=None, framework=None, python_version=None, prediction_class=None, package_uris=None, accelerator_config=None, service_account=None, explanation_method=None, num_integral_steps=None, num_paths=None, image=None, command=None, container_args=None, env_vars=None, ports=None, predict_route=None, health_route=None, min_nodes=None, max_nodes=None, metrics=None, containers_hidden=True, autoscaling_hidden=True): """Create a version, optionally waiting for creation to finish.""" if origin: try: origin = uploads.UploadDirectoryIfNecessary(origin, staging_bucket) except uploads.MissingStagingBucketException: raise InvalidArgumentCombinationError( 'If --origin is provided as a local path, --staging-bucket must be ' 'given as well.') if explanation_method is not None: log.status.Print( 'Explanations reflect patterns in your model, but don\'t necessarily ' 'reveal fundamental relationships about your data population. See ' 'https://cloud.google.com/vertex-ai/docs/explainable-ai/limitations ' 'for more information.') model_ref = models_util.ParseModel(model) version = versions_client.BuildVersion( version_id, path=config_file, deployment_uri=origin, runtime_version=runtime_version, labels=labels, description=description, machine_type=machine_type, framework=framework, python_version=python_version, package_uris=package_uris, prediction_class=prediction_class, accelerator_config=accelerator_config, service_account=service_account, explanation_method=explanation_method, num_integral_steps=num_integral_steps, num_paths=num_paths, image=image, command=command, container_args=container_args, env_vars=env_vars, ports=ports, predict_route=predict_route, health_route=health_route, min_nodes=min_nodes, max_nodes=max_nodes, metrics=metrics, containers_hidden=containers_hidden, autoscaling_hidden=autoscaling_hidden) if not version.deploymentUri and containers_hidden: raise InvalidArgumentCombinationError( 'Either `--origin` must be provided or `deploymentUri` must be ' 'provided in the file given by `--config`.') has_image = ( hasattr(version, 'container') and hasattr(version.container, 'image') and version.container.image) if not version.deploymentUri and not has_image and not containers_hidden: raise InvalidArgumentCombinationError( 'Either `--origin`, `--image`, or equivalent parameters in a config ' 'file (from `--config`) must be specified.') op = versions_client.Create(model_ref, version) return WaitForOpMaybe( operations_client, op, asyncronous=asyncronous, message='Creating version (this might take a few minutes)...')