oracle-ads 2.13.1rc0__py3-none-any.whl → 2.13.2rc1__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 (58) hide show
  1. ads/aqua/__init__.py +7 -1
  2. ads/aqua/app.py +24 -23
  3. ads/aqua/client/client.py +48 -11
  4. ads/aqua/common/entities.py +28 -1
  5. ads/aqua/common/enums.py +13 -7
  6. ads/aqua/common/utils.py +8 -13
  7. ads/aqua/config/container_config.py +203 -0
  8. ads/aqua/config/evaluation/evaluation_service_config.py +5 -181
  9. ads/aqua/constants.py +0 -1
  10. ads/aqua/evaluation/evaluation.py +4 -4
  11. ads/aqua/extension/base_handler.py +4 -0
  12. ads/aqua/extension/model_handler.py +19 -28
  13. ads/aqua/finetuning/finetuning.py +2 -3
  14. ads/aqua/model/entities.py +2 -3
  15. ads/aqua/model/model.py +25 -30
  16. ads/aqua/modeldeployment/deployment.py +6 -14
  17. ads/aqua/modeldeployment/entities.py +2 -2
  18. ads/aqua/server/__init__.py +4 -0
  19. ads/aqua/server/__main__.py +24 -0
  20. ads/aqua/server/app.py +47 -0
  21. ads/aqua/server/aqua_spec.yml +1291 -0
  22. ads/aqua/ui.py +5 -199
  23. ads/common/auth.py +20 -11
  24. ads/common/utils.py +91 -11
  25. ads/config.py +3 -0
  26. ads/llm/__init__.py +1 -0
  27. ads/llm/langchain/plugins/llms/oci_data_science_model_deployment_endpoint.py +32 -23
  28. ads/model/artifact_downloader.py +4 -1
  29. ads/model/common/utils.py +15 -3
  30. ads/model/datascience_model.py +339 -8
  31. ads/model/model_metadata.py +54 -14
  32. ads/model/model_version_set.py +5 -3
  33. ads/model/service/oci_datascience_model.py +477 -5
  34. ads/opctl/operator/common/utils.py +16 -0
  35. ads/opctl/operator/lowcode/anomaly/model/base_model.py +3 -3
  36. ads/opctl/operator/lowcode/anomaly/model/randomcutforest.py +1 -1
  37. ads/opctl/operator/lowcode/anomaly/utils.py +1 -1
  38. ads/opctl/operator/lowcode/common/data.py +5 -2
  39. ads/opctl/operator/lowcode/common/transformations.py +7 -13
  40. ads/opctl/operator/lowcode/common/utils.py +7 -2
  41. ads/opctl/operator/lowcode/forecast/model/arima.py +15 -10
  42. ads/opctl/operator/lowcode/forecast/model/automlx.py +39 -9
  43. ads/opctl/operator/lowcode/forecast/model/autots.py +7 -5
  44. ads/opctl/operator/lowcode/forecast/model/base_model.py +135 -110
  45. ads/opctl/operator/lowcode/forecast/model/forecast_datasets.py +30 -14
  46. ads/opctl/operator/lowcode/forecast/model/ml_forecast.py +2 -2
  47. ads/opctl/operator/lowcode/forecast/model/neuralprophet.py +46 -32
  48. ads/opctl/operator/lowcode/forecast/model/prophet.py +82 -29
  49. ads/opctl/operator/lowcode/forecast/model_evaluator.py +142 -62
  50. ads/opctl/operator/lowcode/forecast/operator_config.py +29 -3
  51. ads/opctl/operator/lowcode/forecast/schema.yaml +1 -1
  52. ads/opctl/operator/lowcode/forecast/whatifserve/deployment_manager.py +108 -56
  53. {oracle_ads-2.13.1rc0.dist-info → oracle_ads-2.13.2rc1.dist-info}/METADATA +15 -12
  54. {oracle_ads-2.13.1rc0.dist-info → oracle_ads-2.13.2rc1.dist-info}/RECORD +57 -53
  55. {oracle_ads-2.13.1rc0.dist-info → oracle_ads-2.13.2rc1.dist-info}/WHEEL +1 -1
  56. ads/aqua/config/evaluation/evaluation_service_model_config.py +0 -8
  57. {oracle_ads-2.13.1rc0.dist-info → oracle_ads-2.13.2rc1.dist-info}/entry_points.txt +0 -0
  58. {oracle_ads-2.13.1rc0.dist-info → oracle_ads-2.13.2rc1.dist-info/licenses}/LICENSE.txt +0 -0
