oracle-ads 2.11.9__py3-none-any.whl → 2.11.11__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.
Files changed (88) hide show
  1. ads/aqua/__init__.py +1 -1
  2. ads/aqua/{base.py → app.py} +27 -7
  3. ads/aqua/cli.py +59 -17
  4. ads/aqua/common/__init__.py +5 -0
  5. ads/aqua/{decorator.py → common/decorator.py} +14 -8
  6. ads/aqua/common/enums.py +69 -0
  7. ads/aqua/{exception.py → common/errors.py} +28 -0
  8. ads/aqua/{utils.py → common/utils.py} +193 -95
  9. ads/aqua/config/config.py +18 -0
  10. ads/aqua/constants.py +51 -33
  11. ads/aqua/data.py +15 -26
  12. ads/aqua/evaluation/__init__.py +8 -0
  13. ads/aqua/evaluation/constants.py +53 -0
  14. ads/aqua/evaluation/entities.py +170 -0
  15. ads/aqua/evaluation/errors.py +71 -0
  16. ads/aqua/{evaluation.py → evaluation/evaluation.py} +122 -370
  17. ads/aqua/extension/__init__.py +2 -0
  18. ads/aqua/extension/aqua_ws_msg_handler.py +97 -0
  19. ads/aqua/extension/base_handler.py +0 -7
  20. ads/aqua/extension/common_handler.py +12 -6
  21. ads/aqua/extension/deployment_handler.py +70 -4
  22. ads/aqua/extension/errors.py +10 -0
  23. ads/aqua/extension/evaluation_handler.py +5 -3
  24. ads/aqua/extension/evaluation_ws_msg_handler.py +43 -0
  25. ads/aqua/extension/finetune_handler.py +41 -3
  26. ads/aqua/extension/model_handler.py +56 -4
  27. ads/aqua/extension/models/__init__.py +0 -0
  28. ads/aqua/extension/models/ws_models.py +69 -0
  29. ads/aqua/extension/ui_handler.py +65 -4
  30. ads/aqua/extension/ui_websocket_handler.py +124 -0
  31. ads/aqua/extension/utils.py +1 -1
  32. ads/aqua/finetuning/__init__.py +7 -0
  33. ads/aqua/finetuning/constants.py +17 -0
  34. ads/aqua/finetuning/entities.py +102 -0
  35. ads/aqua/{finetune.py → finetuning/finetuning.py} +170 -141
  36. ads/aqua/model/__init__.py +8 -0
  37. ads/aqua/model/constants.py +46 -0
  38. ads/aqua/model/entities.py +266 -0
  39. ads/aqua/model/enums.py +26 -0
  40. ads/aqua/{model.py → model/model.py} +405 -309
  41. ads/aqua/modeldeployment/__init__.py +8 -0
  42. ads/aqua/modeldeployment/constants.py +26 -0
  43. ads/aqua/{deployment.py → modeldeployment/deployment.py} +288 -227
  44. ads/aqua/modeldeployment/entities.py +142 -0
  45. ads/aqua/modeldeployment/inference.py +75 -0
  46. ads/aqua/ui.py +88 -8
  47. ads/cli.py +55 -7
  48. ads/common/decorator/threaded.py +97 -0
  49. ads/common/serializer.py +2 -2
  50. ads/config.py +5 -1
  51. ads/jobs/builders/infrastructure/dsc_job.py +49 -6
  52. ads/model/datascience_model.py +1 -1
  53. ads/model/deployment/model_deployment.py +11 -0
  54. ads/model/model_metadata.py +17 -6
  55. ads/opctl/operator/lowcode/anomaly/README.md +0 -2
  56. ads/opctl/operator/lowcode/anomaly/__main__.py +3 -3
  57. ads/opctl/operator/lowcode/anomaly/environment.yaml +0 -2
  58. ads/opctl/operator/lowcode/anomaly/model/automlx.py +2 -2
  59. ads/opctl/operator/lowcode/anomaly/model/autots.py +1 -1
  60. ads/opctl/operator/lowcode/anomaly/model/base_model.py +13 -17
  61. ads/opctl/operator/lowcode/anomaly/operator_config.py +2 -0
  62. ads/opctl/operator/lowcode/anomaly/schema.yaml +1 -2
  63. ads/opctl/operator/lowcode/anomaly/utils.py +3 -2
  64. ads/opctl/operator/lowcode/common/transformations.py +2 -1
  65. ads/opctl/operator/lowcode/common/utils.py +1 -1
  66. ads/opctl/operator/lowcode/forecast/README.md +1 -3
  67. ads/opctl/operator/lowcode/forecast/__main__.py +3 -18
  68. ads/opctl/operator/lowcode/forecast/const.py +2 -0
  69. ads/opctl/operator/lowcode/forecast/environment.yaml +1 -2
  70. ads/opctl/operator/lowcode/forecast/model/arima.py +1 -0
  71. ads/opctl/operator/lowcode/forecast/model/automlx.py +7 -4
  72. ads/opctl/operator/lowcode/forecast/model/autots.py +1 -0
  73. ads/opctl/operator/lowcode/forecast/model/base_model.py +38 -22
  74. ads/opctl/operator/lowcode/forecast/model/factory.py +33 -4
  75. ads/opctl/operator/lowcode/forecast/model/forecast_datasets.py +15 -1
  76. ads/opctl/operator/lowcode/forecast/model/ml_forecast.py +234 -0
  77. ads/opctl/operator/lowcode/forecast/model/neuralprophet.py +9 -1
  78. ads/opctl/operator/lowcode/forecast/model/prophet.py +1 -0
  79. ads/opctl/operator/lowcode/forecast/model_evaluator.py +147 -0
  80. ads/opctl/operator/lowcode/forecast/operator_config.py +2 -1
  81. ads/opctl/operator/lowcode/forecast/schema.yaml +7 -2
  82. ads/opctl/operator/lowcode/forecast/utils.py +18 -44
  83. {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.11.dist-info}/METADATA +9 -12
  84. {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.11.dist-info}/RECORD +87 -61
  85. ads/aqua/job.py +0 -29
  86. {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.11.dist-info}/LICENSE.txt +0 -0
  87. {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.11.dist-info}/WHEEL +0 -0
  88. {oracle_ads-2.11.9.dist-info → oracle_ads-2.11.11.dist-info}/entry_points.txt +0 -0
