oracle-ads 2.11.12__py3-none-any.whl → 2.11.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ads/llm/langchain/plugins/base.py +6 -0
- ads/model/datascience_model.py +224 -0
- {oracle_ads-2.11.12.dist-info → oracle_ads-2.11.13.dist-info}/METADATA +3 -4
- {oracle_ads-2.11.12.dist-info → oracle_ads-2.11.13.dist-info}/RECORD +7 -7
- {oracle_ads-2.11.12.dist-info → oracle_ads-2.11.13.dist-info}/LICENSE.txt +0 -0
- {oracle_ads-2.11.12.dist-info → oracle_ads-2.11.13.dist-info}/WHEEL +0 -0
- {oracle_ads-2.11.12.dist-info → oracle_ads-2.11.13.dist-info}/entry_points.txt +0 -0
@@ -8,6 +8,7 @@ from typing import Any, Dict, List, Optional
|
|
8
8
|
from langchain.llms.base import LLM
|
9
9
|
from langchain.pydantic_v1 import BaseModel, Field, root_validator
|
10
10
|
|
11
|
+
from ads import logger
|
11
12
|
from ads.common.auth import default_signer
|
12
13
|
from ads.config import COMPARTMENT_OCID
|
13
14
|
|
@@ -95,6 +96,11 @@ class GenerativeAiClientModel(BaseModel):
|
|
95
96
|
"""Validate that python package exists in environment."""
|
96
97
|
# Initialize client only if user does not pass in client.
|
97
98
|
# Users may choose to initialize the OCI client by themselves and pass it into this model.
|
99
|
+
logger.warning(
|
100
|
+
f"The ads langchain plugin {cls.__name__} will be deprecated soon. "
|
101
|
+
"Please refer to https://python.langchain.com/v0.2/docs/integrations/providers/oci/ "
|
102
|
+
"for the latest support."
|
103
|
+
)
|
98
104
|
if not values.get("client"):
|
99
105
|
auth = values.get("auth", {})
|
100
106
|
client_kwargs = auth.get("client_kwargs") or {}
|
ads/model/datascience_model.py
CHANGED
@@ -41,6 +41,7 @@ from ads.model.service.oci_datascience_model import (
|
|
41
41
|
ModelProvenanceNotFoundError,
|
42
42
|
OCIDataScienceModel,
|
43
43
|
)
|
44
|
+
from ads.common import oci_client as oc
|
44
45
|
|
45
46
|
logger = logging.getLogger(__name__)
|
46
47
|
|
@@ -1466,3 +1467,226 @@ class DataScienceModel(Builder):
|
|
1466
1467
|
bucket_uri.append(uri)
|
1467
1468
|
|
1468
1469
|
return bucket_uri[0] if len(bucket_uri) == 1 else bucket_uri, artifact_size
|
1470
|
+
|
1471
|
+
def add_artifact(
|
1472
|
+
self,
|
1473
|
+
uri: Optional[str] = None,
|
1474
|
+
namespace: Optional[str] = None,
|
1475
|
+
bucket: Optional[str] = None,
|
1476
|
+
prefix: Optional[str] = None,
|
1477
|
+
files: Optional[List[str]] = None,
|
1478
|
+
):
|
1479
|
+
"""
|
1480
|
+
Adds information about objects in a specified bucket to the model description JSON.
|
1481
|
+
|
1482
|
+
Parameters
|
1483
|
+
----------
|
1484
|
+
uri : str, optional
|
1485
|
+
The URI representing the location of the artifact in OCI object storage.
|
1486
|
+
namespace : str, optional
|
1487
|
+
The namespace of the bucket containing the objects. Required if `uri` is not provided.
|
1488
|
+
bucket : str, optional
|
1489
|
+
The name of the bucket containing the objects. Required if `uri` is not provided.
|
1490
|
+
prefix : str, optional
|
1491
|
+
The prefix of the objects to add. Defaults to None. Cannot be provided if `files` is provided.
|
1492
|
+
files : list of str, optional
|
1493
|
+
A list of file names to include in the model description. If provided, only objects with matching file names will be included. Cannot be provided if `prefix` is provided.
|
1494
|
+
|
1495
|
+
Returns
|
1496
|
+
-------
|
1497
|
+
None
|
1498
|
+
|
1499
|
+
Raises
|
1500
|
+
------
|
1501
|
+
ValueError
|
1502
|
+
- If both `uri` and (`namespace` and `bucket`) are provided.
|
1503
|
+
- If neither `uri` nor both `namespace` and `bucket` are provided.
|
1504
|
+
- If both `prefix` and `files` are provided.
|
1505
|
+
- If no files are found to add to the model description.
|
1506
|
+
|
1507
|
+
Note
|
1508
|
+
----
|
1509
|
+
- If `files` is not provided, it retrieves information about all objects in the bucket.
|
1510
|
+
- If `files` is provided, it only retrieves information about objects with matching file names.
|
1511
|
+
- If no objects are found to add to the model description, a ValueError is raised.
|
1512
|
+
"""
|
1513
|
+
|
1514
|
+
if uri and (namespace or bucket):
|
1515
|
+
raise ValueError(
|
1516
|
+
"Either 'uri' must be provided or both 'namespace' and 'bucket' must be provided."
|
1517
|
+
)
|
1518
|
+
if uri:
|
1519
|
+
object_storage_details = ObjectStorageDetails.from_path(uri)
|
1520
|
+
bucket = object_storage_details.bucket
|
1521
|
+
namespace = object_storage_details.namespace
|
1522
|
+
prefix = (
|
1523
|
+
None
|
1524
|
+
if object_storage_details.filepath == ""
|
1525
|
+
else object_storage_details.filepath
|
1526
|
+
)
|
1527
|
+
if (not namespace) or (not bucket):
|
1528
|
+
raise ValueError("Both 'namespace' and 'bucket' must be provided.")
|
1529
|
+
|
1530
|
+
# Check if both prefix and files are provided
|
1531
|
+
if prefix is not None and files is not None:
|
1532
|
+
raise ValueError(
|
1533
|
+
"Both 'prefix' and 'files' cannot be provided. Please provide only one."
|
1534
|
+
)
|
1535
|
+
|
1536
|
+
if self.model_file_description == None:
|
1537
|
+
self.empty_json = {
|
1538
|
+
"version": "1.0",
|
1539
|
+
"type": "modelOSSReferenceDescription",
|
1540
|
+
"models": [],
|
1541
|
+
}
|
1542
|
+
self.set_spec(self.CONST_MODEL_FILE_DESCRIPTION, self.empty_json)
|
1543
|
+
|
1544
|
+
# Get object storage client
|
1545
|
+
self.object_storage_client = oc.OCIClientFactory(
|
1546
|
+
**(self.dsc_model.auth)
|
1547
|
+
).object_storage
|
1548
|
+
|
1549
|
+
# Remove if the model already exists
|
1550
|
+
self.remove_artifact(namespace=namespace, bucket=bucket, prefix=prefix)
|
1551
|
+
|
1552
|
+
def check_if_file_exists(fileName):
|
1553
|
+
isExists = False
|
1554
|
+
try:
|
1555
|
+
headResponse = self.object_storage_client.head_object(
|
1556
|
+
namespace, bucket, object_name=fileName
|
1557
|
+
)
|
1558
|
+
if headResponse.status == 200:
|
1559
|
+
isExists = True
|
1560
|
+
except Exception as e:
|
1561
|
+
if hasattr(e, "status") and e.status == 404:
|
1562
|
+
logger.error(f"File not found in bucket: {fileName}")
|
1563
|
+
else:
|
1564
|
+
logger.error(f"An error occured: {e}")
|
1565
|
+
return isExists
|
1566
|
+
|
1567
|
+
# Function to un-paginate the api call with while loop
|
1568
|
+
def list_obj_versions_unpaginated():
|
1569
|
+
objectStorageList = []
|
1570
|
+
has_next_page, opc_next_page = True, None
|
1571
|
+
while has_next_page:
|
1572
|
+
response = self.object_storage_client.list_object_versions(
|
1573
|
+
namespace_name=namespace,
|
1574
|
+
bucket_name=bucket,
|
1575
|
+
prefix=prefix,
|
1576
|
+
fields="name,size",
|
1577
|
+
page=opc_next_page,
|
1578
|
+
)
|
1579
|
+
objectStorageList.extend(response.data.items)
|
1580
|
+
has_next_page = response.has_next_page
|
1581
|
+
opc_next_page = response.next_page
|
1582
|
+
return objectStorageList
|
1583
|
+
|
1584
|
+
# Fetch object details and put it into the objects variable
|
1585
|
+
objectStorageList = []
|
1586
|
+
if files == None:
|
1587
|
+
objectStorageList = list_obj_versions_unpaginated()
|
1588
|
+
else:
|
1589
|
+
for fileName in files:
|
1590
|
+
if check_if_file_exists(fileName=fileName):
|
1591
|
+
objectStorageList.append(
|
1592
|
+
self.object_storage_client.list_object_versions(
|
1593
|
+
namespace_name=namespace,
|
1594
|
+
bucket_name=bucket,
|
1595
|
+
prefix=fileName,
|
1596
|
+
fields="name,size",
|
1597
|
+
).data.items[0]
|
1598
|
+
)
|
1599
|
+
|
1600
|
+
objects = [
|
1601
|
+
{"name": obj.name, "version": obj.version_id, "sizeInBytes": obj.size}
|
1602
|
+
for obj in objectStorageList
|
1603
|
+
if obj.size > 0
|
1604
|
+
]
|
1605
|
+
|
1606
|
+
if len(objects) == 0:
|
1607
|
+
error_message = (
|
1608
|
+
f"No files to add in the bucket: {bucket} with namespace: {namespace} "
|
1609
|
+
f"and prefix: {prefix}. File names: {files}"
|
1610
|
+
)
|
1611
|
+
logger.error(error_message)
|
1612
|
+
raise ValueError(error_message)
|
1613
|
+
|
1614
|
+
tmp_model_file_description = self.model_file_description
|
1615
|
+
tmp_model_file_description["models"].append(
|
1616
|
+
{
|
1617
|
+
"namespace": namespace,
|
1618
|
+
"bucketName": bucket,
|
1619
|
+
"prefix": "" if not prefix else prefix,
|
1620
|
+
"objects": objects,
|
1621
|
+
}
|
1622
|
+
)
|
1623
|
+
self.set_spec(self.CONST_MODEL_FILE_DESCRIPTION, tmp_model_file_description)
|
1624
|
+
|
1625
|
+
def remove_artifact(
|
1626
|
+
self,
|
1627
|
+
uri: Optional[str] = None,
|
1628
|
+
namespace: Optional[str] = None,
|
1629
|
+
bucket: Optional[str] = None,
|
1630
|
+
prefix: Optional[str] = None,
|
1631
|
+
):
|
1632
|
+
"""
|
1633
|
+
Removes information about objects in a specified bucket or using a specified URI from the model description JSON.
|
1634
|
+
|
1635
|
+
Parameters
|
1636
|
+
----------
|
1637
|
+
uri : str, optional
|
1638
|
+
The URI representing the location of the artifact in OCI object storage.
|
1639
|
+
namespace : str, optional
|
1640
|
+
The namespace of the bucket containing the objects. Required if `uri` is not provided.
|
1641
|
+
bucket : str, optional
|
1642
|
+
The name of the bucket containing the objects. Required if `uri` is not provided.
|
1643
|
+
prefix : str, optional
|
1644
|
+
The prefix of the objects to remove. Defaults to None.
|
1645
|
+
|
1646
|
+
Returns
|
1647
|
+
-------
|
1648
|
+
None
|
1649
|
+
|
1650
|
+
Raises
|
1651
|
+
------
|
1652
|
+
ValueError
|
1653
|
+
- If both 'uri' and ('namespace' and 'bucket') are provided.
|
1654
|
+
- If neither 'uri' nor both 'namespace' and 'bucket' are provided.
|
1655
|
+
- If the model description JSON is None.
|
1656
|
+
"""
|
1657
|
+
|
1658
|
+
if uri and (namespace or bucket):
|
1659
|
+
raise ValueError(
|
1660
|
+
"Either 'uri' must be provided or both 'namespace' and 'bucket' must be provided."
|
1661
|
+
)
|
1662
|
+
if uri:
|
1663
|
+
object_storage_details = ObjectStorageDetails.from_path(uri)
|
1664
|
+
bucket = object_storage_details.bucket
|
1665
|
+
namespace = object_storage_details.namespace
|
1666
|
+
prefix = (
|
1667
|
+
None
|
1668
|
+
if object_storage_details.filepath == ""
|
1669
|
+
else object_storage_details.filepath
|
1670
|
+
)
|
1671
|
+
if (not namespace) or (not bucket):
|
1672
|
+
raise ValueError("Both 'namespace' and 'bucket' must be provided.")
|
1673
|
+
|
1674
|
+
def findModelIdx():
|
1675
|
+
for idx, model in enumerate(self.model_file_description["models"]):
|
1676
|
+
if (
|
1677
|
+
model["namespace"],
|
1678
|
+
model["bucketName"],
|
1679
|
+
(model["prefix"] if ("prefix" in model) else None),
|
1680
|
+
) == (namespace, bucket, "" if not prefix else prefix):
|
1681
|
+
return idx
|
1682
|
+
return -1
|
1683
|
+
|
1684
|
+
if self.model_file_description == None:
|
1685
|
+
return
|
1686
|
+
|
1687
|
+
modelSearchIdx = findModelIdx()
|
1688
|
+
if modelSearchIdx == -1:
|
1689
|
+
return
|
1690
|
+
else:
|
1691
|
+
# model found case
|
1692
|
+
self.model_file_description["models"].pop(modelSearchIdx)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: oracle_ads
|
3
|
-
Version: 2.11.
|
3
|
+
Version: 2.11.13
|
4
4
|
Summary: Oracle Accelerated Data Science SDK
|
5
5
|
Keywords: Oracle Cloud Infrastructure,OCI,Machine Learning,ML,Artificial Intelligence,AI,Data Science,Cloud,Oracle
|
6
6
|
Author: Oracle Data Science
|
@@ -21,7 +21,7 @@ Requires-Dist: fsspec>=0.8.7
|
|
21
21
|
Requires-Dist: gitpython>=3.1.2
|
22
22
|
Requires-Dist: jinja2>=2.11.2
|
23
23
|
Requires-Dist: matplotlib>=3.1.3, <=3.8.4
|
24
|
-
Requires-Dist: numpy>=1.19.2
|
24
|
+
Requires-Dist: numpy>=1.19.2, <2.0.0
|
25
25
|
Requires-Dist: oci>=2.125.3
|
26
26
|
Requires-Dist: ocifs>=1.1.3
|
27
27
|
Requires-Dist: pandas>1.2.1; python_version<'3.9'
|
@@ -61,7 +61,7 @@ Requires-Dist: rich ; extra == "forecast"
|
|
61
61
|
Requires-Dist: autots[additional] ; extra == "forecast"
|
62
62
|
Requires-Dist: mlforecast ; extra == "forecast"
|
63
63
|
Requires-Dist: neuralprophet>=0.7.0 ; extra == "forecast"
|
64
|
-
Requires-Dist: numpy ; extra == "forecast"
|
64
|
+
Requires-Dist: numpy<2.0.0 ; extra == "forecast"
|
65
65
|
Requires-Dist: oci-cli ; extra == "forecast"
|
66
66
|
Requires-Dist: optuna ; extra == "forecast"
|
67
67
|
Requires-Dist: oracle-ads ; extra == "forecast"
|
@@ -79,7 +79,6 @@ Requires-Dist: transformers ; extra == "huggingface"
|
|
79
79
|
Requires-Dist: langchain-community<0.0.32 ; extra == "llm"
|
80
80
|
Requires-Dist: langchain>=0.1.10,<0.1.14 ; extra == "llm"
|
81
81
|
Requires-Dist: evaluate>=0.4.0 ; extra == "llm"
|
82
|
-
Requires-Dist: langchain-core<0.1.51 ; extra == "llm"
|
83
82
|
Requires-Dist: ipython>=7.23.1, <8.0 ; extra == "notebook"
|
84
83
|
Requires-Dist: ipywidgets~=7.6.3 ; extra == "notebook"
|
85
84
|
Requires-Dist: lightgbm<4.0.0 ; extra == "onnx"
|
@@ -446,7 +446,7 @@ ads/llm/guardrails/base.py,sha256=3z_gSik-d859fvDGe4UGjSon_aeqE0PqZwHOCS_89J0,16
|
|
446
446
|
ads/llm/guardrails/huggingface.py,sha256=ts54JD6AUgXu7HoqYYU6NCQhwdhlWl0DSxuQ9ZRCQ3k,1314
|
447
447
|
ads/llm/langchain/__init__.py,sha256=sAqmLhogrLXb3xI7dPOj9HmSkpTnLh9wkzysuGd8AXk,204
|
448
448
|
ads/llm/langchain/plugins/__init__.py,sha256=sAqmLhogrLXb3xI7dPOj9HmSkpTnLh9wkzysuGd8AXk,204
|
449
|
-
ads/llm/langchain/plugins/base.py,sha256=
|
449
|
+
ads/llm/langchain/plugins/base.py,sha256=fmcI7KRCzh1Y-k7FbTzS-3WyAGomanFK0ZPZcqPIkFA,4704
|
450
450
|
ads/llm/langchain/plugins/contant.py,sha256=p1k9p7LwITygnZttNRauato1PhybUPESnIcZv3kkqLY,1008
|
451
451
|
ads/llm/langchain/plugins/embeddings.py,sha256=nOm902vY1P1oV6v1M7o9Fh0lSc7Gg0Nj5-puOByO6xI,2046
|
452
452
|
ads/llm/langchain/plugins/llm_gen_ai.py,sha256=HeFHUV1aqdw661VoyYdjG973m-LntU0YWozOZ9YEKi0,9975
|
@@ -460,7 +460,7 @@ ads/model/artifact.py,sha256=ONKyjZKO5wmAYI-GT63z8yLm_QsmIGXcob9KrnwtF5k,20503
|
|
460
460
|
ads/model/artifact_downloader.py,sha256=-9IYkjZ0LaMWf5foz5HUGTZCEm67f-3LbDsigNlzEPg,9751
|
461
461
|
ads/model/artifact_uploader.py,sha256=jdkpmncczceOc28LyMkv4u6f845HJ1vVCoI-hLBT-RM,11305
|
462
462
|
ads/model/base_properties.py,sha256=YeVyjCync4fzqqruMc9UfZKR4PnscU31n0mf4CJv3R8,7885
|
463
|
-
ads/model/datascience_model.py,sha256=
|
463
|
+
ads/model/datascience_model.py,sha256=Hejr_CAOCy2S_fSxNhI4ffis0SoYEVBfrA4MBPtrrzc,62775
|
464
464
|
ads/model/generic_model.py,sha256=aQco26ziO79q1BkLbRoS7CuE4Se4JYioyjRsFI3U5fU,146170
|
465
465
|
ads/model/model_file_description_schema.json,sha256=NZw_U4CvKf9oOdxCKr1eUxq8FHwjR_g0GSDk0Hz3SnE,1402
|
466
466
|
ads/model/model_introspect.py,sha256=z9pJul9dwT9w8flvRguhu0ZKoEkbm2Tvdutw_SHYTeg,9745
|
@@ -784,8 +784,8 @@ ads/type_discovery/unknown_detector.py,sha256=yZuYQReO7PUyoWZE7onhhtYaOg6088wf1y
|
|
784
784
|
ads/type_discovery/zipcode_detector.py,sha256=3AlETg_ZF4FT0u914WXvTT3F3Z6Vf51WiIt34yQMRbw,1421
|
785
785
|
ads/vault/__init__.py,sha256=x9tMdDAOdF5iDHk9u2di_K-ze5Nq068x25EWOBoWwqY,245
|
786
786
|
ads/vault/vault.py,sha256=hFBkpYE-Hfmzu1L0sQwUfYcGxpWmgG18JPndRl0NOXI,8624
|
787
|
-
oracle_ads-2.11.
|
788
|
-
oracle_ads-2.11.
|
789
|
-
oracle_ads-2.11.
|
790
|
-
oracle_ads-2.11.
|
791
|
-
oracle_ads-2.11.
|
787
|
+
oracle_ads-2.11.13.dist-info/entry_points.txt,sha256=9VFnjpQCsMORA4rVkvN8eH6D3uHjtegb9T911t8cqV0,35
|
788
|
+
oracle_ads-2.11.13.dist-info/LICENSE.txt,sha256=zoGmbfD1IdRKx834U0IzfFFFo5KoFK71TND3K9xqYqo,1845
|
789
|
+
oracle_ads-2.11.13.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
790
|
+
oracle_ads-2.11.13.dist-info/METADATA,sha256=lshh7w4VT5pefbtOMDHBwzJUcpovBZ6Z7Ydc0Fy3gzk,15717
|
791
|
+
oracle_ads-2.11.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|