diff --git a/.github/workflows/pip_install.yml b/.github/workflows/pip_install.yml new file mode 100644 index 000000000..bc095acdf --- /dev/null +++ b/.github/workflows/pip_install.yml @@ -0,0 +1,25 @@ +name: Pip install comment + +on: + pull_request: + +jobs: + create-pip-link-comment: + runs-on: ubuntu-latest + name: pip link + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Comment PR + uses: marocchino/sticky-pull-request-comment@v2 + with: + hide_and_recreate: true + hide_classify: "OUTDATED" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + message: | + Thanks for the PR! Going to review and merge soon 😉 + Just before that though can you please test the installation with the command below? 😎 + ``` + pip install git+https://github.com/RelevanceAI/relevance-workflows-core.git@${{ github.head_ref }} + ``` diff --git a/deepeval/_version.py b/deepeval/_version.py index 89080dd62..973235116 100644 --- a/deepeval/_version.py +++ b/deepeval/_version.py @@ -1 +1 @@ -__version__: str = "0.10.2" +__version__: str = "0.10.4" diff --git a/deepeval/cli/main.py b/deepeval/cli/main.py index 64ee1f1d5..324e9f6fd 100644 --- a/deepeval/cli/main.py +++ b/deepeval/cli/main.py @@ -34,13 +34,15 @@ def login( if api_key == "": api_key = KEY_FILE_HANDLER.fetch_api_key() api_key = typer.prompt( - text="Paste it here (Hit enter if default is right) ", + text="Paste it here (Hit enter if default is right)", default=api_key, ) KEY_FILE_HANDLER.write_api_key(api_key) client = Api(api_key=api_key) if project_name == "": project_name = KEY_FILE_HANDLER.fetch_implementation_name() + if project_name is None or project_name == "": + project_name = "example" print("What is the name of your project?") project_name = typer.prompt( text="Name (Hit enter if default is right):", diff --git a/deepeval/client.py b/deepeval/client.py index d4bae1e65..b06f22bc5 100644 --- a/deepeval/client.py +++ b/deepeval/client.py @@ -3,6 +3,7 @@ import os import getpass from .api import Api +from .get_api_key import _get_api_key from typing import Optional, List, Dict @@ -12,13 +13,8 @@ class Client(Api): _implementation_id: Dict[str, str] = {} def __init__(self, api_key: str = None, local_mode: bool = False, **kwargs): - if api_key is None: - if "CONFIDENT_AI_API_KEY" not in os.environ: - api_key = getpass.getpass( - "Grab your API key from https://app.confident-ai.com" - ) - else: - api_key = os.environ["CONFIDENT_AI_API_KEY"] + if api_key is None or api_key == "": + api_key = _get_api_key() self.api_key = api_key self.local_mode = local_mode if self.local_mode: diff --git a/deepeval/get_api_key.py b/deepeval/get_api_key.py new file mode 100644 index 000000000..b8d83ca4f --- /dev/null +++ b/deepeval/get_api_key.py @@ -0,0 +1,13 @@ +"""Utility function for getting API key. +""" +import os +from .key_handler import KEY_FILE_HANDLER +from .constants import API_KEY_ENV + + +def _get_api_key(): + """Get an API key here.""" + api_key = KEY_FILE_HANDLER.fetch_api_key() + if api_key is None or api_key == "": + api_key = os.getenv(API_KEY_ENV, "") + return api_key diff --git a/deepeval/metrics/metric.py b/deepeval/metrics/metric.py index 279cfa537..8cba808cf 100644 --- a/deepeval/metrics/metric.py +++ b/deepeval/metrics/metric.py @@ -1,6 +1,7 @@ import os import warnings from typing import Optional +from ..get_api_key import _get_api_key from ..constants import ( API_KEY_ENV, IMPLEMENTATION_ID_ENV, @@ -37,12 +38,14 @@ def is_successful(self) -> bool: raise NotImplementedError def _is_api_key_set(self): - result = os.getenv(API_KEY_ENV) is not None - if result is False: - warnings.warn( - """API key is not set. Please set it by visiting https://app.confident-ai.com""" - ) - return result + result = _get_api_key() + # if result == "" or result is None: + # warnings.warn( + # """API key is not set - you won't be able to log to the DeepEval dashboard. Please set it by running `deepeval login`""" + # ) + if result == "" or result is None: + return False + return True def _is_send_okay(self): # DOing this until the API endpoint is fixed