From 7dfc88de78558c2255cc8f4580efa440753763fb Mon Sep 17 00:00:00 2001
From: Anthonios Partheniou <partheniou@google.com>
Date: Sun, 9 May 2021 21:14:02 -0400
Subject: [PATCH] chore: migrate to owl bot (#135)

---
 videointelligence/samples/analyze/noxfile.py    | 10 ++++++++--
 videointelligence/samples/labels/noxfile.py     | 10 ++++++++--
 videointelligence/samples/quickstart/noxfile.py | 10 ++++++++--
 videointelligence/samples/shotchange/noxfile.py | 10 ++++++++--
 4 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/videointelligence/samples/analyze/noxfile.py b/videointelligence/samples/analyze/noxfile.py
index 97bf7da80e39..956cdf4f9250 100644
--- a/videointelligence/samples/analyze/noxfile.py
+++ b/videointelligence/samples/analyze/noxfile.py
@@ -172,10 +172,16 @@ def blacken(session: nox.sessions.Session) -> None:
 def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
     """Runs py.test for a particular project."""
     if os.path.exists("requirements.txt"):
-        session.install("-r", "requirements.txt")
+        if os.path.exists("constraints.txt"):
+            session.install("-r", "requirements.txt", "-c", "constraints.txt")
+        else:
+            session.install("-r", "requirements.txt")
 
     if os.path.exists("requirements-test.txt"):
-        session.install("-r", "requirements-test.txt")
+        if os.path.exists("constraints-test.txt"):
+            session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
+        else:
+            session.install("-r", "requirements-test.txt")
 
     if INSTALL_LIBRARY_FROM_SOURCE:
         session.install("-e", _get_repo_root())
diff --git a/videointelligence/samples/labels/noxfile.py b/videointelligence/samples/labels/noxfile.py
index 97bf7da80e39..956cdf4f9250 100644
--- a/videointelligence/samples/labels/noxfile.py
+++ b/videointelligence/samples/labels/noxfile.py
@@ -172,10 +172,16 @@ def blacken(session: nox.sessions.Session) -> None:
 def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
     """Runs py.test for a particular project."""
     if os.path.exists("requirements.txt"):
-        session.install("-r", "requirements.txt")
+        if os.path.exists("constraints.txt"):
+            session.install("-r", "requirements.txt", "-c", "constraints.txt")
+        else:
+            session.install("-r", "requirements.txt")
 
     if os.path.exists("requirements-test.txt"):
-        session.install("-r", "requirements-test.txt")
+        if os.path.exists("constraints-test.txt"):
+            session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
+        else:
+            session.install("-r", "requirements-test.txt")
 
     if INSTALL_LIBRARY_FROM_SOURCE:
         session.install("-e", _get_repo_root())
diff --git a/videointelligence/samples/quickstart/noxfile.py b/videointelligence/samples/quickstart/noxfile.py
index 97bf7da80e39..956cdf4f9250 100644
--- a/videointelligence/samples/quickstart/noxfile.py
+++ b/videointelligence/samples/quickstart/noxfile.py
@@ -172,10 +172,16 @@ def blacken(session: nox.sessions.Session) -> None:
 def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
     """Runs py.test for a particular project."""
     if os.path.exists("requirements.txt"):
-        session.install("-r", "requirements.txt")
+        if os.path.exists("constraints.txt"):
+            session.install("-r", "requirements.txt", "-c", "constraints.txt")
+        else:
+            session.install("-r", "requirements.txt")
 
     if os.path.exists("requirements-test.txt"):
-        session.install("-r", "requirements-test.txt")
+        if os.path.exists("constraints-test.txt"):
+            session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
+        else:
+            session.install("-r", "requirements-test.txt")
 
     if INSTALL_LIBRARY_FROM_SOURCE:
         session.install("-e", _get_repo_root())
diff --git a/videointelligence/samples/shotchange/noxfile.py b/videointelligence/samples/shotchange/noxfile.py
index 97bf7da80e39..956cdf4f9250 100644
--- a/videointelligence/samples/shotchange/noxfile.py
+++ b/videointelligence/samples/shotchange/noxfile.py
@@ -172,10 +172,16 @@ def blacken(session: nox.sessions.Session) -> None:
 def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
     """Runs py.test for a particular project."""
     if os.path.exists("requirements.txt"):
-        session.install("-r", "requirements.txt")
+        if os.path.exists("constraints.txt"):
+            session.install("-r", "requirements.txt", "-c", "constraints.txt")
+        else:
+            session.install("-r", "requirements.txt")
 
     if os.path.exists("requirements-test.txt"):
-        session.install("-r", "requirements-test.txt")
+        if os.path.exists("constraints-test.txt"):
+            session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
+        else:
+            session.install("-r", "requirements-test.txt")
 
     if INSTALL_LIBRARY_FROM_SOURCE:
         session.install("-e", _get_repo_root())