oracle-ads 2.11.9__py3-none-any.whl → 2.11.10__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/aqua/__init__.py +1 -1
- ads/aqua/{base.py → app.py} +27 -7
- ads/aqua/cli.py +59 -17
- ads/aqua/common/__init__.py +5 -0
- ads/aqua/{decorator.py → common/decorator.py} +14 -8
- ads/aqua/common/enums.py +69 -0
- ads/aqua/{exception.py → common/errors.py} +28 -0
- ads/aqua/{utils.py → common/utils.py} +168 -77
- ads/aqua/config/config.py +18 -0
- ads/aqua/constants.py +51 -33
- ads/aqua/data.py +15 -26
- ads/aqua/evaluation/__init__.py +8 -0
- ads/aqua/evaluation/constants.py +53 -0
- ads/aqua/evaluation/entities.py +170 -0
- ads/aqua/evaluation/errors.py +71 -0
- ads/aqua/{evaluation.py → evaluation/evaluation.py} +122 -370
- ads/aqua/extension/__init__.py +2 -0
- ads/aqua/extension/aqua_ws_msg_handler.py +97 -0
- ads/aqua/extension/base_handler.py +0 -7
- ads/aqua/extension/common_handler.py +12 -6
- ads/aqua/extension/deployment_handler.py +70 -4
- ads/aqua/extension/errors.py +10 -0
- ads/aqua/extension/evaluation_handler.py +5 -3
- ads/aqua/extension/evaluation_ws_msg_handler.py +43 -0
- ads/aqua/extension/finetune_handler.py +41 -3
- ads/aqua/extension/model_handler.py +56 -4
- ads/aqua/extension/models/__init__.py +0 -0
- ads/aqua/extension/models/ws_models.py +69 -0
- ads/aqua/extension/ui_handler.py +65 -4
- ads/aqua/extension/ui_websocket_handler.py +124 -0
- ads/aqua/extension/utils.py +1 -1
- ads/aqua/finetuning/__init__.py +7 -0
- ads/aqua/finetuning/constants.py +17 -0
- ads/aqua/finetuning/entities.py +102 -0
- ads/aqua/{finetune.py → finetuning/finetuning.py} +162 -136
- ads/aqua/model/__init__.py +8 -0
- ads/aqua/model/constants.py +46 -0
- ads/aqua/model/entities.py +266 -0
- ads/aqua/model/enums.py +26 -0
- ads/aqua/{model.py → model/model.py} +401 -309
- ads/aqua/modeldeployment/__init__.py +8 -0
- ads/aqua/modeldeployment/constants.py +26 -0
- ads/aqua/{deployment.py → modeldeployment/deployment.py} +288 -227
- ads/aqua/modeldeployment/entities.py +142 -0
- ads/aqua/modeldeployment/inference.py +75 -0
- ads/aqua/ui.py +88 -8
- ads/cli.py +55 -7
- ads/common/serializer.py +2 -2
- ads/config.py +2 -1
- ads/jobs/builders/infrastructure/dsc_job.py +49 -6
- ads/model/datascience_model.py +1 -1
- ads/model/deployment/model_deployment.py +11 -0
- ads/model/model_metadata.py +17 -6
- ads/opctl/operator/lowcode/anomaly/README.md +0 -2
- ads/opctl/operator/lowcode/anomaly/__main__.py +3 -3
- ads/opctl/operator/lowcode/anomaly/environment.yaml +0 -2
- ads/opctl/operator/lowcode/anomaly/model/automlx.py +2 -2
- ads/opctl/operator/lowcode/anomaly/model/autots.py +1 -1
- ads/opctl/operator/lowcode/anomaly/model/base_model.py +13 -17
- ads/opctl/operator/lowcode/anomaly/operator_config.py +2 -0
- ads/opctl/operator/lowcode/anomaly/schema.yaml +1 -2
- ads/opctl/operator/lowcode/anomaly/utils.py +3 -2
- ads/opctl/operator/lowcode/common/transformations.py +2 -1
- ads/opctl/operator/lowcode/common/utils.py +1 -1
- ads/opctl/operator/lowcode/forecast/README.md +1 -3
- ads/opctl/operator/lowcode/forecast/__main__.py +3 -18
- ads/opctl/operator/lowcode/forecast/const.py +2 -0
- ads/opctl/operator/lowcode/forecast/environment.yaml +1 -2
- ads/opctl/operator/lowcode/forecast/model/arima.py +1 -0
- ads/opctl/operator/lowcode/forecast/model/automlx.py +7 -4
- ads/opctl/operator/lowcode/forecast/model/autots.py +1 -0
- ads/opctl/operator/lowcode/forecast/model/base_model.py +38 -22
- ads/opctl/operator/lowcode/forecast/model/factory.py +33 -4
- ads/opctl/operator/lowcode/forecast/model/forecast_datasets.py +15 -1
- ads/opctl/operator/lowcode/forecast/model/ml_forecast.py +234 -0
- ads/opctl/operator/lowcode/forecast/model/neuralprophet.py +9 -1
- ads/opctl/operator/lowcode/forecast/model/prophet.py +1 -0
- ads/opctl/operator/lowcode/forecast/model_evaluator.py +147 -0
- ads/opctl/operator/lowcode/forecast/operator_config.py +2 -1
- ads/opctl/operator/lowcode/forecast/schema.yaml +7 -2
- ads/opctl/operator/lowcode/forecast/utils.py +18 -44
- {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.10.dist-info}/METADATA +9 -12
- {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.10.dist-info}/RECORD +86 -61
- ads/aqua/job.py +0 -29
- {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.10.dist-info}/LICENSE.txt +0 -0
- {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.10.dist-info}/WHEEL +0 -0
- {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.10.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# Copyright (c) 2024 Oracle and/or its affiliates.
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
5
|
+
import concurrent.futures
|
6
|
+
from asyncio.futures import Future
|
7
|
+
from concurrent.futures import ThreadPoolExecutor
|
8
|
+
from typing import Dict, List, Type, Union
|
9
|
+
|
10
|
+
import tornado
|
11
|
+
from tornado import httputil
|
12
|
+
from tornado.ioloop import IOLoop
|
13
|
+
from tornado.websocket import WebSocketHandler
|
14
|
+
|
15
|
+
from ads.aqua import logger
|
16
|
+
from ads.aqua.extension.aqua_ws_msg_handler import AquaWSMsgHandler
|
17
|
+
from ads.aqua.extension.evaluation_ws_msg_handler import AquaEvaluationWSMsgHandler
|
18
|
+
from ads.aqua.extension.models.ws_models import (
|
19
|
+
AquaWsError,
|
20
|
+
BaseRequest,
|
21
|
+
BaseResponse,
|
22
|
+
ErrorResponse,
|
23
|
+
RequestResponseType,
|
24
|
+
)
|
25
|
+
|
26
|
+
MAX_WORKERS = 20
|
27
|
+
|
28
|
+
|
29
|
+
def get_aqua_internal_error_response(message_id: str) -> ErrorResponse:
|
30
|
+
error = AquaWsError(
|
31
|
+
status="500",
|
32
|
+
message="Internal Server Error",
|
33
|
+
service_payload={},
|
34
|
+
reason="",
|
35
|
+
)
|
36
|
+
return ErrorResponse(
|
37
|
+
message_id=message_id,
|
38
|
+
kind=RequestResponseType.Error,
|
39
|
+
data=error,
|
40
|
+
)
|
41
|
+
|
42
|
+
|
43
|
+
class AquaUIWebSocketHandler(WebSocketHandler):
|
44
|
+
"""Handler for Aqua Websocket."""
|
45
|
+
|
46
|
+
_handlers_: List[Type[AquaWSMsgHandler]] = [AquaEvaluationWSMsgHandler]
|
47
|
+
|
48
|
+
thread_pool: ThreadPoolExecutor
|
49
|
+
|
50
|
+
future_message_map: Dict[Future, BaseRequest]
|
51
|
+
message_type_handler_map: Dict[RequestResponseType, Type[AquaWSMsgHandler]]
|
52
|
+
|
53
|
+
def __init__(
|
54
|
+
self,
|
55
|
+
application: tornado.web.Application,
|
56
|
+
request: httputil.HTTPServerRequest,
|
57
|
+
**kwargs,
|
58
|
+
):
|
59
|
+
# Create a mapping of message type to handler and check for duplicates
|
60
|
+
self.future_message_map = {}
|
61
|
+
self.message_type_handler_map = {}
|
62
|
+
for handler in self._handlers_:
|
63
|
+
for message_type in handler.get_message_types():
|
64
|
+
if message_type in self.message_type_handler_map:
|
65
|
+
raise ValueError(
|
66
|
+
f"Duplicate message type {message_type} in AQUA websocket handlers."
|
67
|
+
)
|
68
|
+
else:
|
69
|
+
self.message_type_handler_map[message_type] = handler
|
70
|
+
|
71
|
+
super().__init__(application, request, **kwargs)
|
72
|
+
|
73
|
+
def open(self, *args, **kwargs):
|
74
|
+
self.thread_pool = ThreadPoolExecutor(max_workers=MAX_WORKERS)
|
75
|
+
logger.info("AQUA WebSocket opened")
|
76
|
+
|
77
|
+
def on_message(self, message: Union[str, bytes]):
|
78
|
+
try:
|
79
|
+
request = BaseRequest.from_json(message, ignore_unknown=True)
|
80
|
+
except Exception as e:
|
81
|
+
logger.error(
|
82
|
+
f"Unable to parse WebSocket message {message}\nWith exception: {str(e)}"
|
83
|
+
)
|
84
|
+
raise e
|
85
|
+
# Find the handler for the message type.
|
86
|
+
# Each handler is responsible for some specific message types
|
87
|
+
handler = self.message_type_handler_map.get(request.kind, None)
|
88
|
+
if handler is None:
|
89
|
+
self.write_message(
|
90
|
+
get_aqua_internal_error_response(request.message_id).to_json()
|
91
|
+
)
|
92
|
+
raise ValueError(f"No handler found for message type {request.kind}")
|
93
|
+
else:
|
94
|
+
message_handler = handler(message)
|
95
|
+
future: Future = self.thread_pool.submit(message_handler.process)
|
96
|
+
self.future_message_map[future] = request
|
97
|
+
future.add_done_callback(self.on_message_processed)
|
98
|
+
|
99
|
+
def on_message_processed(self, future: concurrent.futures.Future):
|
100
|
+
"""Callback function to handle the response from the various AquaWSMsgHandlers."""
|
101
|
+
try:
|
102
|
+
response: BaseResponse = future.result()
|
103
|
+
|
104
|
+
# Any exception coming here is an unhandled exception in the handler. We should log it and return an internal server error.
|
105
|
+
# In non WebSocket scenarios this would be handled by the tornado webserver
|
106
|
+
except Exception as e:
|
107
|
+
logger.error(
|
108
|
+
f"Unable to handle WebSocket message {self.future_message_map[future]}\nWith exception: {str(e)}"
|
109
|
+
)
|
110
|
+
response: BaseResponse = get_aqua_internal_error_response(
|
111
|
+
self.future_message_map[future].message_id
|
112
|
+
)
|
113
|
+
raise e
|
114
|
+
finally:
|
115
|
+
self.future_message_map.pop(future)
|
116
|
+
# Send the response back to the client on the event thread
|
117
|
+
IOLoop.current().run_sync(lambda: self.write_message(response.to_json()))
|
118
|
+
|
119
|
+
def on_close(self) -> None:
|
120
|
+
self.thread_pool.shutdown()
|
121
|
+
logger.info("AQUA WebSocket closed")
|
122
|
+
|
123
|
+
|
124
|
+
__handlers__ = [("ws?([^/]*)", AquaUIWebSocketHandler)]
|
ads/aqua/extension/utils.py
CHANGED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# Copyright (c) 2024 Oracle and/or its affiliates.
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
5
|
+
from ads.aqua.finetuning.finetuning import AquaFineTuningApp
|
6
|
+
|
7
|
+
__all__ = ["AquaFineTuningApp"]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# Copyright (c) 2024 Oracle and/or its affiliates.
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
5
|
+
|
6
|
+
from ads.common.extended_enum import ExtendedEnumMeta
|
7
|
+
|
8
|
+
|
9
|
+
class FineTuneCustomMetadata(str, metaclass=ExtendedEnumMeta):
|
10
|
+
FINE_TUNE_SOURCE = "fine_tune_source"
|
11
|
+
FINE_TUNE_SOURCE_NAME = "fine_tune_source_name"
|
12
|
+
FINE_TUNE_OUTPUT_PATH = "fine_tune_output_path"
|
13
|
+
FINE_TUNE_JOB_ID = "fine_tune_job_id"
|
14
|
+
FINE_TUNE_JOB_RUN_ID = "fine_tune_job_run_id"
|
15
|
+
SERVICE_MODEL_ARTIFACT_LOCATION = "artifact_location"
|
16
|
+
SERVICE_MODEL_DEPLOYMENT_CONTAINER = "deployment-container"
|
17
|
+
SERVICE_MODEL_FINE_TUNE_CONTAINER = "finetune-container"
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# Copyright (c) 2024 Oracle and/or its affiliates.
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
5
|
+
from dataclasses import dataclass, field
|
6
|
+
from typing import List, Optional
|
7
|
+
|
8
|
+
from ads.aqua.data import AquaJobSummary
|
9
|
+
from ads.common.serializer import DataClassSerializable
|
10
|
+
|
11
|
+
|
12
|
+
@dataclass(repr=False)
|
13
|
+
class AquaFineTuningParams(DataClassSerializable):
|
14
|
+
epochs: int
|
15
|
+
learning_rate: Optional[float] = None
|
16
|
+
sample_packing: Optional[bool] = "auto"
|
17
|
+
batch_size: Optional[
|
18
|
+
int
|
19
|
+
] = None # make it batch_size for user, but internally this is micro_batch_size
|
20
|
+
sequence_len: Optional[int] = None
|
21
|
+
pad_to_sequence_len: Optional[bool] = None
|
22
|
+
lora_r: Optional[int] = None
|
23
|
+
lora_alpha: Optional[int] = None
|
24
|
+
lora_dropout: Optional[float] = None
|
25
|
+
lora_target_linear: Optional[bool] = None
|
26
|
+
lora_target_modules: Optional[List] = None
|
27
|
+
|
28
|
+
|
29
|
+
@dataclass(repr=False)
|
30
|
+
class AquaFineTuningSummary(AquaJobSummary, DataClassSerializable):
|
31
|
+
parameters: AquaFineTuningParams = field(default_factory=AquaFineTuningParams)
|
32
|
+
|
33
|
+
|
34
|
+
@dataclass(repr=False)
|
35
|
+
class CreateFineTuningDetails(DataClassSerializable):
|
36
|
+
"""Dataclass to create aqua model fine tuning.
|
37
|
+
|
38
|
+
Fields
|
39
|
+
------
|
40
|
+
ft_source_id: str
|
41
|
+
The fine tuning source id. Must be model ocid.
|
42
|
+
ft_name: str
|
43
|
+
The name for fine tuning.
|
44
|
+
dataset_path: str
|
45
|
+
The dataset path for fine tuning. Could be either a local path from notebook session
|
46
|
+
or an object storage path.
|
47
|
+
report_path: str
|
48
|
+
The report path for fine tuning. Must be an object storage path.
|
49
|
+
ft_parameters: dict
|
50
|
+
The parameters for fine tuning.
|
51
|
+
shape_name: str
|
52
|
+
The shape name for fine tuning job infrastructure.
|
53
|
+
replica: int
|
54
|
+
The replica for fine tuning job runtime.
|
55
|
+
validation_set_size: float
|
56
|
+
The validation set size for fine tuning job. Must be a float in between [0,1).
|
57
|
+
ft_description: (str, optional). Defaults to `None`.
|
58
|
+
The description for fine tuning.
|
59
|
+
compartment_id: (str, optional). Defaults to `None`.
|
60
|
+
The compartment id for fine tuning.
|
61
|
+
project_id: (str, optional). Defaults to `None`.
|
62
|
+
The project id for fine tuning.
|
63
|
+
experiment_id: (str, optional). Defaults to `None`.
|
64
|
+
The fine tuning model version set id. If provided,
|
65
|
+
fine tuning model will be associated with it.
|
66
|
+
experiment_name: (str, optional). Defaults to `None`.
|
67
|
+
The fine tuning model version set name. If provided,
|
68
|
+
the fine tuning version set with the same name will be used if exists,
|
69
|
+
otherwise a new model version set will be created with the name.
|
70
|
+
experiment_description: (str, optional). Defaults to `None`.
|
71
|
+
The description for fine tuning model version set.
|
72
|
+
block_storage_size: (int, optional). Defaults to 256.
|
73
|
+
The storage for fine tuning job infrastructure.
|
74
|
+
subnet_id: (str, optional). Defaults to `None`.
|
75
|
+
The custom egress for fine tuning job.
|
76
|
+
log_group_id: (str, optional). Defaults to `None`.
|
77
|
+
The log group id for fine tuning job infrastructure.
|
78
|
+
log_id: (str, optional). Defaults to `None`.
|
79
|
+
The log id for fine tuning job infrastructure.
|
80
|
+
force_overwrite: (bool, optional). Defaults to `False`.
|
81
|
+
Whether to force overwrite the existing file in object storage.
|
82
|
+
"""
|
83
|
+
|
84
|
+
ft_source_id: str
|
85
|
+
ft_name: str
|
86
|
+
dataset_path: str
|
87
|
+
report_path: str
|
88
|
+
ft_parameters: dict
|
89
|
+
shape_name: str
|
90
|
+
replica: int
|
91
|
+
validation_set_size: float
|
92
|
+
ft_description: Optional[str] = None
|
93
|
+
compartment_id: Optional[str] = None
|
94
|
+
project_id: Optional[str] = None
|
95
|
+
experiment_id: Optional[str] = None
|
96
|
+
experiment_name: Optional[str] = None
|
97
|
+
experiment_description: Optional[str] = None
|
98
|
+
block_storage_size: Optional[int] = None
|
99
|
+
subnet_id: Optional[str] = None
|
100
|
+
log_id: Optional[str] = None
|
101
|
+
log_group_id: Optional[str] = None
|
102
|
+
force_overwrite: Optional[bool] = False
|