in src/python/tensorflow_cloud/utils/google_api_client.py [0:0]
def get_or_set_consent_status()-> bool:
"""Gets or sets the user consent status for telemetry collection.
Returns:
If the user has rejected client side telemetry collection returns
False, otherwise it returns true, if a consent flag is not found the
user is notified of telemetry collection and a flag is set.
"""
# Verify if user consent exists and if it is valid for current version of
# tensorflow_cloud
if os.path.exists(_LOCAL_CONFIG_PATH):
with open(_LOCAL_CONFIG_PATH) as config_json:
config_data = json.load(config_json)
if config_data.get(_TELEMETRY_REJECTED_CONFIG):
logging.info("User has opt-out of telemetry reporting.")
return False
if config_data.get(
_TELEMETRY_VERSION_CONFIG) == version.__version__:
return True
# Either user has not been notified of telemetry collection or a different
# version of the tensorflow_cloud has been installed since the last
# notification. Notify the user and update the configuration.
logging.info(_PRIVACY_NOTICE)
print(_PRIVACY_NOTICE)
config_data = {}
config_data[_TELEMETRY_VERSION_CONFIG] = version.__version__
# Create the config path if it does not already exist
os.makedirs(os.path.dirname(_LOCAL_CONFIG_PATH), exist_ok=True)
with open(_LOCAL_CONFIG_PATH, "w") as config_json:
json.dump(config_data, config_json)
return True