@@ -10,7 +10,6 @@ import logging
10
10
  import os
11
11
  import random
12
12
  import re
13
- from enum import Enum
14
13
  from functools import wraps
15
14
  from pathlib import Path
16
15
  from string import Template
@@ -20,64 +19,27 @@ import fsspec
20
19
  import oci
21
20
  from oci.data_science.models import JobRun, Model
22
21
 
23
- from ads.aqua.constants import RqsAdditionalDetails
22
+ from ads.aqua.common.enums import RqsAdditionalDetails
23
+ from ads.aqua.common.errors import (
24
+ AquaFileNotFoundError,
25
+ AquaRuntimeError,
26
+ AquaValueError,
27
+ )
28
+ from ads.aqua.constants import *
24
29
  from ads.aqua.data import AquaResourceIdentifier
25
- from ads.aqua.exception import AquaFileNotFoundError, AquaRuntimeError, AquaValueError
26
30
  from ads.common.auth import default_signer
31
+ from ads.common.decorator.threaded import threaded
32
+ from ads.common.extended_enum import ExtendedEnumMeta
27
33
  from ads.common.object_storage_details import ObjectStorageDetails
28
34
  from ads.common.oci_resource import SEARCH_TYPE, OCIResource
29
- from ads.common.utils import get_console_link, upload_to_os
35
+ from ads.common.utils import copy_file, get_console_link, upload_to_os
30
36
  from ads.config import AQUA_SERVICE_MODELS_BUCKET, CONDA_BUCKET_NS, TENANCY_OCID
31
37
  from ads.model import DataScienceModel, ModelVersionSet
32
38
 
33
39
  logger = logging.getLogger("ads.aqua")
34
40
 