@@ -4,9 +4,10 @@
4
4
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
5
 
6
6
  import logging
7
+ from dataclasses import dataclass
7
8
  from functools import wraps
8
9
  from io import BytesIO
9
- from typing import Callable, Dict, List, Optional
10
+ from typing import Callable, Dict, List, Optional, Union
10
11
 
11
12
  import oci.data_science
12
13
  from oci.data_science.models import (
@@ -18,13 +19,18 @@ from oci.data_science.models import (
18
19
  UpdateModelDetails,
19
20
  )
20
21
  from oci.exceptions import ServiceError
22
+ from requests.structures import CaseInsensitiveDict
21
23
 
24
+ from ads.common import utils
25
+ from ads.common.auth import default_signer
22
26
  from ads.common.object_storage_details import ObjectStorageDetails
23
27
  from ads.common.oci_datascience import OCIDataScienceMixin
24
28
  from ads.common.oci_mixin import OCIWorkRequestMixin
25
29
  from ads.common.oci_resource import SEARCH_TYPE, OCIResource
26
- from ads.common.utils import extract_region
30
+ from ads.common.serializer import DataClassSerializable
31
+ from ads.common.utils import extract_region, read_file, text_sanitizer
27
32
  from ads.common.work_request import DataScienceWorkRequest
33
+ from ads.model.common.utils import MetadataArtifactPathType
28
34
  from ads.model.deployment import ModelDeployment
29
35
 
30
36
  logger = logging.getLogger(__name__)
@@ -54,6 +60,21 @@ class ModelWithActiveDeploymentError(Exception): # pragma: no cover
54
60
  pass
55
61
 
56
62
 
63
+ class ModelMetadataArtifactNotFoundError(Exception): # pragma: no cover
64
+ def __init__(self, model_ocid, metadata_key: str):
65
+ super().__init__(
66
+ f"The model {model_ocid} does not contain the metadata with key {metadata_key}."
67
+ )
68
+
69
+
70
+ @dataclass(repr=False)
71
+ class ModelMetadataArtifactDetails(DataClassSerializable):
72
+ """Represents a details of Model Metadata ."""
73
+
74
+ headers: Union[Dict, CaseInsensitiveDict]
75
+ status: str
76
+
77
+
57
78
  def check_for_model_id(msg: str = MODEL_NEEDS_TO_BE_SAVED):
58
79
  """The decorator helping to check if the ID attribute sepcified for a datascience model.
59
80
 
@@ -86,6 +107,12 @@ def check_for_model_id(msg: str = MODEL_NEEDS_TO_BE_SAVED):
86
107
  return decorator
87
108
 
88
109
 
110
+ def convert_model_metadata_response(
111
+ headers: Union[Dict, CaseInsensitiveDict], status: int
112
+ ) -> ModelMetadataArtifactDetails:
113
+ return ModelMetadataArtifactDetails(headers=headers, status=str(status))
114
+
115
+
89
116
  class OCIDataScienceModel(
90
117
  OCIDataScienceMixin,
91
118
  OCIWorkRequestMixin,
@@ -529,8 +556,6 @@ class OCIDataScienceModel(
529
556
 
530
557
  Parameters
531
558
  ----------
532
- model_id: str
533
- The model ID.
534
559
  config: (Dict, optional). Defaults to `None`.
535
560
  Configuration keys and values as per SDK and Tool Configuration.
536
561
  The from_file() method can be used to load configuration from a file.
@@ -579,7 +604,7 @@ class OCIDataScienceModel(
579
604
  raise ValueError("Model OCID not provided.")
580
605
  return super().from_ocid(ocid)
581
606
 
582
- def _is_model_by_reference(self):
607
+ def is_model_created_by_reference(self):
583
608
  """Checks if model is created by reference
584
609
  Returns
585
610
  -------
@@ -594,3 +619,450 @@ class OCIDataScienceModel(
594
619
  ):
595
620
  return True
596
621
  return False
622
+
623
+ def get_metadata_content(
624
+ self, artifact_path_or_content: str, path_type: MetadataArtifactPathType
625
+ ):
626
+ """
627
+ returns the content of the metadata artifact
628
+
629
+ Parameters
630
+ ----------
631
+ artifact_path_or_content: str
632
+ The path of the file (local or oss) containing metadata artifact or content.
633
+ path_type: str
634
+ can be one of local , oss or actual content itself
635
+
636
+ Returns
637
+ -------
638
+ metadata artifact content
639
+ """
640
+
641
+ if path_type == MetadataArtifactPathType.CONTENT:
642
+ return artifact_path_or_content
643
+
644
+ elif path_type == MetadataArtifactPathType.LOCAL:
645
+ if not utils.is_path_exists(artifact_path_or_content):
646
+ raise FileNotFoundError(
647
+ f"File not found: {artifact_path_or_content} . "
648
+ )
649
+
650
+ with open(artifact_path_or_content, "rb") as f:
651
+ contents = f.read()
652
+ logger.info(f"The metadata artifact content - {contents}")
653
+
654
+ return contents
655
+
656
+ elif path_type == MetadataArtifactPathType.OSS:
657
+ if not utils.is_path_exists(artifact_path_or_content):
658
+ raise FileNotFoundError(f"File not found: {artifact_path_or_content}")
659
+
660
+ contents = str(
661
+ read_file(file_path=artifact_path_or_content, auth=default_signer())
662
+ )
663
+ logger.debug(f"The metadata artifact content - {contents}")
664
+
665
+ return contents
666
+
667
+ @check_for_model_id(
668
+ msg="Model needs to be saved to the Model Catalog before the creating custom metadata artifact corresponding to that model"
669
+ )
670
+ def create_custom_metadata_artifact(
671
+ self,
672
+ metadata_key_name: str,
673
+ artifact_path: str,
674
+ path_type: MetadataArtifactPathType,
675
+ ) -> ModelMetadataArtifactDetails:
676
+ """Creates model custom metadata artifact for specified model.
677
+
678
+ Parameters
679
+ ----------
680
+ metadata_key_name: str
681
+ The name of the model metadatum in the metadata.
682
+
683
+ artifact_path: str
684
+ The model custom metadata artifact path to be upload.
685
+
686
+ path_type: MetadataArtifactPathType
687
+ can be one of local , oss or actual content itself
688
+
689
+ Returns
690
+ -------
691
+ ModelMetadataArtifactDetails
692
+ The model custom metadata artifact creation info.
693
+ Example:
694
+ {
695
+ 'Date': 'Mon, 02 Dec 2024 06:38:24 GMT',
696
+ 'opc-request-id': 'E4F7',
697
+ 'ETag': '77156317-8bb9-4c4a-882b-0d85f8140d93',
698
+ 'X-Content-Type-Options': 'nosniff',
699
+ 'Content-Length': '4029958',
700
+ 'Vary': 'Origin',
701
+ 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
702
+ 'status': 204
703
+ }
704
+
705
+ """
706
+ contents = self.get_metadata_content(
707
+ artifact_path_or_content=artifact_path, path_type=path_type
708
+ )
709
+ response = self.client.create_model_custom_metadatum_artifact(
710
+ self.id,
711
+ metadata_key_name,
712
+ text_sanitizer(contents),
713
+ content_disposition="form" '-data; name="file"; filename="readme.*"',
714
+ )
715
+ response_data = convert_model_metadata_response(
716
+ response.headers, response.status
717
+ )
718
+ return response_data
719
+
720
+ @check_for_model_id(
721
+ msg="Model needs to be saved to the Model Catalog before creating defined metadata artifact corresponding to that model"
722
+ )
723
+ def create_defined_metadata_artifact(
724
+ self,
725
+ metadata_key_name: str,
726
+ artifact_path: str,
727
+ path_type: MetadataArtifactPathType,
728
+ ) -> ModelMetadataArtifactDetails:
729
+ """Creates model defined metadata artifact for specified model.
730
+
731
+ Parameters
732
+ ----------
733
+ metadata_key_name: str
734
+ The name of the model metadatum in the metadata.
735
+
736
+ artifact_path: str
737
+ The model custom metadata artifact path to be upload.
738
+
739
+ path_type: MetadataArtifactPathType
740
+ can be one of local , oss or actual content itself.
741
+
742
+ Returns
743
+ -------
744
+ ModelMetadataArtifactDetails
745
+ The model defined metadata artifact creation info.
746
+ Example:
747
+ {
748
+ 'Date': 'Mon, 02 Dec 2024 06:38:24 GMT',
749
+ 'opc-request-id': 'E4F7',
750
+ 'ETag': '77156317-8bb9-4c4a-882b-0d85f8140d93',
751
+ 'X-Content-Type-Options': 'nosniff',
752
+ 'Content-Length': '4029958',
753
+ 'Vary': 'Origin',
754
+ 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
755
+ 'status': 204
756
+ }
757
+
758
+ """
759
+ contents = self.get_metadata_content(
760
+ artifact_path_or_content=artifact_path, path_type=path_type
761
+ )
762
+ response = self.client.create_model_defined_metadatum_artifact(
763
+ self.id,
764
+ metadata_key_name,
765
+ text_sanitizer(contents),
766
+ content_disposition='form-data; name="file"; filename="readme.*"',
767
+ )
768
+ response_data = convert_model_metadata_response(
769
+ response.headers, response.status
770
+ )
771
+ return response_data
772
+
773
+ @check_for_model_id(
774
+ msg="Model needs to be saved to the Model Catalog before updating defined metadata artifact corresponding to that model"
775
+ )
776
+ def update_defined_metadata_artifact(
777
+ self,
778
+ metadata_key_name: str,
779
+ artifact_path: str,
780
+ path_type: MetadataArtifactPathType,
781
+ ) -> ModelMetadataArtifactDetails:
782
+ """Update model defined metadata artifact for specified model.
783
+
784
+ Parameters
785
+ ----------
786
+ metadata_key_name: str
787
+ The name of the model metadatum in the metadata.
788
+
789
+ artifact_path: str
790
+ The model defined metadata artifact path to be upload.
791
+
792
+ path_type:MetadataArtifactPathType
793
+ can be one of local , oss or actual content itself.
794
+ Returns
795
+ -------
796
+ ModelMetadataArtifactDetails
797
+ The model defined metadata artifact update info.
798
+ Example:
799
+ {
800
+ 'Date': 'Mon, 02 Dec 2024 06:38:24 GMT',
801
+ 'opc-request-id': 'E4F7',
802
+ 'ETag': '77156317-8bb9-4c4a-882b-0d85f8140d93',
803
+ 'X-Content-Type-Options': 'nosniff',
804
+ 'Content-Length': '4029958',
805
+ 'Vary': 'Origin',
806
+ 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
807
+ 'status': 204
808
+ }
809
+
810
+ """
811
+ contents = self.get_metadata_content(
812
+ artifact_path_or_content=artifact_path, path_type=path_type
813
+ )
814
+ response = self.client.update_model_defined_metadatum_artifact(
815
+ self.id,
816
+ metadata_key_name,
817
+ text_sanitizer(contents),
818
+ content_disposition='form-data; name="file"; filename="readme.*"',
819
+ )
820
+ response_data = convert_model_metadata_response(
821
+ response.headers, response.status
822
+ )
823
+ return response_data
824
+
825
+ @check_for_model_id(
826
+ msg="Model needs to be saved to the Model Catalog before updating custom metadata artifact corresponding to that model"
827
+ )
828
+ def update_custom_metadata_artifact(
829
+ self,
830
+ metadata_key_name: str,
831
+ artifact_path: str,
832
+ path_type: MetadataArtifactPathType,
833
+ ) -> ModelMetadataArtifactDetails:
834
+ """Update model custom metadata artifact for specified model.
835
+
836
+ Parameters
837
+ ----------
838
+ metadata_key_name: str
839
+ The name of the model metadatum in the metadata.
840
+
841
+ artifact_path: str
842
+ The model custom metadata artifact path to be upload.
843
+
844
+ path_type: MetadataArtifactPathType
845
+ can be one of local , oss or actual content itself.
846
+
847
+ Returns
848
+ -------
849
+ ModelMetadataArtifactDetails
850
+ The model custom metadata artifact update info.
851
+ Example:
852
+ {
853
+ 'Date': 'Mon, 02 Dec 2024 06:38:24 GMT',
854
+ 'opc-request-id': 'E4F7',
855
+ 'ETag': '77156317-8bb9-4c4a-882b-0d85f8140d93',
856
+ 'X-Content-Type-Options': 'nosniff',
857
+ 'Content-Length': '4029958',
858
+ 'Vary': 'Origin',
859
+ 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
860
+ 'status': 204
861
+ }
862
+
863
+ """
864
+ contents = self.get_metadata_content(
865
+ artifact_path_or_content=artifact_path, path_type=path_type
866
+ )
867
+ response = self.client.update_model_custom_metadatum_artifact(
868
+ self.id,
869
+ metadata_key_name,
870
+ text_sanitizer(contents),
871
+ content_disposition="form" '-data; name="file"; filename="readme.*"',
872
+ )
873
+ response_data = convert_model_metadata_response(
874
+ response.headers, response.status
875
+ )
876
+ return response_data
877
+
878
+ @check_for_model_id(
879
+ msg="Model needs to be saved to the Model Catalog before fetching custom metadata artifact corresponding to that model"
880
+ )
881
+ def get_custom_metadata_artifact(self, metadata_key_name: str) -> bytes:
882
+ """Downloads model custom metadata artifact content for specified model metadata key.
883
+
884
+ Parameters
885
+ ----------
886
+ metadata_key_name: str
887
+ The name of the model metadatum in the metadata.
888
+ Returns
889
+ -------
890
+ bytes
891
+ custom metadata artifact content
892
+
893
+ """
894
+ try:
895
+ return self.client.get_model_custom_metadatum_artifact_content(
896
+ self.id, metadata_key_name
897
+ ).data.content
898
+ except ServiceError as ex:
899
+ if ex.status == 404:
900
+ raise ModelMetadataArtifactNotFoundError(self.id, metadata_key_name)
901
+
902
+ @check_for_model_id(
903
+ msg="Model needs to be saved to the Model Catalog before fetching defined metadata artifact corresponding to that model"
904
+ )
905
+ def get_defined_metadata_artifact(self, metadata_key_name: str) -> bytes:
906
+ """Downloads model defined metadata artifact content for specified model metadata key.
907
+
908
+ Parameters
909
+ ----------
910
+ metadata_key_name: str
911
+ The name of the model metadatum in the metadata.
912
+ Returns
913
+ -------
914
+ bytes
915
+ Defined metadata artifact content
916
+
917
+ """
918
+ try:
919
+ return self.client.get_model_defined_metadatum_artifact_content(
920
+ self.id, metadata_key_name
921
+ ).data.content
922
+ except ServiceError as ex:
923
+ if ex.status == 404 or ex.status == 400:
924
+ raise ModelMetadataArtifactNotFoundError(self.id, metadata_key_name)
925
+
926
+ @check_for_model_id(
927
+ msg="Model needs to be saved to the Model Catalog before fetching custom metadata artifact corresponding to that model"
928
+ )
929
+ def head_custom_metadata_artifact(
930
+ self, metadata_key_name: str
931
+ ) -> ModelMetadataArtifactDetails:
932
+ """Gets custom metadata artifact metadata for specified model metadata key.
933
+
934
+ Parameters
935
+ ----------
936
+ metadata_key_name: str
937
+ The name of the model metadatum in the metadata.
938
+ Returns
939
+ -------
940
+ ModelMetadataArtifactDetails
941
+ The model custom metadata artifact head call info.
942
+ Example:
943
+ {
944
+ 'Date': 'Mon, 02 Dec 2024 06:38:24 GMT',
945
+ 'opc-request-id': 'E4F7',
946
+ 'ETag': '77156317-8bb9-4c4a-882b-0d85f8140d93',
947
+ 'X-Content-Type-Options': 'nosniff',
948
+ 'Content-Length': '4029958',
949
+ 'Vary': 'Origin',
950
+ 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
951
+ 'status': 204
952
+ }
953
+
954
+ """
955
+ response = self.client.head_model_custom_metadatum_artifact(
956
+ self.id, metadata_key_name
957
+ )
958
+ response_data = convert_model_metadata_response(
959
+ response.headers, response.status
960
+ )
961
+ return response_data
962
+
963
+ @check_for_model_id(
964
+ msg="Model needs to be saved to the Model Catalog before fetching defined metadata artifact corresponding to that model"
965
+ )
966
+ def head_defined_metadata_artifact(
967
+ self, metadata_key_name: str
968
+ ) -> ModelMetadataArtifactDetails:
969
+ """Gets defined metadata artifact metadata for specified model metadata key.
970
+
971
+ Parameters
972
+ ----------
973
+ metadata_key_name: str
974
+ The name of the model metadatum in the metadata.
975
+ Returns
976
+ -------
977
+ ModelMetadataArtifactDetails
978
+ The model defined metadata artifact head call info.
979
+ Example:
980
+ {
981
+ 'Date': 'Mon, 02 Dec 2024 06:38:24 GMT',
982
+ 'opc-request-id': 'E4F7',
983
+ 'ETag': '77156317-8bb9-4c4a-882b-0d85f8140d93',
984
+ 'X-Content-Type-Options': 'nosniff',
985
+ 'Content-Length': '4029958',
986
+ 'Vary': 'Origin',
987
+ 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
988
+ 'status': 204
989
+ }
990
+
991
+ """
992
+ response = self.client.head_model_defined_metadatum_artifact(
993
+ self.id, metadata_key_name
994
+ )
995
+ response_data = convert_model_metadata_response(
996
+ response.headers, response.status
997
+ )
998
+ return response_data
999
+
1000
+ @check_for_model_id(
1001
+ msg="Model needs to be saved to the Model Catalog before the deleting custom metadata artifact corresponding to that model"
1002
+ )
1003
+ def delete_custom_metadata_artifact(
1004
+ self, metadata_key_name: str
1005
+ ) -> ModelMetadataArtifactDetails:
1006
+ """Deletes model custom metadata artifact for specified model metadata key.
1007
+
1008
+ Parameters
1009
+ ----------
1010
+ metadata_key_name: str
1011
+ The name of the model metadatum in the metadata.
1012
+ Returns
1013
+ -------
1014
+ ModelMetadataArtifactDetails
1015
+ The model custom metadata artifact delete call info.
1016
+ Example:
1017
+ {
1018
+ 'Date': 'Mon, 02 Dec 2024 06:38:24 GMT',
1019
+ 'opc-request-id': 'E4F7',
1020
+ 'X-Content-Type-Options': 'nosniff',
1021
+ 'Vary': 'Origin',
1022
+ 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
1023
+ 'status': 204
1024
+ }
1025
+
1026
+ """
1027
+ response = self.client.delete_model_custom_metadatum_artifact(
1028
+ self.id, metadata_key_name
1029
+ )
1030
+ response_data = convert_model_metadata_response(
1031
+ response.headers, response.status
1032
+ )
1033
+ return response_data
1034
+
1035
+ @check_for_model_id(
1036
+ msg="Model needs to be saved to the Model Catalog before the deleting defined metadata artifact corresponding to that model"
1037
+ )
1038
+ def delete_defined_metadata_artifact(
1039
+ self, metadata_key_name: str
1040
+ ) -> ModelMetadataArtifactDetails:
1041
+ """Deletes model defined metadata artifact for specified model metadata key.
1042
+
1043
+ Parameters
1044
+ ----------
1045
+ metadata_key_name: str
1046
+ The name of the model metadatum in the metadata.
1047
+ Returns
1048
+ -------
1049
+ ModelMetadataArtifactDetails
1050
+ The model defined metadata artifact delete call info.
1051
+ Example:
1052
+ {
1053
+ 'Date': 'Mon, 02 Dec 2024 06:38:24 GMT',
1054
+ 'opc-request-id': 'E4F7',
1055
+ 'X-Content-Type-Options': 'nosniff',
1056
+ 'Vary': 'Origin',
1057
+ 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
1058
+ 'status': 204
1059
+ }
1060
+
1061
+ """
1062
+ response = self.client.delete_model_defined_metadatum_artifact(
1063
+ self.id, metadata_key_name
1064
+ )
1065
+ response_data = convert_model_metadata_response(
1066
+ response.headers, response.status
1067
+ )
1068
+ return response_data
@@ -9,6 +9,7 @@ import os
9
9
  import sys
10
10
  import time
11
11
  import traceback
12
+ import uuid
12
13
  from string import Template
13
14
  from typing import Any, Dict, List, Tuple
14
15
 
@@ -17,6 +18,7 @@ import yaml
17
18
  from cerberus import Validator
18
19
 
19
20
  from ads.opctl import logger, utils
21
+ from ads.common.oci_logging import OCILog
20
22
 
21
23
  CONTAINER_NETWORK = "CONTAINER_NETWORK"
22
24
 
@@ -190,3 +192,17 @@ def print_traceback():
190
192
  if logger.level == logging.DEBUG:
191
193
  ex_type, ex, tb = sys.exc_info()
192
194
  traceback.print_tb(tb)
195
+
196
+
197
+ def create_log_in_log_group(compartment_id, log_group_id, auth, log_name=None):
198
+ """
199
+ Creates a log within a given log group
200
+ """
201
+ if not log_name:
202
+ log_name = f"log-{int(time.time())}-{uuid.uuid4()}"
203
+ log = OCILog(display_name=log_name,
204
+ log_group_id=log_group_id,
205
+ compartment_id=compartment_id,
206
+ **auth).create()
207
+ logger.info(f"Created log with log OCID {log.id}")
208
+ return log.id
@@ -71,7 +71,7 @@ class AnomalyOperatorBaseModel(ABC):
71
71
  try:
72
72
  anomaly_output = self._build_model()
73
73
  except Exception as e:
74
- logger.warn(f"Found exception: {e}")
74
+ logger.warning(f"Found exception: {e}")
75
75
  if self.spec.datetime_column:
76
76
  anomaly_output = self._fallback_build_model()
77
77
  raise e
@@ -347,7 +347,7 @@ class AnomalyOperatorBaseModel(ABC):
347
347
  storage_options=storage_options,
348
348
  )
