Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r ClientAdvisor/App/requirements.txt
- name: Run flake8
run: flake8 --config=ClientAdvisor/App/.flake8 ClientAdvisor/App
pip install -r ResearchAssistant/App/requirements.txt
pip install pylint flake8 azure-identity pymssql
- name: Run flake8 and pylint
run: |
flake8 --config=ClientAdvisor/App/.flake8 ClientAdvisor/App
pylint --rcfile=ClientAdvisor/App/.pylintrc ClientAdvisor/App
flake8 --config=ResearchAssistant/App/.flake8 ResearchAssistant/App
pylint --rcfile=ResearchAssistant/App/.pylintrc ResearchAssistant/App
6 changes: 3 additions & 3 deletions ClientAdvisor/App/.flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
max-line-length = 88
extend-ignore = E501, E203
exclude = .venv, frontend,
max-line-length = 160
extend-ignore = E203, W503, E501
exclude = .venv, frontend
41 changes: 41 additions & 0 deletions ClientAdvisor/App/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[MASTER]
ignore=tests ; Ignore the tests folder globally.

[MESSAGES CONTROL]
disable=
invalid-name, # C0103: Ignore naming style errors
line-too-long, # C0301: Ignore long lines
missing-function-docstring, # C0116: Ignore missing function docstrings
missing-class-docstring, # C0115: Ignore missing class docstrings
missing-module-docstring, # C0114: Ignore missing module docstrings
redefined-outer-name, # W0621: Ignore redefined variables warnings
broad-exception-raised, # W0719: Ignore broad exception raised warnings
broad-exception-caught, # W0718: Ignore broad exception caught warnings
too-many-arguments, # R0913: Ignore too many arguments
too-many-locals, # R0914: Ignore too many local variables
too-many-return-statements, # R0911: Ignore too many return statements
too-many-branches, # R0912: Ignore too many branches
unused-argument, # W0613: Ignore unused arguments
unspecified-encoding, # W1514: Ignore unspecified encoding in open()
logging-fstring-interpolation, # W1203: Ignore lazy f-string interpolation
missing-timeout, # W3101: Ignore missing timeout in requests.get
no-else-return, # R1705: Ignore unnecessary 'else' after return
redefined-builtin, # W0622: Ignore redefining built-ins
global-statement, # W0603: Ignore global statement usage
no-name-in-module, # E0611: Ignore unresolved module names
no-member, # E1101: Ignore module has no 'member'
pointless-string-statement, # W0105: Ignore pointless string statements
unnecessary-comprehension, # R1721: Ignore unnecessary comprehensions
fixme, # W0511: Ignore TODO comments
too-many-instance-attributes, # R0902: Ignore too many attributes in class
too-many-positional-arguments, # R0917: Ignore too many positional arguments
raise-missing-from, # W0707: Ignore re-raising without 'raise from'
import-outside-toplevel, # C0415: Ignore imports outside top-level
no-value-for-parameter # E1120: Ignore missing arguments in function

[TYPECHECK]
generated-members=get_bearer_token_provider

[FORMAT]
max-module-lines=1700 # Allow large modules up to 1700 lines
max-line-length=160 # Allow lines up to 160 characters
61 changes: 30 additions & 31 deletions ClientAdvisor/App/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,31 @@

import httpx
import requests
from azure.identity.aio import (DefaultAzureCredential,
get_bearer_token_provider)
from azure.identity.aio import DefaultAzureCredential, get_bearer_token_provider
from backend.auth.auth_utils import get_authenticated_user_details, get_tenantid
from backend.history.cosmosdbservice import CosmosConversationClient
from backend.utils import (
convert_to_pf_format,
format_as_ndjson,
format_pf_non_streaming_response,
format_stream_response,
generateFilterString,
parse_multi_columns,
)
from db import get_connection
from dotenv import load_dotenv

# from quart.sessions import SecureCookieSessionInterface
from openai import AsyncAzureOpenAI
from quart import (Blueprint, Quart, jsonify, make_response, render_template,
request, send_from_directory)

from backend.auth.auth_utils import (get_authenticated_user_details,
get_tenantid)
from backend.history.cosmosdbservice import CosmosConversationClient
from backend.utils import (convert_to_pf_format, format_as_ndjson,
format_pf_non_streaming_response,
format_stream_response, generateFilterString,
parse_multi_columns)
from db import get_connection
from quart import (
Blueprint,
Quart,
jsonify,
make_response,
render_template,
request,
send_from_directory,
)

bp = Blueprint("routes", __name__, static_folder="static", template_folder="static")

Expand Down Expand Up @@ -172,7 +181,7 @@ async def assets(path):
"AZURE_COSMOSDB_MONGO_VCORE_VECTOR_COLUMNS"
)

SHOULD_STREAM = True if AZURE_OPENAI_STREAM.lower() == "true" else False
SHOULD_STREAM = AZURE_OPENAI_STREAM.lower() == "true"

# Chat History CosmosDB Integration Settings
AZURE_COSMOSDB_DATABASE = os.environ.get("AZURE_COSMOSDB_DATABASE")
Expand Down Expand Up @@ -373,7 +382,7 @@ def init_openai_client(use_data=SHOULD_USE_DATA):