35
- UNKNOWN = ""
36
- UNKNOWN_DICT = {}
37
- README = "README.md"
38
- LICENSE_TXT = "config/LICENSE.txt"
39
- DEPLOYMENT_CONFIG = "deployment_config.json"
40
- COMPARTMENT_MAPPING_KEY = "service-model-compartment"
41
- CONTAINER_INDEX = "container_index.json"
42
- EVALUATION_REPORT_JSON = "report.json"
43
- EVALUATION_REPORT_MD = "report.md"
44
- EVALUATION_REPORT = "report.html"
45
- UNKNOWN_JSON_STR = "{}"
46
- CONSOLE_LINK_RESOURCE_TYPE_MAPPING = dict(
47
- datasciencemodel="models",
48
- datasciencemodeldeployment="model-deployments",
49
- datasciencemodeldeploymentdev="model-deployments",
50
- datasciencemodeldeploymentint="model-deployments",
51
- datasciencemodeldeploymentpre="model-deployments",
52
- datasciencejob="jobs",
53
- datasciencejobrun="job-runs",
54
- datasciencejobrundev="job-runs",
55
- datasciencejobrunint="job-runs",
56
- datasciencejobrunpre="job-runs",
57
- datasciencemodelversionset="model-version-sets",
58
- datasciencemodelversionsetpre="model-version-sets",
59
- datasciencemodelversionsetint="model-version-sets",
60
- datasciencemodelversionsetdev="model-version-sets",
61
- )
62
- FINE_TUNING_RUNTIME_CONTAINER = "iad.ocir.io/ociodscdev/aqua_ft_cuda121:0.3.17.20"
63
- DEFAULT_FT_BLOCK_STORAGE_SIZE = 750
64
- DEFAULT_FT_REPLICA = 1
65
- DEFAULT_FT_BATCH_SIZE = 1
66
- DEFAULT_FT_VALIDATION_SET_SIZE = 0.1
67
-
68
- HF_MODELS = "/home/datascience/conda/pytorch21_p39_gpu_v1/"
69
- MAXIMUM_ALLOWED_DATASET_IN_BYTE = 52428800 # 1024 x 1024 x 50 = 50MB
70
- JOB_INFRASTRUCTURE_TYPE_DEFAULT_NETWORKING = "ME_STANDALONE"
71
- NB_SESSION_IDENTIFIER = "NB_SESSION_OCID"
72
- LIFECYCLE_DETAILS_MISSING_JOBRUN = "The asscociated JobRun resource has been deleted."
73
- READY_TO_DEPLOY_STATUS = "ACTIVE"
74
- READY_TO_FINE_TUNE_STATUS = "TRUE"
75
- AQUA_GA_LIST = ["id19sfcrra6z"]
76
- AQUA_MODEL_TYPE_SERVICE = "service"
77
- AQUA_MODEL_TYPE_CUSTOM = "custom"
78
-
79
-
80
- class LifecycleStatus(Enum):
41
+
42
+ class LifecycleStatus(str, metaclass=ExtendedEnumMeta):
81
43
  UNKNOWN = ""
82
44
 
83
45
  @property
@@ -136,8 +98,6 @@ LIFECYCLE_DETAILS_MAPPING = {
136
98
  JobRun.LIFECYCLE_STATE_FAILED: "The evaluation failed.",
137
99
  JobRun.LIFECYCLE_STATE_NEEDS_ATTENTION: "Missing jobrun information.",
138
100
  }
139
- SUPPORTED_FILE_FORMATS = ["jsonl"]
140
- MODEL_BY_REFERENCE_OSS_PATH_KEY = "artifact_location"
141
101
 
142
102
 
143
103
  def random_color_generator(word: str):
@@ -201,22 +161,28 @@ def get_artifact_path(custom_metadata_list: List) -> str:
201
161
  Parameters
202
162
  ----------
203
163
  custom_metadata_list: List
204
- A list of custom metadata of model.
164
+ A list of custom metadata of OCI model.
205
165
 
206
166
  Returns
207
167
  -------
208
168
  str:
209
169
  The artifact path from model.
