about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_job/queue_settings.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_job/queue_settings.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are here HEAD master
Diffstat (limited to '.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_job/queue_settings.py')
-rw-r--r--.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_job/queue_settings.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_job/queue_settings.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_job/queue_settings.py
new file mode 100644
index 00000000..5b51fb6e
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_job/queue_settings.py
@@ -0,0 +1,87 @@
+# ---------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# ---------------------------------------------------------
+
+import logging
+from typing import Any, Dict, Optional, Union
+
+from ..._restclient.v2023_04_01_preview.models import QueueSettings as RestQueueSettings
+from ..._utils._experimental import experimental
+from ..._utils.utils import is_data_binding_expression
+from ...constants._job.job import JobPriorityValues, JobTierNames
+from ...entities._mixins import DictMixin, RestTranslatableMixin
+from ...exceptions import ErrorCategory, ErrorTarget, ValidationErrorType, ValidationException
+
+module_logger = logging.getLogger(__name__)
+
+
+@experimental
+class QueueSettings(RestTranslatableMixin, DictMixin):
+    """Queue settings for a pipeline job.
+
+    :ivar job_tier: Enum to determine the job tier. Possible values include: "Spot", "Basic",
+        "Standard", "Premium", "Null".
+    :vartype job_tier: str or ~azure.mgmt.machinelearningservices.models.JobTier
+    :ivar priority: Controls the priority of the job on a compute.
+    :vartype priority: str
+    :keyword job_tier: The job tier. Accepted values are "Spot", "Basic", "Standard", and "Premium".
+    :paramtype job_tier: Optional[Literal]]
+    :keyword priority: The priority of the job on a compute. Accepted values are "low", "medium", and "high".
+        Defaults to "medium".
+    :paramtype priority: Optional[Literal]
+    :keyword kwargs: Additional properties for QueueSettings.
+    :paramtype kwargs: Optional[dict]
+    """
+
+    def __init__(
+        self,  # pylint: disable=unused-argument
+        *,
+        job_tier: Optional[str] = None,
+        priority: Optional[str] = None,
+        **kwargs: Any,
+    ) -> None:
+        self.job_tier = job_tier
+        self.priority = priority
+
+    def _to_rest_object(self) -> RestQueueSettings:
+        self._validate()
+        job_tier = JobTierNames.ENTITY_TO_REST.get(self.job_tier.lower(), None) if self.job_tier else None
+        priority = JobPriorityValues.ENTITY_TO_REST.get(self.priority.lower(), None) if self.priority else None
+        return RestQueueSettings(job_tier=job_tier, priority=priority)
+
+    @classmethod
+    def _from_rest_object(cls, obj: Union[Dict[str, Any], RestQueueSettings, None]) -> Optional["QueueSettings"]:
+        if obj is None:
+            return None
+        if isinstance(obj, dict):
+            queue_settings = RestQueueSettings.from_dict(obj)
+            return cls._from_rest_object(queue_settings)
+        job_tier = JobTierNames.REST_TO_ENTITY.get(obj.job_tier, None) if obj.job_tier else None
+        priority = JobPriorityValues.REST_TO_ENTITY.get(obj.priority, None) if hasattr(obj, "priority") else None
+        return cls(job_tier=job_tier, priority=priority)
+
+    def _validate(self) -> None:
+        for key, enum_class in [("job_tier", JobTierNames), ("priority", JobPriorityValues)]:
+            value = getattr(self, key)
+            if is_data_binding_expression(value):
+                msg = (
+                    f"do not support data binding expression on {key} as it involves value mapping "
+                    f"when transformed to rest object, but received '{value}'."
+                )
+                raise ValidationException(
+                    message=msg,
+                    no_personal_data_message=msg,
+                    target=ErrorTarget.JOB,
+                    error_category=ErrorCategory.USER_ERROR,
+                    error_type=ValidationErrorType.INVALID_VALUE,
+                )
+            valid_keys = list(enum_class.ENTITY_TO_REST.keys())  # type: ignore[attr-defined]
+            if value and value.lower() not in valid_keys:
+                msg = f"{key} should be one of {valid_keys}, but received '{value}'."
+                raise ValidationException(
+                    message=msg,
+                    no_personal_data_message=msg,
+                    target=ErrorTarget.JOB,
+                    error_category=ErrorCategory.USER_ERROR,
+                    error_type=ValidationErrorType.INVALID_VALUE,
+                )