Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
test: fix tables tests
Browse files Browse the repository at this point in the history
  • Loading branch information
busunkim96 committed Aug 28, 2020
1 parent df037ba commit 85dfb02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def __location_path(self, project=None, region=None):
)
region = self.region

return self.auto_ml_client.location_path(project, region)
return f"projects/{project}/locations/{region}"

# the returned metadata object doesn't allow for updating fields, so
# we need to manually copy user-updated fields over
Expand Down
14 changes: 4 additions & 10 deletions samples/tables/automl_tables_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def list_models(project_id, compute_region, filter_=None):
# filter_ = 'DATASET_DISPLAY_NAME_HERE'

from google.cloud import automl_v1beta1 as automl
from google.cloud.automl_v1beta1 import enums

client = automl.TablesClient(project=project_id, region=compute_region)

Expand All @@ -108,7 +107,7 @@ def list_models(project_id, compute_region, filter_=None):
print("List of models:")
for model in response:
# Retrieve deployment state.
if model.deployment_state == enums.Model.DeploymentState.DEPLOYED:
if model.deployment_state == automl.Model.DeploymentState.DEPLOYED:
deployment_state = "deployed"
else:
deployment_state = "undeployed"
Expand All @@ -133,9 +132,7 @@ def list_models(project_id, compute_region, filter_=None):
metadata.train_cost_milli_node_hours
)
)
print("Model create time:")
print("\tseconds: {}".format(model.create_time.seconds))
print("\tnanos: {}".format(model.create_time.nanos))
print("Model create time: {}".format(model.create_time))
print("Model deployment state: {}".format(deployment_state))
print("\n")

Expand All @@ -154,15 +151,14 @@ def get_model(project_id, compute_region, model_display_name):
# model_display_name = 'MODEL_DISPLAY_NAME_HERE'

from google.cloud import automl_v1beta1 as automl
from google.cloud.automl_v1beta1 import enums

client = automl.TablesClient(project=project_id, region=compute_region)

# Get complete detail of the model.
model = client.get_model(model_display_name=model_display_name)

# Retrieve deployment state.
if model.deployment_state == enums.Model.DeploymentState.DEPLOYED:
if model.deployment_state == automl.Model.DeploymentState.DEPLOYED:
deployment_state = "deployed"
else:
deployment_state = "undeployed"
Expand All @@ -185,9 +181,7 @@ def get_model(project_id, compute_region, model_display_name):
print("Features of top importance:")
for feat in feat_list[:feat_to_show]:
print(feat)
print("Model create time:")
print("\tseconds: {}".format(model.create_time.seconds))
print("\tnanos: {}".format(model.create_time.nanos))
print("Model create time: {}".format(model.create_time))
print("Model deployment state: {}".format(deployment_state))

# [END automl_tables_get_model]
Expand Down

0 comments on commit 85dfb02

Please sign in to comment.