return azure_openai_client
except Exception as e:
logging.exception("Exception in Azure OpenAI initialization", e)
logging.exception("Exception in Azure OpenAI initialization", exc_info=True)
azure_openai_client = None
raise e

Expand All @@ -399,7 +408,7 @@ def init_cosmosdb_client():
enable_message_feedback=AZURE_COSMOSDB_ENABLE_FEEDBACK,
)
except Exception as e:
logging.exception("Exception in CosmosDB initialization", e)
logging.exception("Exception in CosmosDB initialization", exc_info=True)
cosmos_conversation_client = None
raise e
else:
Expand Down Expand Up @@ -472,9 +481,7 @@ def get_configured_data_source():
else []
),
},
"in_scope": (
True if AZURE_SEARCH_ENABLE_IN_DOMAIN.lower() == "true" else False
),
"in_scope": (AZURE_SEARCH_ENABLE_IN_DOMAIN.lower() == "true"),
"top_n_documents": (
int(AZURE_SEARCH_TOP_K) if AZURE_SEARCH_TOP_K else int(SEARCH_TOP_K)
),
Expand Down Expand Up @@ -534,9 +541,7 @@ def get_configured_data_source():
),
},
"in_scope": (
True
if AZURE_COSMOSDB_MONGO_VCORE_ENABLE_IN_DOMAIN.lower() == "true"
else False
AZURE_COSMOSDB_MONGO_VCORE_ENABLE_IN_DOMAIN.lower() == "true"
),
"top_n_documents": (
int(AZURE_COSMOSDB_MONGO_VCORE_TOP_K)
Expand Down Expand Up @@ -590,9 +595,7 @@ def get_configured_data_source():
else []
),
},
"in_scope": (
True if ELASTICSEARCH_ENABLE_IN_DOMAIN.lower() == "true" else False
),
"in_scope": (ELASTICSEARCH_ENABLE_IN_DOMAIN.lower() == "true"),
"top_n_documents": (
int(ELASTICSEARCH_TOP_K)
if ELASTICSEARCH_TOP_K
Expand Down Expand Up @@ -642,9 +645,7 @@ def get_configured_data_source():
else []
),
},
"in_scope": (
True if AZURE_MLINDEX_ENABLE_IN_DOMAIN.lower() == "true" else False
),
"in_scope": (AZURE_MLINDEX_ENABLE_IN_DOMAIN.lower() == "true"),
"top_n_documents": (
int(AZURE_MLINDEX_TOP_K)
if AZURE_MLINDEX_TOP_K
Expand Down Expand Up @@ -687,9 +688,7 @@ def get_configured_data_source():
else []
),
},
"in_scope": (
True if PINECONE_ENABLE_IN_DOMAIN.lower() == "true" else False
),
"in_scope": (PINECONE_ENABLE_IN_DOMAIN.lower() == "true"),
"top_n_documents": (
int(PINECONE_TOP_K) if PINECONE_TOP_K else int(SEARCH_TOP_K)
),
Expand Down
3 changes: 1 addition & 2 deletions ClientAdvisor/App/backend/history/cosmosdbservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def __init__(
except exceptions.CosmosHttpResponseError as e:
if e.status_code == 401:
raise ValueError("Invalid credentials") from e
else:
raise ValueError("Invalid CosmosDB endpoint") from e
raise ValueError("Invalid CosmosDB endpoint") from e

try:
self.database_client = self.cosmosdb_client.get_database_client(
Expand Down
3 changes: 1 addition & 2 deletions ClientAdvisor/App/tests/backend/auth/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import json
from unittest.mock import patch

from backend.auth.auth_utils import (get_authenticated_user_details,
get_tenantid)
from backend.auth.auth_utils import get_authenticated_user_details, get_tenantid


def test_get_authenticated_user_details_no_principal_id():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pytest
from azure.cosmos import exceptions

from backend.history.cosmosdbservice import CosmosConversationClient


Expand Down
17 changes: 11 additions & 6 deletions ClientAdvisor/App/tests/backend/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
from unittest.mock import MagicMock, patch

import pytest

from backend.utils import (JSONEncoder, convert_to_pf_format, fetchUserGroups,
format_as_ndjson, format_non_streaming_response,
format_pf_non_streaming_response,
format_stream_response, generateFilterString,
parse_multi_columns)
from backend.utils import (
JSONEncoder,
convert_to_pf_format,
fetchUserGroups,
format_as_ndjson,
format_non_streaming_response,
format_pf_non_streaming_response,
format_stream_response,
generateFilterString,
parse_multi_columns,
)


@dataclasses.dataclass
Expand Down
11 changes: 8 additions & 3 deletions ClientAdvisor/App/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
from unittest.mock import AsyncMock, MagicMock, patch

import pytest

from app import (create_app, delete_all_conversations, generate_title,
init_cosmosdb_client, init_openai_client, stream_chat_request)
from app import (
create_app,
delete_all_conversations,
generate_title,
init_cosmosdb_client,
init_openai_client,
stream_chat_request,
)

# Constants for testing
INVALID_API_VERSION = "2022-01-01"
Expand Down
3 changes: 1 addition & 2 deletions ClientAdvisor/App/tools/data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import os
import sys

from dotenv import load_dotenv

import app
from dotenv import load_dotenv

# import the app.py module to gain access to the methods to construct payloads and
# call the API through the sdk
Expand Down
Loading
Loading