Skip to content

Commit b3344a3

Browse files
lukebaumanncopybara-github
authored andcommitted
Catch OSError when setting up cloud logging.
In some environments, a GCP project is not determinable and `cloud_logging.setup()` raises an exception. PiperOrigin-RevId: 676089267
1 parent 3a09bad commit b3344a3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pathwaysutils/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ def _is_persistence_enabled():
5555
pathways_orbax_handler.register_pathways_handlers(
5656
datetime.timedelta(minutes=10)
5757
)
58-
cloud_logging.setup()
58+
try:
59+
cloud_logging.setup()
60+
except OSError as e:
61+
logging.warning("pathwaysutils: Failed to set up cloud logging.")
5962
else:
6063
logging.warning(
6164
"pathwaysutils: Did not detect Pathways-on-Cloud backend. No changes"

0 commit comments

Comments
 (0)