Skip to content

Commit 4fd7f27

Browse files
junjiang-labcopybara-github
authored andcommitted
Internal clean up.
PiperOrigin-RevId: 916121032
1 parent 45e3ef5 commit 4fd7f27

5 files changed

Lines changed: 7 additions & 21 deletions

File tree

litert_cli/commands/run/desktop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ def run_desktop(
275275
with ctx:
276276
try:
277277
env = None
278-
if constants.IN_GOOGLE3:
279-
# In Google3 environment, we need to fallback to LD_LIBRARY_PATH for
278+
if constants.IS_INTERNAL_ENV:
279+
# In internal environment, we need to fallback to LD_LIBRARY_PATH for
280280
# loading GPU accelerators in hermetic .par file. Otherwise, use
281281
# default path.
282282
env = Environment.create(runtime_path="")

litert_cli/core/constants.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,12 @@
2020
import os
2121
import types
2222

23-
# Check if we are in Google3 environment
24-
try:
25-
import google3 # pylint: disable=unused-import,g-import-not-at-top
26-
27-
_AUTO_IN_GOOGLE3 = True
28-
except ImportError:
29-
_AUTO_IN_GOOGLE3 = False
23+
# Flag to indicate if the CLI is running in internal environment
24+
IS_INTERNAL_ENV: bool = False
3025

3126
# Environment variable names
3227
ENV_LITERT_CLI_ROOT: str = "LITERT_CLI_ROOT"
3328
ENV_LITERT_CLI_ANDROID_ROOT: str = "LITERT_CLI_ANDROID_ROOT"
34-
ENV_LITERT_CLI_FORCE_OSS: str = "LITERT_CLI_FORCE_OSS"
3529
ENV_LITERT_VERBOSE: str = "LITERT_VERBOSE"
3630
ENV_LITERT_ENABLE_MODEL_PLUGINS: str = "LITERT_ENABLE_MODEL_PLUGINS"
3731

@@ -40,14 +34,6 @@
4034
os.environ.get(ENV_LITERT_ENABLE_MODEL_PLUGINS, "0") == "1"
4135
)
4236

43-
_FORCE_OSS = os.environ.get(ENV_LITERT_CLI_FORCE_OSS, "").lower() in (
44-
"1",
45-
"true",
46-
"yes",
47-
)
48-
49-
IN_GOOGLE3: bool = _AUTO_IN_GOOGLE3 and not _FORCE_OSS
50-
5137
# Cache directory
5238
LITERT_CLI_CACHE_DIR: str = os.path.join(
5339
os.path.expanduser("~"), ".cache", "litert-cli"

litert_cli/core/deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def ensure_extra(extra_name: str, *, silent: bool = False) -> bool:
7070
click.Abort: If `silent` is False and the dependency cannot be ensured
7171
(e.g., unknown extra or installation failure).
7272
"""
73-
if constants.IN_GOOGLE3:
73+
if constants.IS_INTERNAL_ENV:
7474
return True
7575

7676
packages_to_check = _PACKAGE_BY_EXTRA.get(extra_name)

litert_cli/core/deps_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DepsTest(absltest.TestCase):
2727

2828
def setUp(self):
2929
super().setUp()
30-
self.enter_context(mock.patch.object(constants, 'IN_GOOGLE3', False))
30+
self.enter_context(mock.patch.object(constants, 'IS_INTERNAL_ENV', False))
3131

3232
@mock.patch.object(importlib.metadata, 'version', autospec=True)
3333
def test_ensure_extra_already_installed(self, mock_version):

litert_cli/litert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def main_bridge(unused_argv):
110110

111111
if __name__ == '__main__':
112112
try:
113-
# Try to run in google3
113+
# Try to run in internal environment
114114
from absl import app # pylint: disable=g-import-not-at-top
115115

116116
app.run(main_bridge, argv=[sys.argv[0]])

0 commit comments

Comments
 (0)