Skip to content

Commit 7022b06

Browse files
telpirionleahecole
authored andcommitted
samples: updates face recognition to v1 (#127)
1 parent 136526a commit 7022b06

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed

videointelligence/samples/analyze/noxfile.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,25 @@
3838

3939
TEST_CONFIG = {
4040
# You can opt out from the test for specific Python versions.
41-
'ignored_versions': ["2.7"],
42-
41+
"ignored_versions": ["2.7"],
4342
# Old samples are opted out of enforcing Python type hints
4443
# All new samples should feature them
45-
'enforce_type_hints': False,
46-
44+
"enforce_type_hints": False,
4745
# An envvar key for determining the project id to use. Change it
4846
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
4947
# build specific Cloud project. You can also use your own string
5048
# to use your own Cloud project.
51-
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
49+
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
5250
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
53-
5451
# A dictionary you want to inject into your test. Don't put any
5552
# secrets here. These values will override predefined values.
56-
'envs': {},
53+
"envs": {},
5754
}
5855

5956

6057
try:
6158
# Ensure we can import noxfile_config in the project's directory.
62-
sys.path.append('.')
59+
sys.path.append(".")
6360
from noxfile_config import TEST_CONFIG_OVERRIDE
6461
except ImportError as e:
6562
print("No user noxfile_config found: detail: {}".format(e))
@@ -74,12 +71,12 @@ def get_pytest_env_vars() -> Dict[str, str]:
7471
ret = {}
7572

7673
# Override the GCLOUD_PROJECT and the alias.
77-
env_key = TEST_CONFIG['gcloud_project_env']
74+
env_key = TEST_CONFIG["gcloud_project_env"]
7875
# This should error out if not set.
79-
ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]
76+
ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key]
8077

8178
# Apply user supplied envs.
82-
ret.update(TEST_CONFIG['envs'])
79+
ret.update(TEST_CONFIG["envs"])
8380
return ret
8481

8582

@@ -88,7 +85,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
8885
ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"]
8986

9087
# Any default versions that should be ignored.
91-
IGNORED_VERSIONS = TEST_CONFIG['ignored_versions']
88+
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
9289

9390
TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])
9491

@@ -137,7 +134,7 @@ def _determine_local_import_names(start_dir: str) -> List[str]:
137134

138135
@nox.session
139136
def lint(session: nox.sessions.Session) -> None:
140-
if not TEST_CONFIG['enforce_type_hints']:
137+
if not TEST_CONFIG["enforce_type_hints"]:
141138
session.install("flake8", "flake8-import-order")
142139
else:
143140
session.install("flake8", "flake8-import-order", "flake8-annotations")
@@ -146,9 +143,11 @@ def lint(session: nox.sessions.Session) -> None:
146143
args = FLAKE8_COMMON_ARGS + [
147144
"--application-import-names",
148145
",".join(local_names),
149-
"."
146+
".",
150147
]
151148
session.run("flake8", *args)
149+
150+
152151
#
153152
# Black
154153
#
@@ -161,6 +160,7 @@ def blacken(session: nox.sessions.Session) -> None:
161160

162161
session.run("black", *python_files)
163162

163+
164164
#
165165
# Sample Tests
166166
#
@@ -169,7 +169,9 @@ def blacken(session: nox.sessions.Session) -> None:
169169
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
170170

171171

172-
def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
172+
def _session_tests(
173+
session: nox.sessions.Session, post_install: Callable = None
174+
) -> None:
173175
"""Runs py.test for a particular project."""
174176
if os.path.exists("requirements.txt"):
175177
session.install("-r", "requirements.txt")
@@ -200,9 +202,9 @@ def py(session: nox.sessions.Session) -> None:
200202
if session.python in TESTED_VERSIONS:
201203
_session_tests(session)
202204
else:
203-
session.skip("SKIPPED: {} tests are disabled for this sample.".format(
204-
session.python
205-
))
205+
session.skip(
206+
"SKIPPED: {} tests are disabled for this sample.".format(session.python)
207+
)
206208

207209

208210
#
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
google-cloud-videointelligence==2.0.0
1+
google-cloud-videointelligence==2.1.0
22
google-cloud-storage==1.37.0

videointelligence/samples/analyze/video_detect_faces_beta.py renamed to videointelligence/samples/analyze/video_detect_faces.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020 Google LLC
1+
# Copyright 2021 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,10 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# [START video_detect_faces_beta]
15+
# [START video_detect_faces]
1616
import io
1717

18-
from google.cloud import videointelligence_v1p3beta1 as videointelligence
18+
from google.cloud import videointelligence_v1 as videointelligence
1919

2020

2121
def detect_faces(local_file_path="path/to/your/video-file.mp4"):
@@ -82,4 +82,4 @@ def detect_faces(local_file_path="path/to/your/video-file.mp4"):
8282
)
8383

8484

85-
# [END video_detect_faces_beta]
85+
# [END video_detect_faces]

videointelligence/samples/analyze/video_detect_faces_gcs_beta.py renamed to videointelligence/samples/analyze/video_detect_faces_gcs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# [START video_detect_faces_gcs_beta]
16-
from google.cloud import videointelligence_v1p3beta1 as videointelligence
15+
# [START video_detect_faces_gcs]
16+
from google.cloud import videointelligence_v1 as videointelligence
1717

1818

1919
def detect_faces(gcs_uri="gs://YOUR_BUCKET_ID/path/to/your/video.mp4"):
@@ -77,4 +77,4 @@ def detect_faces(gcs_uri="gs://YOUR_BUCKET_ID/path/to/your/video.mp4"):
7777
)
7878

7979

80-
# [END video_detect_faces_gcs_beta]
80+
# [END video_detect_faces_gcs]

videointelligence/samples/analyze/video_detect_faces_gcs_beta_test.py renamed to videointelligence/samples/analyze/video_detect_faces_gcs_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import pytest
1818

19-
import video_detect_faces_gcs_beta
19+
import video_detect_faces_gcs
2020

2121
RESOURCES = os.path.join(os.path.dirname(__file__), "resources")
2222

@@ -25,7 +25,7 @@
2525
def test_detect_faces(capsys):
2626
input_uri = "gs://cloud-samples-data/video/googlework_short.mp4"
2727

28-
video_detect_faces_gcs_beta.detect_faces(gcs_uri=input_uri)
28+
video_detect_faces_gcs.detect_faces(gcs_uri=input_uri)
2929

3030
out, _ = capsys.readouterr()
3131

videointelligence/samples/analyze/video_detect_faces_beta_test.py renamed to videointelligence/samples/analyze/video_detect_faces_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import pytest
1818

19-
import video_detect_faces_beta
19+
import video_detect_faces
2020

2121
RESOURCES = os.path.join(os.path.dirname(__file__), "resources")
2222

@@ -25,7 +25,7 @@
2525
def test_detect_faces(capsys):
2626
local_file_path = os.path.join(RESOURCES, "googlework_short.mp4")
2727

28-
video_detect_faces_beta.detect_faces(local_file_path=local_file_path)
28+
video_detect_faces.detect_faces(local_file_path=local_file_path)
2929

3030
out, _ = capsys.readouterr()
3131

0 commit comments

Comments
 (0)