Skip to content

Commit 3d95666

Browse files
lukebaumanncopybara-github
authored andcommitted
Remove google.cloud.logging from package
It should be up to the workload whether structured logs and integration with Cloud Logging is used. In addition, `google.cloud.logging.Client.setup_logging()` was being called after other logs were made via dependencies. These other logs would create a `StreamHandler` that prints logs to stderr since no handler existed. Then `setup_logging` would add a `StructuredLogHandler` meaning there were two handlers resulting in duplicate logs. PiperOrigin-RevId: 751170764
1 parent 89c4651 commit 3d95666

File tree

3 files changed

+0
-41
lines changed

3 files changed

+0
-41
lines changed

pathwaysutils/__init__.py

-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import os
1919

2020
import jax
21-
from pathwaysutils import cloud_logging
2221
from pathwaysutils import profiling
2322
from pathwaysutils import proxy_backend
2423
from pathwaysutils.persistence import orbax_handler
@@ -101,13 +100,6 @@ def initialize() -> None:
101100
# compilation cache.
102101
jax.config.update("jax_enable_compilation_cache", False)
103102

104-
try:
105-
cloud_logging.setup()
106-
except Exception as error: # pylint: disable=broad-except
107-
_logger.debug(
108-
"Failed to set up cloud logging due to the following error: %s",
109-
error,
110-
)
111103
else:
112104
_logger.debug(
113105
"Did not detect Pathways-on-Cloud backend. No changes applied."

pathwaysutils/cloud_logging.py

-21
This file was deleted.

pathwaysutils/test/pathwaysutils_test.py

-12
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,19 @@
1515
import os
1616
from unittest import mock
1717

18-
import google.cloud.logging
1918
import jax
2019
import pathwaysutils
21-
from pathwaysutils import cloud_logging
2220

2321
from absl.testing import absltest
2422
from absl.testing import parameterized
2523

2624

2725
class PathwaysutilsTest(parameterized.TestCase):
2826

29-
def setUp(self):
30-
super().setUp()
31-
self.mock_setup_logging = mock.patch.object(
32-
cloud_logging, "setup", autospec=True
33-
)
34-
3527
def test_first_initialize(self):
3628
jax.config.update("jax_platforms", "proxy")
3729
pathwaysutils._initialization_count = 0
3830

39-
self.enter_context(
40-
mock.patch.object(google.cloud.logging, "Client", autospec=True)
41-
)
42-
4331
with self.assertLogs(pathwaysutils._logger, level="DEBUG") as logs:
4432
pathwaysutils.initialize()
4533

0 commit comments

Comments
 (0)