210
170
  """
211
- for custom_metadata in custom_metadata_list:
212
- if custom_metadata.key == MODEL_BY_REFERENCE_OSS_PATH_KEY:
213
- if ObjectStorageDetails.is_oci_path(custom_metadata.value):
214
- artifact_path = custom_metadata.value
215
- else:
216
- artifact_path = ObjectStorageDetails(
217
- AQUA_SERVICE_MODELS_BUCKET, CONDA_BUCKET_NS, custom_metadata.value
218
- ).path
219
- return artifact_path
171
+ try:
172
+ for custom_metadata in custom_metadata_list:
173
+ if custom_metadata.key == MODEL_BY_REFERENCE_OSS_PATH_KEY:
174
+ if ObjectStorageDetails.is_oci_path(custom_metadata.value):
175
+ artifact_path = custom_metadata.value
176
+ else:
177
+ artifact_path = ObjectStorageDetails(
178
+ AQUA_SERVICE_MODELS_BUCKET,
179
+ CONDA_BUCKET_NS,
180
+ custom_metadata.value,
181
+ ).path
182
+ return artifact_path
183
+ except Exception as ex:
184
+ logger.debug(ex)
185
+
220
186
  logger.debug("Failed to get artifact path from custom metadata.")
221
187
  return UNKNOWN
222
188
 
@@ -230,6 +196,7 @@ def read_file(file_path: str, **kwargs) -> str:
230
196
  return UNKNOWN
231
197
 
232
198
 
199
+ @threaded()
233
200
  def load_config(file_path: str, config_file_name: str, **kwargs) -> dict:
234
201
  artifact_path = f"{file_path.rstrip('/')}/{config_file_name}"
235
202
  if artifact_path.startswith("oci://"):
@@ -260,12 +227,10 @@ def is_valid_ocid(ocid: str) -> bool:
260
227
  bool:
261
228
  Whether the given ocid is valid.
262
229
  """
263
- # TODO: revisit pattern
264
- pattern = (
265
- r"^ocid1\.([a-z0-9_]+)\.([a-z0-9]+)\.([a-z0-9-]*)(\.[^.]+)?\.([a-z0-9_]+)$"
266
- )
267
- match = re.match(pattern, ocid)
268
- return True
230
+
231
+ if not ocid:
232
+ return False
233
+ return ocid.lower().startswith("ocid")
269
234
 
270
235
 
271
236
  def get_resource_type(ocid: str) -> str:
@@ -520,6 +485,19 @@ def _build_job_identifier(
520
485
  return AquaResourceIdentifier()
521
486
 
522
487
 
488
+ def container_config_path():
489
+ return f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"
490
+
491
+
492
+ def get_container_config():
493
+ config = load_config(
494
+ file_path=container_config_path(),
495
+ config_file_name=CONTAINER_INDEX,
496
+ )
497
+
498
+ return config
499
+
500
+
523
501
  def get_container_image(
524
502
  config_file_name: str = None, container_type: str = None
525
503
  ) -> str:
@@ -537,14 +515,8 @@ def get_container_image(
537
515
  A dict of allowed configs.
538
516
  """
539
517
 
540
- config_file_name = (
541
- f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"
542
- )
543
-
544
- config = load_config(
545
- file_path=config_file_name,
546
- config_file_name=CONTAINER_INDEX,
547
- )
518
+ config = config_file_name or get_container_config()
519
+ config_file_name = container_config_path()
548
520
 
549
521
  if container_type not in config:
550
522
  raise AquaValueError(
@@ -570,8 +542,10 @@ def get_container_image(
570
542
 
571
543
 
572
544
  def fetch_service_compartment() -> Union[str, None]:
573
- """Loads the compartment mapping json from service bucket. This json file has a service-model-compartment key which
574
- contains a dictionary of namespaces and the compartment OCID of the service models in that namespace.
545
+ """
546
+ Loads the compartment mapping json from service bucket.
547
+ This json file has a service-model-compartment key which contains a dictionary of namespaces
548
+ and the compartment OCID of the service models in that namespace.
575
549
  """
576
550
  config_file_name = (
577
551
  f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"
@@ -583,9 +557,9 @@ def fetch_service_compartment() -> Union[str, None]:
583
557
  config_file_name=CONTAINER_INDEX,
584
558
  )
585
559
  except Exception as e:
586
- logger.error(
587
- f"Config file {config_file_name}/{CONTAINER_INDEX} to fetch service compartment OCID could not be found. "
588
- f"\n{str(e)}."
560
+ logger.debug(
561
+ f"Config file {config_file_name}/{CONTAINER_INDEX} to fetch service compartment OCID "
562
+ f"could not be found. \n{str(e)}."
589
563
  )
590
564
  return
591
565
  compartment_mapping = config.get(COMPARTMENT_MAPPING_KEY)
@@ -694,23 +668,26 @@ def get_model_by_reference_paths(model_file_description: dict):
694
668
  fine_tune_output_path = UNKNOWN
695
669
  models = model_file_description["models"]
696
670
 
697
- for model in models:
698
- namespace, bucket_name, prefix = (
699
- model["namespace"],
700
- model["bucketName"],
701
- model["prefix"],
671
+ if not models:
672
+ raise AquaValueError(
673
+ f"Model path is not available in the model json artifact. "
674
+ f"Please check if the model created by reference has the correct artifact."
702
675
  )
703
- bucket_uri = f"oci://{bucket_name}@{namespace}/{prefix}".rstrip("/")
704
- if bucket_name == AQUA_SERVICE_MODELS_BUCKET:
705
- base_model_path = bucket_uri
706
- else:
707
- fine_tune_output_path = bucket_uri
708
676
 
709
- if not base_model_path:
710
- raise AquaValueError(
711
- f"Base Model should come from the bucket {AQUA_SERVICE_MODELS_BUCKET}. "
712
- f"Other paths are not supported by Aqua."
677
+ if len(models) > 0:
678
+ # since the model_file_description json does not have a flag to identify the base model, we consider
679
+ # the first instance to be the base model.
680
+ base_model_artifact = models[0]
681
+ base_model_path = f"oci://{base_model_artifact['bucketName']}@{base_model_artifact['namespace']}/{base_model_artifact['prefix']}".rstrip(
682
+ "/"
683
+ )
684
+ if len(models) > 1:
685
+ # second model is considered as fine-tuned model
686
+ ft_model_artifact = models[1]
687
+ fine_tune_output_path = f"oci://{ft_model_artifact['bucketName']}@{ft_model_artifact['namespace']}/{ft_model_artifact['prefix']}".rstrip(
688
+ "/"
713
689
  )
690
+
714
691
  return base_model_path, fine_tune_output_path
715
692
 
716
693
 
@@ -750,3 +727,124 @@ def get_ocid_substring(ocid: str, key_len: int) -> str:
750
727
  """This helper function returns the last n characters of the ocid specified by key_len parameter.
751
728
  If ocid is None or length is less than key_len, it returns an empty string."""
752
729
  return ocid[-key_len:] if ocid and len(ocid) > key_len else ""
730
+
731
+
732
+ def is_service_managed_container(container):
733
+ return container and container.startswith(SERVICE_MANAGED_CONTAINER_URI_SCHEME)
734
+
735
+
736
+ def get_params_list(params: str) -> List[str]:
737
+ """Parses the string parameter and returns a list of params.
738
+
739
+ Parameters
740
+ ----------
741
+ params
742
+ string parameters by separated by -- delimiter
743
+
744
+ Returns
745
+ -------
746
+ list of params
747
+
748
+ """
749
+ if not params:
750
+ return []
751
+ return ["--" + param.strip() for param in params.split("--")[1:]]
752
+
753
+
754
+ def get_params_dict(params: Union[str, List[str]]) -> dict:
755
+ """Accepts a string or list of string of double-dash parameters and returns a dict with the parameter keys and values.
756
+
757
+ Parameters
758
+ ----------
759
+ params:
760
+ List of parameters or parameter string separated by space.
761
+
762
+ Returns
763
+ -------
764
+ dict containing parameter keys and values
765
+
766
+ """
767
+ params_list = get_params_list(params) if isinstance(params, str) else params
768
+ return {
769
+ split_result[0]: split_result[1] if len(split_result) > 1 else UNKNOWN
770
+ for split_result in (x.split() for x in params_list)
771
+ }
772
+
773
+
774
+ def get_combined_params(params1: str = None, params2: str = None) -> str:
775
+ """
776
+ Combines string of double-dash parameters, and overrides the values from the second string in the first.
777
+ Parameters
778
+ ----------
779
+ params1:
780
+ Parameter string with values
781
+ params2:
782
+ Parameter string with values that need to be overridden.
783
+
784
+ Returns
785
+ -------
786
+ A combined list with overridden values from params2.
787
+ """
788
+ if not params1:
789
+ return params2
790
+ if not params2:
791
+ return params1
792
+
793
+ # overwrite values from params2 into params1
794
+ combined_params = [
795
+ f"{key} {value}" if value else key
796
+ for key, value in {
797
+ **get_params_dict(params1),
798
+ **get_params_dict(params2),
799
+ }.items()
800
+ ]
801
+
802
+ return " ".join(combined_params)
803
+
804
+
805
+ def copy_model_config(artifact_path: str, os_path: str, auth: dict = None):
806
+ """Copies the aqua model config folder from the artifact path to the user provided object storage path.
807
+ The config folder is overwritten if the files already exist at the destination path.
808
+
809
+ Parameters
810
+ ----------
811
+ artifact_path:
812
+ Path of the aqua model where config folder is available.
813
+ os_path:
814
+ User provided path where config folder will be copied.
815
+ auth: (Dict, optional). Defaults to None.
816
+ The default authentication is set using `ads.set_auth` API. If you need to override the
817
+ default, use the `ads.common.auth.api_keys` or `ads.common.auth.resource_principal` to create appropriate
818
+ authentication signer and kwargs required to instantiate IdentityClient object.
819
+
820
+ Returns
821
+ -------
822
+ None
823
+ Nothing.
824
+ """
825
+
826
+ try:
827
+ source_dir = ObjectStorageDetails(
828
+ AQUA_SERVICE_MODELS_BUCKET,
829
+ CONDA_BUCKET_NS,
830
+ f"{os.path.dirname(artifact_path).rstrip('/')}/config",
831
+ ).path
832
+ dest_dir = f"{os_path.rstrip('/')}/config"
833
+
834
+ oss_details = ObjectStorageDetails.from_path(source_dir)
835
+ objects = oss_details.list_objects(fields="name").objects
836
+
837
+ for obj in objects:
838
+ source_path = ObjectStorageDetails(
839
+ AQUA_SERVICE_MODELS_BUCKET, CONDA_BUCKET_NS, obj.name
840
+ ).path
841
+ destination_path = os.path.join(dest_dir, os.path.basename(obj.name))
842
+ copy_file(
843
+ uri_src=source_path,
844
+ uri_dst=destination_path,
845
+ force_overwrite=True,
846
+ auth=auth,
847
+ )
848
+ except Exception as ex:
849
+ logger.debug(ex)
850
+ logger.debug(f"Failed to copy config folder from {artifact_path} to {os_path}.")
@@ -0,0 +1,18 @@
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
+
7
+ # TODO: move this to global config.json in object storage
8
+ def get_finetuning_config_defaults():
9
+ """Generate and return the fine-tuning default configuration dictionary."""
10
+ return {
11
+ "shape": {
12
+ "VM.GPU.A10.1": {"batch_size": 1, "replica": "1-10"},
13
+ "VM.GPU.A10.2": {"batch_size": 1, "replica": "1-10"},
14
+ "BM.GPU.A10.4": {"batch_size": 1, "replica": 1},
15
+ "BM.GPU4.8": {"batch_size": 4, "replica": 1},
16
+ "BM.GPU.A100-v2.8": {"batch_size": 6, "replica": 1},
17
+ }
18
+ }
ads/aqua/constants.py CHANGED
@@ -3,43 +3,61 @@
3
3
  # Copyright (c) 2024 Oracle and/or its affiliates.
4
4
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
5
  """This module defines constants used in ads.aqua module."""
6
- from enum import Enum
7
6
 
7
+ UNKNOWN = ""
8
8
  UNKNOWN_VALUE = ""
9
-
10
-
11
- class RqsAdditionalDetails:
12
- METADATA = "metadata"
13
- CREATED_BY = "createdBy"
14
- DESCRIPTION = "description"
15
- MODEL_VERSION_SET_ID = "modelVersionSetId"
16
- MODEL_VERSION_SET_NAME = "modelVersionSetName"
17
- PROJECT_ID = "projectId"
18
- VERSION_LABEL = "versionLabel"
19
-
20
-
21
- class FineTuningDefinedMetadata(Enum):
22
- """Represents the defined metadata keys used in Fine Tuning."""
23
-
24
- VAL_SET_SIZE = "val_set_size"
25
- TRAINING_DATA = "training_data"
26
-
27
-
28
- class FineTuningCustomMetadata(Enum):
29
- """Represents the custom metadata keys used in Fine Tuning."""
30
-
31
- FT_SOURCE = "fine_tune_source"
32
- FT_SOURCE_NAME = "fine_tune_source_name"
33
- FT_OUTPUT_PATH = "fine_tune_output_path"
34
- FT_JOB_ID = "fine_tune_job_id"
35
- FT_JOB_RUN_ID = "fine_tune_jobrun_id"
36
- TRAINING_METRICS_FINAL = "train_metrics_final"
37
- VALIDATION_METRICS_FINAL = "val_metrics_final"
38
- TRAINING_METRICS_EPOCH = "train_metrics_epoch"
39
- VALIDATION_METRICS_EPOCH = "val_metrics_epoch"
40
-
9
+ READY_TO_IMPORT_STATUS = "TRUE"
10
+ UNKNOWN_DICT = {}
11
+ README = "README.md"
12
+ LICENSE_TXT = "config/LICENSE.txt"
13
+ DEPLOYMENT_CONFIG = "deployment_config.json"
14
+ COMPARTMENT_MAPPING_KEY = "service-model-compartment"
15
+ CONTAINER_INDEX = "container_index.json"
16
+ EVALUATION_REPORT_JSON = "report.json"
17
+ EVALUATION_REPORT_MD = "report.md"
18
+ EVALUATION_REPORT = "report.html"
19
+ UNKNOWN_JSON_STR = "{}"
20
+ FINE_TUNING_RUNTIME_CONTAINER = "iad.ocir.io/ociodscdev/aqua_ft_cuda121:0.3.17.20"
21
+ DEFAULT_FT_BLOCK_STORAGE_SIZE = 750
22
+ DEFAULT_FT_REPLICA = 1
23
+ DEFAULT_FT_BATCH_SIZE = 1
24
+ DEFAULT_FT_VALIDATION_SET_SIZE = 0.1
25
+
26
+ MAXIMUM_ALLOWED_DATASET_IN_BYTE = 52428800 # 1024 x 1024 x 50 = 50MB
27
+ JOB_INFRASTRUCTURE_TYPE_DEFAULT_NETWORKING = "ME_STANDALONE"
28
+ NB_SESSION_IDENTIFIER = "NB_SESSION_OCID"
29
+ LIFECYCLE_DETAILS_MISSING_JOBRUN = "The asscociated JobRun resource has been deleted."
30
+ READY_TO_DEPLOY_STATUS = "ACTIVE"
31
+ READY_TO_FINE_TUNE_STATUS = "TRUE"
32
+ AQUA_GA_LIST = ["id19sfcrra6z"]
33
+ AQUA_MODEL_TYPE_SERVICE = "service"
34
+ AQUA_MODEL_TYPE_CUSTOM = "custom"
35
+ AQUA_MODEL_ARTIFACT_CONFIG = "config.json"
36
+ AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME = "_name_or_path"
37
+ AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE = "model_type"
41
38
 
42
39
  TRAINING_METRICS_FINAL = "training_metrics_final"
43
40
  VALIDATION_METRICS_FINAL = "validation_metrics_final"
44
41
  TRINING_METRICS = "training_metrics"
45
42
  VALIDATION_METRICS = "validation_metrics"
43
+
44
+ SERVICE_MANAGED_CONTAINER_URI_SCHEME = "dsmc://"
45
+ SUPPORTED_FILE_FORMATS = ["jsonl"]
46
+ MODEL_BY_REFERENCE_OSS_PATH_KEY = "artifact_location"
47
+
48
+ CONSOLE_LINK_RESOURCE_TYPE_MAPPING = dict(
49
+ datasciencemodel="models",
50
+ datasciencemodeldeployment="model-deployments",
51
+ datasciencemodeldeploymentdev="model-deployments",
52
+ datasciencemodeldeploymentint="model-deployments",
53
+ datasciencemodeldeploymentpre="model-deployments",
54
+ datasciencejob="jobs",
55
+ datasciencejobrun="job-runs",
56
+ datasciencejobrundev="job-runs",
57
+ datasciencejobrunint="job-runs",
58
+ datasciencejobrunpre="job-runs",
59
+ datasciencemodelversionset="model-version-sets",
60
+ datasciencemodelversionsetpre="model-version-sets",
61
+ datasciencemodelversionsetint="model-version-sets",
62
+ datasciencemodelversionsetdev="model-version-sets",
63
+ )
ads/aqua/data.py CHANGED
@@ -3,8 +3,7 @@
3
3
  # Copyright (c) 2024 Oracle and/or its affiliates.
4
4
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
5
 
6
- from dataclasses import dataclass
7
- from enum import Enum
6
+ from dataclasses import dataclass, field
8
7
 
9
8
  from ads.common.serializer import DataClassSerializable
10
9
 
@@ -16,27 +15,17 @@ class AquaResourceIdentifier(DataClassSerializable):
16
15
  url: str = ""
17
16
 
18
17
 
19
- class Resource(Enum):
20
- JOB = "jobs"
21
- JOBRUN = "jobruns"
22
- MODEL = "models"
23
- MODEL_DEPLOYMENT = "modeldeployments"
24
- MODEL_VERSION_SET = "model-version-sets"
25
-
26
-
27
- class DataScienceResource(Enum):
28
- MODEL_DEPLOYMENT = "datasciencemodeldeployment"
29
- MODEL = "datasciencemodel"
30
-
31
-
32
- class Tags(Enum):
33
- TASK = "task"
34
- LICENSE = "license"
35
- ORGANIZATION = "organization"
36
- AQUA_TAG = "OCI_AQUA"
37
- AQUA_SERVICE_MODEL_TAG = "aqua_service_model"
38
- AQUA_FINE_TUNED_MODEL_TAG = "aqua_fine_tuned_model"
39
- AQUA_MODEL_NAME_TAG = "aqua_model_name"
40
- AQUA_EVALUATION = "aqua_evaluation"
41
- AQUA_FINE_TUNING = "aqua_finetuning"
42
- READY_TO_FINE_TUNE = "ready_to_fine_tune"
18
+ @dataclass(repr=False)
19
+ class AquaJobSummary(DataClassSerializable):
20
+ """Represents an Aqua job summary."""
21
+
22
+ id: str
23
+ name: str
24
+ console_url: str
25
+ lifecycle_state: str
26
+ lifecycle_details: str
27
+ time_created: str
28
+ tags: dict
29
+ experiment: AquaResourceIdentifier = field(default_factory=AquaResourceIdentifier)
30
+ source: AquaResourceIdentifier = field(default_factory=AquaResourceIdentifier)
31
+ job: AquaResourceIdentifier = field(default_factory=AquaResourceIdentifier)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*--
3
+
4
+ # Copyright (c) 2024 Oracle and/or its affiliates.
5
+ # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6
+ from ads.aqua.evaluation.evaluation import AquaEvaluationApp
7
+
8
+ __all__ = ["AquaEvaluationApp"]
@@ -0,0 +1,53 @@
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
+ """
7
+ aqua.evaluation.const
8
+ ~~~~~~~~~~~~~~
9
+
10
+ This module contains constants/enums used in Aqua Evaluation.
11
+ """
12
+ from oci.data_science.models import JobRun
13
+
14
+ from ads.common.extended_enum import ExtendedEnumMeta
15
+
16
+ EVAL_TERMINATION_STATE = [
17
+ JobRun.LIFECYCLE_STATE_SUCCEEDED,
18
+ JobRun.LIFECYCLE_STATE_FAILED,
19
+ ]
20
+
21
+
22
+ class EvaluationCustomMetadata(str, metaclass=ExtendedEnumMeta):
23
+ EVALUATION_SOURCE = "evaluation_source"
24
+ EVALUATION_JOB_ID = "evaluation_job_id"
25
+ EVALUATION_JOB_RUN_ID = "evaluation_job_run_id"
26
+ EVALUATION_OUTPUT_PATH = "evaluation_output_path"
27
+ EVALUATION_SOURCE_NAME = "evaluation_source_name"
28
+ EVALUATION_ERROR = "aqua_evaluate_error"
29
+
30
+
31
+ class EvaluationConfig(str, metaclass=ExtendedEnumMeta):
32
+ PARAMS = "model_params"
33
+
34
+
35
+ class EvaluationReportJson(str, metaclass=ExtendedEnumMeta):
36
+ """Contains evaluation report.json fields name."""
37
+
38
+ METRIC_SUMMARY_RESULT = "metric_summary_result"
39
+ METRIC_RESULT = "metric_results"
40
+ MODEL_PARAMS = "model_params"
41
+ MODEL_DETAILS = "model_details"
42
+ DATA = "data"
43
+ DATASET = "dataset"
44
+
45
+
46
+ class EvaluationMetricResult(str, metaclass=ExtendedEnumMeta):
47
+ """Contains metric result's fields name in report.json."""
48
+
49
+ SHORT_NAME = "key"
50
+ NAME = "name"
51
+ DESCRIPTION = "description"
52
+ SUMMARY_DATA = "summary_data"
53
+ DATA = "data"