|
| 1 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). You |
| 4 | +# may not use this file except in compliance with the License. A copy of |
| 5 | +# the License is located at |
| 6 | +# |
| 7 | +# http://aws.amazon.com/apache2.0/ |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is |
| 10 | +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
| 11 | +# ANY KIND, either express or implied. See the License for the specific |
| 12 | +# language governing permissions and limitations under the License. |
| 13 | +"""Contains API objects for SageMaker experiments.""" |
| 14 | +from __future__ import absolute_import |
| 15 | + |
| 16 | +import numbers |
| 17 | + |
| 18 | +from sagemaker.apiutils import _base_types |
| 19 | + |
| 20 | + |
| 21 | +class TrialComponentMetricSummary(_base_types.ApiObject): |
| 22 | + """Summary model of a trial component. |
| 23 | +
|
| 24 | + Attributes: |
| 25 | + metric_name (str): The name of the metric. |
| 26 | + source_arn (str): The ARN of the source. |
| 27 | + time_stamp (datetime): Metric last updated value. |
| 28 | + max (float): The max value of the metric. |
| 29 | + min (float): The min value of the metric. |
| 30 | + last (float): The last value of the metric. |
| 31 | + count (float): The number of samples used to generate the metric. |
| 32 | + avg (float): The average value of the metric. |
| 33 | + std_dev (float): The standard deviation of the metric. |
| 34 | + """ |
| 35 | + |
| 36 | + metric_name = None |
| 37 | + source_arn = None |
| 38 | + time_stamp = None |
| 39 | + max = None |
| 40 | + min = None |
| 41 | + last = None |
| 42 | + count = None |
| 43 | + avg = None |
| 44 | + std_dev = None |
| 45 | + |
| 46 | + def __init__(self, metric_name=None, source_arn=None, **kwargs): |
| 47 | + super(TrialComponentMetricSummary, self).__init__( |
| 48 | + metric_name=metric_name, source_arn=source_arn, **kwargs |
| 49 | + ) |
| 50 | + |
| 51 | + |
| 52 | +class TrialComponentParameters(_base_types.ApiObject): |
| 53 | + """A dictionary of TrialComponentParameterValues""" |
| 54 | + |
| 55 | + @classmethod |
| 56 | + def from_boto(cls, boto_dict, **kwargs): |
| 57 | + """Converts a boto dict to a dictionary of TrialComponentParameterValues |
| 58 | +
|
| 59 | + Args: |
| 60 | + boto_dict (dict): boto response dictionary. |
| 61 | + **kwargs: Arbitrary keyword arguments. |
| 62 | +
|
| 63 | + Returns: |
| 64 | + dict: Dictionary of parameter values. |
| 65 | + """ |
| 66 | + return_map = {} |
| 67 | + for key, value in boto_dict.items(): |
| 68 | + return_map[key] = value.get("NumberValue", value.get("StringValue", None)) |
| 69 | + return return_map |
| 70 | + |
| 71 | + @classmethod |
| 72 | + def to_boto(cls, parameters): |
| 73 | + """Converts TrialComponentParameters to dict. |
| 74 | +
|
| 75 | + Args: |
| 76 | + parameters (TrialComponentParameters): Dictionary to convert. |
| 77 | +
|
| 78 | + Returns: |
| 79 | + dict: Dictionary of trial component parameters in boto format. |
| 80 | + """ |
| 81 | + boto_map = {} |
| 82 | + for key, value in parameters.items(): |
| 83 | + if isinstance(value, numbers.Number): |
| 84 | + boto_map[key] = {"NumberValue": value} |
| 85 | + else: |
| 86 | + boto_map[key] = {"StringValue": str(value)} |
| 87 | + return boto_map |
| 88 | + |
| 89 | + |
| 90 | +class TrialComponentArtifact(_base_types.ApiObject): |
| 91 | + """Trial component artifact. |
| 92 | +
|
| 93 | + Attributes: |
| 94 | + value (str): The artifact value. |
| 95 | + media_type (str): The media type. |
| 96 | + """ |
| 97 | + |
| 98 | + value = None |
| 99 | + media_type = None |
| 100 | + |
| 101 | + def __init__(self, value=None, media_type=None, **kwargs): |
| 102 | + super(TrialComponentArtifact, self).__init__(value=value, media_type=media_type, **kwargs) |
| 103 | + |
| 104 | + |
| 105 | +class TrialComponentStatus(_base_types.ApiObject): |
| 106 | + """Status of the trial component. |
| 107 | +
|
| 108 | + Attributes: |
| 109 | + primary_status (str): The status of a trial component. |
| 110 | + message (str): Status message. |
| 111 | + """ |
| 112 | + |
| 113 | + primary_status = None |
| 114 | + message = None |
| 115 | + |
| 116 | + def __init__(self, primary_status=None, message=None, **kwargs): |
| 117 | + super(TrialComponentStatus, self).__init__( |
| 118 | + primary_status=primary_status, message=message, **kwargs |
| 119 | + ) |
| 120 | + |
| 121 | + |
| 122 | +class TrialComponentSummary(_base_types.ApiObject): |
| 123 | + """Summary model of a trial component. |
| 124 | +
|
| 125 | + Attributes: |
| 126 | + trial_component_name (str): Name of trial component. |
| 127 | + trial_component_arn (str): ARN of the trial component. |
| 128 | + display_name (str): Friendly display name in UI. |
| 129 | + source_arn (str): ARN of the trial component source. |
| 130 | + status (str): Status. |
| 131 | + start_time (datetime): Start time. |
| 132 | + end_time (datetime): End time. |
| 133 | + creation_time (datetime): Creation time. |
| 134 | + created_by (str): Created by. |
| 135 | + last_modified_time (datetime): Date last modified. |
| 136 | + last_modified_by (datetime): User last modified. |
| 137 | + """ |
| 138 | + |
| 139 | + _custom_boto_types = { |
| 140 | + "status": (TrialComponentStatus, False), |
| 141 | + } |
| 142 | + trial_component_name = None |
| 143 | + trial_component_arn = None |
| 144 | + display_name = None |
| 145 | + source_arn = None |
| 146 | + status = None |
| 147 | + start_time = None |
| 148 | + end_time = None |
| 149 | + creation_time = None |
| 150 | + created_by = None |
| 151 | + last_modified_time = None |
| 152 | + last_modified_by = None |
| 153 | + |
| 154 | + |
| 155 | +class TrialComponentSource(_base_types.ApiObject): |
| 156 | + """Trial Component Source |
| 157 | +
|
| 158 | + Attributes: |
| 159 | + source_arn (str): The ARN of the source. |
| 160 | + """ |
| 161 | + |
| 162 | + source_arn = None |
| 163 | + |
| 164 | + def __init__(self, source_arn=None, **kwargs): |
| 165 | + super(TrialComponentSource, self).__init__(source_arn=source_arn, **kwargs) |
| 166 | + |
| 167 | + |
| 168 | +class Parent(_base_types.ApiObject): |
| 169 | + """The trial/experiment/run that a trial component is associated with. |
| 170 | +
|
| 171 | + Attributes: |
| 172 | + trial_name (str): Name of the trial. |
| 173 | + experiment_name (str): Name of the experiment. |
| 174 | + run_name (str): Name of the run. |
| 175 | + """ |
| 176 | + |
| 177 | + trial_name = None |
| 178 | + experiment_name = None |
| 179 | + run_name = None |
| 180 | + |
| 181 | + |
| 182 | +class TrialComponentSearchResult(_base_types.ApiObject): |
| 183 | + """Summary model of an Trial Component search result. |
| 184 | +
|
| 185 | + Attributes: |
| 186 | + trial_component_arn (str): ARN of the trial component. |
| 187 | + trial_component_name (str): Name of the trial component. |
| 188 | + display_name (str): Display name of the trial component for UI display. |
| 189 | + source (dict): The source of the trial component. |
| 190 | + status (dict): The status of the trial component. |
| 191 | + start_time (datetime): Start time. |
| 192 | + end_time (datetime): End time. |
| 193 | + creation_time (datetime): Creation time. |
| 194 | + created_by (str): Created by. |
| 195 | + last_modified_time (datetime): Date last modified. |
| 196 | + last_modified_by (datetime): User last modified. |
| 197 | + parameters (dict): The hyperparameters of the component. |
| 198 | + input_artifacts (dict): The input artifacts of the component. |
| 199 | + output_artifacts (dict): The output artifacts of the component. |
| 200 | + metrics (list): The metrics for the component. |
| 201 | + source_detail (dict): The source of the trial component. |
| 202 | + tags (list): The list of tags that are associated with the trial component. |
| 203 | + parents (list[Parent]): The parent of trial component. |
| 204 | + """ |
| 205 | + |
| 206 | + _custom_boto_types = { |
| 207 | + "parents": (Parent, True), # parents is a collection (list) of Parent objects |
| 208 | + } |
| 209 | + trial_component_arn = None |
| 210 | + trial_component_name = None |
| 211 | + display_name = None |
| 212 | + source = None |
| 213 | + status = None |
| 214 | + start_time = None |
| 215 | + end_time = None |
| 216 | + creation_time = None |
| 217 | + created_by = None |
| 218 | + last_modified_time = None |
| 219 | + last_modified_by = None |
| 220 | + parameters = None |
| 221 | + input_artifacts = None |
| 222 | + output_artifacts = None |
| 223 | + metrics = None |
| 224 | + source_detail = None |
| 225 | + tags = None |
| 226 | + parents = None |
0 commit comments