This repository has been archived by the owner on Feb 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update * update * update * add missing import * update * update envvar * add bentoctl version * fix lint and test
- Loading branch information
Showing
7 changed files
with
154 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import logging | ||
import os | ||
|
||
|
||
DEBUG_ENV_VAR = "BENTOCTL_DEBUG" | ||
|
||
|
||
def set_debug_mode(is_enabled: bool): | ||
if is_enabled or os.environ.get(DEBUG_ENV_VAR): | ||
os.environ[DEBUG_ENV_VAR] = str(True) | ||
logging.getLogger().setLevel(logging.DEBUG) | ||
logging.getLogger("bentoml").setLevel(logging.DEBUG) | ||
else: | ||
logging.getLogger().setLevel(logging.WARNING) | ||
logging.getLogger("bentoml").setLevel(logging.WARNING) | ||
|
||
|
||
def get_debug_mode(): | ||
if DEBUG_ENV_VAR in os.environ: | ||
return os.environ[DEBUG_ENV_VAR].lower() == "true" | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from bentoctl import __version__ | ||
|
||
# These are internal apis. We will need to make sure update these when BentoML changes. | ||
from bentoml._internal.utils.analytics.usage_stats import ( # noqa pylint: disable=unused-import | ||
do_not_track, | ||
track, | ||
BENTOML_DO_NOT_TRACK, | ||
) | ||
|
||
|
||
class CliEvent: | ||
def __init__( | ||
self, | ||
cmd_group, | ||
cmd_name, | ||
duration_in_ms=None, | ||
error_type=None, | ||
return_code=None, | ||
operator=None, | ||
version=None, | ||
): | ||
self.cmd_group = cmd_group | ||
self.cmd_name = cmd_name | ||
self.duration_in_ms = duration_in_ms | ||
self.error_type = error_type | ||
self.return_code = return_code | ||
self.operator = operator | ||
self.version = version | ||
self.bentoctl_version = __version__ | ||
self.event_name = 'bentoctl_cli' | ||
|
||
|
||
def _bentoctl_event(cmd_group, cmd_name, return_value=None): | ||
if return_value is not None: | ||
deployment_config = return_value | ||
version = ( | ||
deployment_config.bento.tag.version if deployment_config.bento else None | ||
) | ||
|
||
return CliEvent( | ||
cmd_group, | ||
cmd_name, | ||
operator=deployment_config.operator_name, | ||
version=version, | ||
) | ||
else: | ||
return CliEvent(cmd_group, cmd_name) | ||
|
||
|
||
cli_events_map = {"bentoctl": _bentoctl_event} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters