Spaces:
Build error
Build error
Download modules/cloud_logging.py from a9/incoder-demo: direct link, hf CLI and curl.
- Browser
- Download file 740 Bytes
-
https://huggingface.co/spaces/a9/incoder-demo/resolve/main/modules/cloud_logging.py
- Command line
-
hf download hf://spaces/a9/incoder-demo/modules/cloud_logging.py
-
curl -L -o cloud_logging.py https://huggingface.co/spaces/a9/incoder-demo/resolve/main/modules/cloud_logging.py
740 Bytes
| import os | |
| def make_logging_client(): | |
| cred_filename = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS') | |
| if not cred_filename: | |
| return None | |
| print("cred filename:", cred_filename) | |
| cred_string = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS_STRING') | |
| print("cred string:", bool(cred_string)) | |
| if not os.path.exists(cred_filename): | |
| if cred_string: | |
| print(f"writing cred string to {cred_filename}") | |
| with open(cred_filename, 'w') as f: | |
| f.write(cred_string) | |
| else: | |
| return None | |
| from google.cloud import logging | |
| logging_client = logging.Client() | |
| logging_client.setup_logging() | |
| return logging_client | |
| logging_client = make_logging_client() | |