braket.jobs.metrics_data.cwl_insights_metrics_fetcher module

class braket.jobs.metrics_data.cwl_insights_metrics_fetcher.CwlInsightsMetricsFetcher(aws_session: ~braket.aws.aws_session.AwsSession, poll_timeout_seconds: float = 10, poll_interval_seconds: float = 1, logger: ~logging.Logger = <Logger braket.jobs.metrics_data.cwl_insights_metrics_fetcher (WARNING)>)[source]

Bases: object

Initializes a CwlInsightsMetricsFetcher.

Parameters:
  • aws_session (AwsSession) – AwsSession to connect to AWS with.

  • poll_timeout_seconds (float) – The polling timeout for retrieving the metrics, in seconds. Default: 10 seconds.

  • poll_interval_seconds (float) – The interval of time, in seconds, between polling for results. Default: 1 second.

  • logger (Logger) – Logger object with which to write logs, such as quantum task statuses while waiting for a quantum task to be in a terminal state. Default is getLogger(__name__)

LOG_GROUP_NAME = '/aws/braket/jobs'
QUERY_DEFAULT_JOB_DURATION = 10800
get_metrics_for_job(job_name: str, metric_type: MetricType = MetricType.TIMESTAMP, statistic: MetricStatistic = MetricStatistic.MAX, job_start_time: int | None = None, job_end_time: int | None = None, stream_prefix: str | None = None) dict[str, list[str | float | int]][source]

Synchronously retrieves all the algorithm metrics logged by a given Hybrid Job.

Parameters:
  • job_name (str) – The name of the Hybrid Job. The name must be exact to ensure only the relevant metrics are retrieved.

  • metric_type (MetricType) – The type of metrics to get. Default is MetricType.TIMESTAMP.

  • statistic (MetricStatistic) – The statistic to determine which metric value to use when there is a conflict. Default is MetricStatistic.MAX.

  • job_start_time (int | None) – The time when the hybrid job started. Default: 3 hours before job_end_time.

  • job_end_time (int | None) – If the hybrid job is complete, this should be the time at which the hybrid job finished. Default: current time.

  • stream_prefix (str | None) – If a logs prefix is provided, it will be used instead of the job name.

Returns:

dict[str, list[Union[str, float, int]]] – The metrics data, where the keys are the column names and the values are a list containing the values in each row.

Example

timestamp energy 0 0.1 1 0.2 would be represented as: { “timestamp” : [0, 1], “energy” : [0.1, 0.2] } The values may be integers, floats, strings or None.