Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6bccf93
automl: add base samples
nnegrey Dec 12, 2019
9356684
automl: add base set of samples
nnegrey Dec 13, 2019
a69e033
Merge branch 'master' into automl-ga-base-samples
nnegrey Dec 18, 2019
f527a46
Clean up tests
nnegrey Dec 20, 2019
c2232a1
License year 2020, drop python2 print statement unicode
nnegrey Jan 2, 2020
fe68bc4
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 2, 2020
6b5401c
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 2, 2020
4976068
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 7, 2020
7cfad55
use centralized automl testing project
nnegrey Jan 7, 2020
ce95040
Fix GCS path typo
nnegrey Jan 7, 2020
2cd710a
Use fake dataset for batch predict
nnegrey Jan 7, 2020
9594c94
lint: line length
nnegrey Jan 7, 2020
418a04e
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 9, 2020
b3bdcc5
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 9, 2020
88ebd78
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 9, 2020
58a8128
fix fixture naming and use
nnegrey Jan 9, 2020
4420851
Merge branch 'master' into automl-ga-base-samples
leahecole Jan 14, 2020
d330ba2
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 15, 2020
e5ffd29
Fix fixture changes
nnegrey Jan 21, 2020
12b5c4e
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 21, 2020
83d1a4b
Catch resource exhausted error
nnegrey Jan 21, 2020
9526879
Merge branch 'automl-ga-base-samples' of https://github.com/GoogleClo…
nnegrey Jan 21, 2020
5d40849
use fake data for import test
nnegrey Jan 22, 2020
f4f0734
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 22, 2020
17689b1
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 27, 2020
ccb5792
update how to access an operation id
nnegrey Jan 28, 2020
fe00a35
Merge branch 'master' into automl-ga-base-samples
nnegrey Jan 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix fixture naming and use
  • Loading branch information
nnegrey committed Jan 9, 2020
commit 58a8128200475c72fa6c08069fc93a41d76c2061
6 changes: 3 additions & 3 deletions automl/cloud-client/delete_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


@pytest.fixture(scope="function")
def create_dataset():
def dataset_id():
client = automl.AutoMlClient()
project_location = client.location_path(PROJECT_ID, "us-central1")
display_name = "test_" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
Expand All @@ -39,8 +39,8 @@ def create_dataset():
yield dataset_id


def test_delete_dataset(capsys, create_dataset):
def test_delete_dataset(capsys, dataset_id):
# delete dataset
delete_dataset.delete_dataset(PROJECT_ID, create_dataset)
delete_dataset.delete_dataset(PROJECT_ID, dataset_id)
out, _ = capsys.readouterr()
assert "Dataset deleted." in out
6 changes: 3 additions & 3 deletions automl/cloud-client/get_model_evaluation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


@pytest.fixture(scope="function")
def get_evaluation_id():
def model_evaluation_id():
client = automl.AutoMlClient()
model_full_id = client.model_path(PROJECT_ID, "us-central1", MODEL_ID)
evaluation = None
Expand All @@ -37,9 +37,9 @@ def get_evaluation_id():
yield model_evaluation_id


def test_get_model_evaluation(capsys, get_evaluation_id):
def test_get_model_evaluation(capsys, model_evaluation_id):
get_model_evaluation.get_model_evaluation(
PROJECT_ID, MODEL_ID, get_evaluation_id
PROJECT_ID, MODEL_ID, model_evaluation_id
)
out, _ = capsys.readouterr()
assert "Model evaluation name: " in out
6 changes: 3 additions & 3 deletions automl/cloud-client/get_operation_status_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


@pytest.fixture(scope="function")
def get_operation_id():
def operation_id():
client = automl.AutoMlClient()
project_location = client.location_path(PROJECT_ID, "us-central1")
response = client.transport._operations_client.list_operations(
Expand All @@ -36,7 +36,7 @@ def get_operation_id():
yield operation_id


def test_get_operation_status(capsys, get_operation_id):
get_operation_status.get_operation_status(get_operation_id)
def test_get_operation_status(capsys, operation_id):
get_operation_status.get_operation_status(operation_id)
out, _ = capsys.readouterr()
assert "Operation details" in out
10 changes: 5 additions & 5 deletions automl/cloud-client/import_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


@pytest.fixture(scope="function")
def create_dataset():
def dataset_id():
client = automl.AutoMlClient()
project_location = client.location_path(PROJECT_ID, "us-central1")
display_name = "test_" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
Expand All @@ -42,19 +42,19 @@ def create_dataset():


@pytest.mark.slow
def test_import_dataset(capsys, create_dataset):
def test_import_dataset(capsys, dataset_id):
data = (
"gs://{}/sentiment-analysis/dataset.csv".format(BUCKET_ID)
)
dataset_id = create_dataset
import_dataset.import_dataset(PROJECT_ID, dataset_id, data)
created_dataset_id = dataset_id
import_dataset.import_dataset(PROJECT_ID, created_dataset_id, data)
out, _ = capsys.readouterr()
assert "Data imported." in out

# delete created dataset
client = automl.AutoMlClient()
dataset_full_id = client.dataset_path(
PROJECT_ID, "us-central1", dataset_id
PROJECT_ID, "us-central1", created_dataset_id
)
response = client.delete_dataset(dataset_full_id)
response.result()
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
MODEL_ID = os.environ["SENTIMENT_ANALYSIS_MODEL_ID"]


@pytest.fixture(scope="function")
def verify_model_state():
@pytest.fixture(scope="function", autouse=True)
def setup():
# Verify the model is deployed before trying to predict
client = automl.AutoMlClient()
model_full_id = client.model_path(PROJECT_ID, "us-central1", MODEL_ID)

Expand All @@ -35,8 +36,7 @@ def verify_model_state():
response.result()


def test_predict(capsys, verify_model_state):
verify_model_state
def test_predict(capsys):
text = "Hopefully this Claritin kicks in soon"
language_sentiment_analysis_predict.predict(PROJECT_ID, MODEL_ID, text)
out, _ = capsys.readouterr()
Expand Down
8 changes: 4 additions & 4 deletions automl/cloud-client/translate_predict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
MODEL_ID = os.environ["TRANSLATION_MODEL_ID"]


@pytest.fixture(scope="function")
def verify_model_state():
@pytest.fixture(scope="function", autouse=True)
def setup():
# Verify the model is deployed before trying to predict
client = automl.AutoMlClient()
model_full_id = client.model_path(PROJECT_ID, "us-central1", MODEL_ID)

Expand All @@ -35,8 +36,7 @@ def verify_model_state():
response.result()


def test_predict(capsys, verify_model_state):
verify_model_state
def test_predict(capsys):
translate_predict.predict(PROJECT_ID, MODEL_ID, "resources/input.txt")
out, _ = capsys.readouterr()
assert "Translated content: " in out
8 changes: 4 additions & 4 deletions automl/cloud-client/vision_classification_predict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
MODEL_ID = os.environ["VISION_CLASSIFICATION_MODEL_ID"]


@pytest.fixture(scope="function")
def verify_model_state():
@pytest.fixture(scope="function", autouse=True)
def setup():
# Verify the model is deployed before tyring to predict
client = automl.AutoMlClient()
model_full_id = client.model_path(PROJECT_ID, "us-central1", MODEL_ID)

Expand All @@ -35,8 +36,7 @@ def verify_model_state():
response.result()


def test_vision_classification_predict(capsys, verify_model_state):
verify_model_state
def test_vision_classification_predict(capsys):
file_path = "resources/test.png"
vision_classification_predict.predict(PROJECT_ID, MODEL_ID, file_path)
out, _ = capsys.readouterr()
Expand Down