Skip to content

Commit

Permalink
fix: Resolve pylint errors
Browse files Browse the repository at this point in the history
    pylint "struggles" with decorators, and seems unable to infer
    the parameters of the decorated functions of (Async)HttpPipeline.

    Adding #pylint: disable comments to those invocations that are
    known to be correct
  • Loading branch information
kdestin committed Aug 22, 2024
1 parent 9806b4f commit a49331f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/promptflow-evals/promptflow/evals/_common/rai_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ async def ensure_service_availability(rai_svc_url: str, token: str, capability:

client = get_async_http_client()

response = await client.get(svc_liveness_url, headers=headers, timeout=CommonConstants.DEFAULT_HTTP_TIMEOUT)
response = await client.get( # pylint: disable=too-many-function-args,unexpected-keyword-arg
svc_liveness_url, headers=headers, timeout=CommonConstants.DEFAULT_HTTP_TIMEOUT
)

if response.status_code != 200:
raise Exception( # pylint: disable=broad-exception-raised
Expand Down Expand Up @@ -104,7 +106,9 @@ async def submit_request(question: str, answer: str, metric: str, rai_svc_url: s

client = get_async_http_client()

response = await client.post(url, json=payload, headers=headers, timeout=CommonConstants.DEFAULT_HTTP_TIMEOUT)
response = await client.post( # pylint: disable=too-many-function-args,unexpected-keyword-arg
url, json=payload, headers=headers, timeout=CommonConstants.DEFAULT_HTTP_TIMEOUT
)

if response.status_code != 202:
print("Fail evaluating '%s' with error message: %s" % (payload["UserTextList"], response.text))
Expand Down Expand Up @@ -139,7 +143,9 @@ async def fetch_result(operation_id: str, rai_svc_url: str, credential: TokenCre

client = get_async_http_client()

response = await client.get(url, headers=headers, timeout=CommonConstants.DEFAULT_HTTP_TIMEOUT)
response = await client.get( # pylint: disable=too-many-function-args,unexpected-keyword-arg
url, headers=headers, timeout=CommonConstants.DEFAULT_HTTP_TIMEOUT
)

if response.status_code == 200:
return response.json()
Expand Down Expand Up @@ -245,7 +251,7 @@ async def _get_service_discovery_url(azure_ai_project: dict, token: str) -> str:

client = get_async_http_client()

response = await client.get(
response = await client.get( # pylint: disable=too-many-function-args,unexpected-keyword-arg
f"https://management.azure.com/subscriptions/{azure_ai_project['subscription_id']}/"
f"resourceGroups/{azure_ai_project['resource_group_name']}/"
f"providers/Microsoft.MachineLearningServices/workspaces/{azure_ai_project['project_name']}?"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Handle optional import. The azure libraries are only present if
# promptflow-azure is installed.
try:
from azure.ai.ml.entities._credentials import AccountKeyConfiguration
from azure.ai.ml.entities._credentials import AccountKeyConfiguration # pylint: disable=ungrouped-imports
from azure.ai.ml.entities._datastore.datastore import Datastore
from azure.storage.blob import BlobServiceClient
except (ModuleNotFoundError, ImportError):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ async def request_api(
# initial 10 seconds wait before attempting to fetch result
await asyncio.sleep(10)

response = await exp_retry_client.get(self.result_url, headers=proxy_headers)
response = await exp_retry_client.get( # pylint: disable=too-many-function-args,unexpected-keyword-arg
self.result_url, headers=proxy_headers
)

response.raise_for_status()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _get_service_discovery_url(self):
bearer_token = self.token_manager.get_token()
headers = {"Authorization": f"Bearer {bearer_token}", "Content-Type": "application/json"}
http_client = get_http_client()
response = http_client.get(
response = http_client.get( # pylint: disable=too-many-function-args,unexpected-keyword-arg
f"https://management.azure.com/subscriptions/{self.azure_ai_project['subscription_id']}/"
f"resourceGroups/{self.azure_ai_project['resource_group_name']}/"
f"providers/Microsoft.MachineLearningServices/workspaces/{self.azure_ai_project['project_name']}?"
Expand Down Expand Up @@ -116,7 +116,7 @@ async def get(self, url: str) -> Any:
}

session = self._create_async_client()
response = await session.get(url=url, headers=headers)
response = await session.get(url=url, headers=headers) # pylint: disable=unexpected-keyword-arg

if response.status_code == 200:
return response.json()
Expand Down

0 comments on commit a49331f

Please sign in to comment.