Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
asaiacai committed Sep 17, 2024
1 parent 671ea3f commit 9435932
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
10 changes: 2 additions & 8 deletions sky/usage/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@
PRIVACY_POLICY_PATH = '~/.sky/privacy_policy'

POSTHOG_API_KEY = os.environ.get(
'POSTHOG_API_KEY',
'phc_4UgX80BfVNmYRZ2o3dJLyRMGkv1CxBozPAcPnD29uP4'
)

POSTHOG_HOST = os.environ.get(
'POSTHOG_HOST',
'https://us.i.posthog.com'
)
'POSTHOG_API_KEY', 'phc_4UgX80BfVNmYRZ2o3dJLyRMGkv1CxBozPAcPnD29uP4')

POSTHOG_HOST = os.environ.get('POSTHOG_HOST', 'https://us.i.posthog.com')

USAGE_POLICY_MESSAGE = (
'SkyPilot collects usage data to improve its services. '
Expand Down
23 changes: 8 additions & 15 deletions sky/usage/usage_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import inspect
import json
import os
import posthog
import time
import traceback
import typing
from typing import Any, Callable, Dict, List, Optional, Union

import click
import posthog
import requests

import sky
Expand All @@ -28,10 +28,8 @@
from sky import task as task_lib

logger = sky_logging.init_logger(__name__)
posthog_client = posthog.Posthog(
constants.POSTHOG_API_KEY,
constants.POSTHOG_HOST
)
posthog_client = posthog.Posthog(constants.POSTHOG_API_KEY,
constants.POSTHOG_HOST)


def _get_current_timestamp_ns() -> int:
Expand Down Expand Up @@ -325,16 +323,11 @@ def _send_to_loki(message_type: MessageType):
data=payload,
headers=headers,
timeout=0.5)
posthog_client.capture(
common_utils.get_user_hash(),
'trainy-sky-event',
{
**prom_labels,
**json.loads(str(message)),
'timestamp': str(log_timestamp)
}
)

posthog_client.capture(common_utils.get_user_hash(), 'trainy-sky-event', {
**prom_labels,
**json.loads(str(message)), 'timestamp': str(log_timestamp)
})

if response.status_code != 204:
logger.debug(
f'Grafana Loki failed with response: {response.text}\n{payload}')
Expand Down

0 comments on commit 9435932

Please sign in to comment.