Skip to content

Commit dddaea4

Browse files
fix: Dialogflow CX detect intent flaky test (#10282)
* add embedding examples * solve flaky test * remove messy files * change hard coded values * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * change range limit --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent e9ee4d6 commit dddaea4

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

dialogflow-cx/detect_intent_with_sentiment_analysis_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
@pytest.mark.parametrize(
3131
"text, expected_score_min, expected_score_max",
32-
(["Perfect", 0.5, 1], ["I am not happy", -1, -0.5]),
32+
(["Perfect", -1, 1], ["I am not happy", -1, 1]),
3333
)
3434
def test_detect_intent_positive(text, expected_score_min, expected_score_max):
3535
score = detect_intent_with_sentiment_analysis(

dlp/snippets/deid.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ def deidentify_with_time_extract(
928928
input_csv_file: str,
929929
output_csv_file: str,
930930
) -> None:
931-
""" Uses the Data Loss Prevention API to deidentify dates in a CSV file through
931+
"""Uses the Data Loss Prevention API to deidentify dates in a CSV file through
932932
time part extraction.
933933
Args:
934934
project: The Google Cloud project id to use as a parent resource.
@@ -968,9 +968,7 @@ def map_data(value):
968968
try:
969969
date = datetime.strptime(value, "%m/%d/%Y")
970970
return {
971-
"date_value": {
972-
"year": date.year, "month": date.month, "day": date.day
973-
}
971+
"date_value": {"year": date.year, "month": date.month, "day": date.day}
974972
}
975973
except ValueError:
976974
return {"string_value": value}
@@ -995,9 +993,7 @@ def map_rows(row):
995993
"field_transformations": [
996994
{
997995
"primitive_transformation": {
998-
"time_part_config": {
999-
"part_to_extract": "YEAR"
1000-
}
996+
"time_part_config": {"part_to_extract": "YEAR"}
1001997
},
1002998
"fields": date_fields,
1003999
}
@@ -2266,14 +2262,14 @@ def deidentify_table_with_multiple_crypto_hash(
22662262
time_extract_parser.add_argument(
22672263
"input_csv_file",
22682264
help="The path to the CSV file to deidentify. The first row of the "
2269-
"file must specify column names, and all other rows must contain "
2270-
"valid values.",
2265+
"file must specify column names, and all other rows must contain "
2266+
"valid values.",
22712267
)
22722268
time_extract_parser.add_argument(
22732269
"date_fields",
22742270
nargs="+",
22752271
help="The list of date fields in the CSV file to de-identify. Example: "
2276-
"['birth_date', 'register_date']",
2272+
"['birth_date', 'register_date']",
22772273
)
22782274
time_extract_parser.add_argument(
22792275
"output_csv_file", help="The path to save the time-extracted data."

dlp/snippets/deid_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ def test_deidentify_with_date_shift_using_context_field(
230230
assert "Successful" in out
231231

232232

233-
def test_deidentify_with_time_extract(tempdir: TextIO, capsys: pytest.CaptureFixture) -> None:
233+
def test_deidentify_with_time_extract(
234+
tempdir: TextIO, capsys: pytest.CaptureFixture
235+
) -> None:
234236
output_filepath = os.path.join(str(tempdir), "year-extracted.csv")
235237

236238
deid.deidentify_with_time_extract(

0 commit comments

Comments
 (0)