-
Notifications
You must be signed in to change notification settings - Fork 47
ADS changes for MS enhancements #1036
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
Changes from all commits
d681e17
77783ce
804d17f
09f2f9b
3dd7b85
0aa0df0
663e7b2
8f7da9e
9207cce
32d5695
446df19
0ea9c9d
44e04bd
bae144e
db59823
ca4b8c9
eb3bb86
b8cb9b8
19c98cf
2a8e4b7
68bcdf5
0f53a8d
d15ec0b
4d60946
be3c617
01e040d
7238c2e
fabb268
134d6c5
c58b2f5
87dfe13
c1020f8
f0091cc
05e7813
1784b42
5b1207d
5eb496e
4cc32ad
5c2d6e6
cd3dd8a
6321fa8
1a0484e
ead6753
f917ee7
f847ca3
e05cbf3
d8bab8a
0813099
c1b1b96
1b87417
40456fe
45e9014
782839f
aabbb98
b4999d0
192248a
54296f1
39763e9
2eb12a3
e414716
5ef6f12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
from enum import Enum | ||
from io import DEFAULT_BUFFER_SIZE | ||
from textwrap import fill | ||
from typing import Dict, Optional, Tuple, Union | ||
from typing import Any, Dict, Optional, Tuple, Union | ||
from urllib import request | ||
from urllib.parse import urlparse | ||
|
||
|
@@ -63,6 +63,8 @@ | |
# Maximum distinct values by cardinality will be used for plotting | ||
MAX_DISPLAY_VALUES = 10 | ||
|
||
UNKNOWN = "" | ||
|
||
# par link of the index json file. | ||
PAR_LINK = "https://objectstorage.us-ashburn-1.oraclecloud.com/p/WyjtfVIG0uda-P3-2FmAfwaLlXYQZbvPZmfX1qg0-sbkwEQO6jpwabGr2hMDBmBp/n/ociodscdev/b/service-conda-packs/o/service_pack/index.json" | ||
|
||
|
@@ -82,6 +84,7 @@ | |
color=["teal", "blueviolet", "forestgreen", "peru", "y", "dodgerblue", "r"] | ||
) | ||
|
||
|
||
# sqlalchemy engines | ||
_engines = {} | ||
|
||
|
@@ -149,6 +152,22 @@ def oci_key_location(): | |
) | ||
|
||
|
||
def text_sanitizer(content): | ||
if isinstance(content, str): | ||
return ( | ||
content.replace("“", '"') | ||
.replace("”", '"') | ||
.replace("’", "'") | ||
.replace("‘", "'") | ||
.replace("—", "-") | ||
.encode("utf-8", "ignore") | ||
.decode("utf-8", "ignore") | ||
) | ||
if isinstance(content, dict): | ||
return json.dumps(content) | ||
return str(content) | ||
|
||
|
||
@deprecated( | ||
"2.5.10", | ||
details="Deprecated, use: from ads.common.auth import AuthState; AuthState().oci_config_path", | ||
|
@@ -212,6 +231,37 @@ def random_valid_ocid(prefix="ocid1.dataflowapplication.oc1.iad"): | |
return f"{left}.{fake}" | ||
|
||
|
||
def parse_bool(value: Any) -> bool: | ||
""" | ||
Converts a value to boolean. For strings, it interprets 'true', '1', or 'yes' | ||
(case insensitive) as True; everything else as False. | ||
|
||
Parameters | ||
---------- | ||
value : Any | ||
The value to convert to boolean. | ||
|
||
Returns | ||
------- | ||
bool | ||
The boolean interpretation of the value. | ||
""" | ||
if isinstance(value, bool): | ||
return value | ||
if isinstance(value, str): | ||
return value.strip().lower() in ("true", "1", "yes") | ||
return bool(value) | ||
|
||
|
||
def read_file(file_path: str, **kwargs) -> str: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you double check, we might already have something similar in common utils There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't create this function , just moved it from |
||
try: | ||
with fsspec.open(file_path, "r", **kwargs.get("auth", {})) as f: | ||
return f.read() | ||
except Exception as e: | ||
logger.debug(f"Failed to read file {file_path}. {e}") | ||
return UNKNOWN | ||
|
||
|
||
def get_dataframe_styles(max_width=75): | ||
"""Styles used for dataframe, example usage: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we remove
UNKNOWN
here, it causes some error infeature/multi_model_deploy
branch. I'll add it back to the corresponding pr. @mrDzurbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was moved to ads.common.utils since this function was moved to
ads.common.utils
to avoid circular importsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a generic function , it was adviced to move this to
ads.common.utils