349
349
 
350
- logger.warn(
350
+ logger.warning(
351
351
  f"The report has been successfully "
352
352
  f"generated and placed to the: {unique_output_dir}."
353
353
  )
@@ -356,7 +356,7 @@ class AnomalyOperatorBaseModel(ABC):
356
356
  """
357
357
  Fallback method for the sub model _build_model method.
358
358
  """
359
- logger.warn(
359
+ logger.warning(
360
360
  f"The build_model method has failed for the model: {self.spec.model}. "
361
361
  "A fallback model will be built."
362
362
  )
@@ -95,7 +95,7 @@ class RandomCutForestOperatorModel(AnomalyOperatorBaseModel):
95
95
 
96
96
  anomaly_output.add_output(target, anomaly, score)
97
97
  except Exception as e:
98
- logger.warn(f"Encountered Error: {e}. Skipping series {target}.")
98
+ logger.warning(f"Encountered Error: {e}. Skipping series {target}.")
99
99
 
100
100
  return anomaly_output
101
101
 
@@ -44,7 +44,7 @@ def _build_metrics_df(y_true, y_pred, column_name):
44
44
  # Throws exception if y_true has only one class
45
45
  metrics[SupportedMetrics.ROC_AUC] = roc_auc_score(y_true, y_pred)
46
46
  except Exception as e:
47
- logger.warn(f"An exception occurred: {e}")
47
+ logger.warning(f"An exception occurred: {e}")
48
48
  metrics[SupportedMetrics.ROC_AUC] = None
49
49
  precision, recall, thresholds = precision_recall_curve(y_true, y_pred)
50
50
  metrics[SupportedMetrics.PRC_AUC] = auc(recall, precision)
@@ -19,13 +19,16 @@ from .transformations import Transformations
19
19
 
20
20
 
21
21
  class AbstractData(ABC):
22
- def __init__(self, spec: dict, name="input_data"):
22
+ def __init__(self, spec, name="input_data", data=None):
23
23
  self.Transformations = Transformations
24
24
  self.data = None
25
25
  self._data_dict = dict()
26
26
  self.name = name
27
27
  self.spec = spec
28
- self.load_transform_ingest_data(spec)
28
+ if data is not None:
29
+ self.data = data
30
+ else:
31
+ self.load_transform_ingest_data(spec)
29
32
 
30
33
  def get_raw_data_by_cat(self, category):
31
34
  mapping = self._data_transformer.get_target_category_columns_map()
@@ -31,7 +31,6 @@ class Transformations(ABC):
31
31
  dataset_info : ForecastOperatorConfig
32
32
  """
33
33
  self.name = name
34
- self.has_artificial_series = False
35
34
  self.dataset_info = dataset_info
36
35
  self.target_category_columns = dataset_info.target_category_columns
37
36
  self.target_column_name = dataset_info.target_column
@@ -99,7 +98,11 @@ class Transformations(ABC):
99
98
  return clean_df
100
99
 
101
100
  def _remove_trailing_whitespace(self, df):
102
- return df.apply(lambda x: x.str.strip() if x.dtype == "object" else x)
101
+ return df.apply(
102
+ lambda x: x.str.strip()
103
+ if hasattr(x, "dtype") and x.dtype == "object"
104
+ else x
105
+ )
103
106
 
104
107
  def _clean_column_names(self, df):
105
108
  """
@@ -136,7 +139,6 @@ class Transformations(ABC):
136
139
  self._target_category_columns_map = {}
137
140
  if not self.target_category_columns:
138
141
  df[DataColumns.Series] = "Series 1"
139
- self.has_artificial_series = True
140
142
  else:
141
143
  df[DataColumns.Series] = merge_category_columns(
142
144
  df, self.target_category_columns
@@ -209,7 +211,7 @@ class Transformations(ABC):
209
211
 
210
212
  def _missing_value_imputation_add(self, df):
211
213
  """
212
- Function fills missing values in the pandas dataframe using liner interpolation
214
+ Function fills missing values with zero
213
215
 
214
216
  Parameters
215
217
  ----------
@@ -219,15 +221,7 @@ class Transformations(ABC):
219
221
  -------
220
222
  A new Pandas DataFrame without missing values.
221
223
  """
222
- # find columns that all all NA and replace with 0
223
- for col in df.columns:
224
- # find next int not in list
225
- i = 0
226
- vals = df[col].unique()
227
- while i in vals:
228
- i = i + 1
229
- df[col] = df[col].fillna(0)
230
- return df
224
+ return df.fillna(0)
231
225
 
232
226
  def _outlier_treatment(self, df):
233
227
  """