Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSK-2874 Fix quality badge using https://peps.python.org/pep-0563/ #1816

Merged
merged 2 commits into from
Feb 26, 2024
Merged
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: 7 additions & 3 deletions giskard/core/suite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Any, Callable, Dict, List, Optional, Union
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union

import inspect
import logging
Expand Down Expand Up @@ -28,6 +30,9 @@
from ..utils.artifacts import serialize_parameter
from .kwargs_utils import get_imports_code

if TYPE_CHECKING:
from mlflow import MlflowClient

logger = logging.getLogger(__name__)

suite_input_types: List[type] = [
Expand Down Expand Up @@ -123,10 +128,9 @@ def _repr_html_(self):
widget = TestSuiteResultWidget(self)
return widget.render_html()

def to_mlflow(self, mlflow_client=None, mlflow_run_id: str = None):
def to_mlflow(self, mlflow_client: MlflowClient = None, mlflow_run_id: str = None):
import mlflow

mlflow_client: mlflow.MlflowClient = mlflow_client
from giskard.integrations.mlflow.giskard_evaluator_utils import process_text

metrics = dict()
Expand Down
10 changes: 7 additions & 3 deletions giskard/datasets/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Dict, Hashable, List, Optional, Union
from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Hashable, List, Optional, Union

import inspect
import logging
Expand Down Expand Up @@ -33,6 +35,9 @@
from ...utils.file_utils import get_file_name
from ..metadata.indexing import ColumnMetadataMixin

if TYPE_CHECKING:
from mlflow import MlflowClient

SAMPLE_SIZE = 1000

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -692,10 +697,9 @@ def copy(self):

return dataset

def to_mlflow(self, mlflow_client=None, mlflow_run_id: str = None):
def to_mlflow(self, mlflow_client: MlflowClient = None, mlflow_run_id: str = None):
import mlflow

mlflow_client: mlflow.MlflowClient = mlflow_client # Doing typing here, to avoid import from mlflow
# To avoid file being open in write mode and read at the same time,
# First, we'll write it, then make sure to remove it
with tempfile.NamedTemporaryFile(prefix="dataset-", suffix=".csv", delete=False) as f:
Expand Down
10 changes: 7 additions & 3 deletions giskard/scanner/report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Optional
from __future__ import annotations

from typing import TYPE_CHECKING, Optional

import random
import string
Expand All @@ -11,6 +13,9 @@
from giskard.core.errors import GiskardImportError
from giskard.utils.analytics_collector import analytics, anonymize

if TYPE_CHECKING:
from mlflow import MlflowClient


class ScanReport:
def __init__(self, issues, model=None, dataset=None, as_html: bool = True):
Expand Down Expand Up @@ -212,7 +217,7 @@ def get_scan_summary_for_mlflow(scan_results):

def to_mlflow(
self,
mlflow_client=None,
mlflow_client: MlflowClient = None,
mlflow_run_id: str = None,
summary: bool = True,
model_artifact_path: str = "",
Expand All @@ -223,7 +228,6 @@ def to_mlflow(
"""
import mlflow

mlflow_client: mlflow.MlflowClient = mlflow_client
results_df = self.get_scan_summary_for_mlflow(self)
if model_artifact_path != "":
model_artifact_path = "-for-" + model_artifact_path
Expand Down
Loading