# Path: sacred/metrics_logger.py
# class MetricsLogger:
# class ScalarMetricLogEntry:
#     def __init__(self):
#     def log_scalar_metric(self, metric_name, value, step=None):
#     def get_last_metrics(self):
#     def __init__(self, name, step, timestamp, value):
# def linearize_metrics(logged_metrics):
# 
# Path: sacred/metrics_logger.py
# def linearize_metrics(logged_metrics):
#     """
#     Group metrics by name.
# 
#     Takes a list of individual measurements, possibly belonging
#     to different metrics and groups them by name.
# 
#     :param logged_metrics: A list of ScalarMetricLogEntries
#     :return: Measured values grouped by the metric name:
#     {"metric_name1": {"steps": [0,1,2], "values": [4, 5, 6],
#     "timestamps": [datetime, datetime, datetime]},
#     "metric_name2": {...}}
#     """
#     metrics_by_name = {}
#     for metric_entry in logged_metrics:
#         if metric_entry.name not in metrics_by_name:
#             metrics_by_name[metric_entry.name] = {
#                 "steps": [],
#                 "values": [],
#                 "timestamps": [],
#                 "name": metric_entry.name,
#             }
#         metrics_by_name[metric_entry.name]["steps"].append(metric_entry.step)
#         metrics_by_name[metric_entry.name]["values"].append(metric_entry.value)
#         metrics_by_name[metric_entry.name]["timestamps"].append(metric_entry.timestamp)
#     return metrics_by_name
# 
# Path: sacred/randomness.py
# def set_global_seed(seed):
#     random.seed(seed)
#     if opt.has_numpy:
#         opt.np.random.seed(seed)
#     if module_is_in_cache("tensorflow"):
#         tf = opt.get_tensorflow()
#         tf.set_random_seed(seed)
#     if module_is_in_cache("torch"):
#         import torch
# 
#         torch.manual_seed(seed)
#         if torch.cuda.is_available():
#             torch.cuda.manual_seed_all(seed)
# 
# Path: sacred/utils.py
# class SacredInterrupt(Exception):
#     """Base-Class for all custom interrupts.
# 
#     For more information see :ref:`custom_interrupts`.
#     """
# 
#     STATUS = "INTERRUPTED"
# 
# def join_paths(*parts):
#     """Join different parts together to a valid dotted path."""
#     return ".".join(str(p).strip(".") for p in parts if p)
# 
# class IntervalTimer(threading.Thread):
#     @classmethod
#     def create(cls, func, interval=10):
#         stop_event = threading.Event()
#         timer_thread = cls(stop_event, func, interval)
#         return stop_event, timer_thread
# 
#     def __init__(self, event, func, interval=10.0):
#         super().__init__()
#         self.stopped = event
#         self.func = func
#         self.interval = interval
# 
#     def run(self):
#         while not self.stopped.wait(self.interval):
#             self.func()
#         self.func()
# 
# Path: sacred/stdout_capturing.py
# def get_stdcapturer(mode=None):
#     mode = mode if mode is not None else SETTINGS.CAPTURE_MODE
#     capture_options = {"no": no_tee, "fd": tee_output_fd, "sys": tee_output_python}
#     if mode not in capture_options:
#         raise KeyError(
#             "Unknown capture mode '{}'. Available options are {}".format(
#                 mode, sorted(capture_options.keys())
#             )
#         )
#     return mode, capture_options[mode]


import datetime
import os.path
import sys
import traceback as tb
from sacred import metrics_logger
from sacred.metrics_logger import linearize_metrics
from sacred.randomness import set_global_seed
from sacred.utils import SacredInterrupt, join_paths, IntervalTimer
from sacred.stdout_capturing import get_stdcapturer
        self.status = "QUEUED"
        queue_time = datetime.datetime.utcnow()
        self.meta_info["queue_time"] = queue_time
        command = join_paths(
            self.main_function.prefix, self.main_function.signature.name
        )
        self.run_logger.info("Queuing-up command '%s'", command)
        for observer in self.observers:
            _id = observer.queued_event(
                ex_info=self.experiment_info,
                command=command,
                host_info=self.host_info,
                queue_time=queue_time,
                config=self.config,
                meta_info=self.meta_info,
                _id=self._id,
            )
            if self._id is None:
                self._id = _id
            # do not catch any exceptions on startup:
            # the experiment SHOULD fail if any of the observers fails

        if self._id is None:
            self.run_logger.info("Queued")
        else:
            self.run_logger.info('Queued-up run with ID "{}"'.format(self._id))

    def _emit_started(self):
        self.status = "RUNNING"
        self.start_time = datetime.datetime.utcnow()

# Path: sacred/metrics_logger.py
# class MetricsLogger:
# class ScalarMetricLogEntry:
#     def __init__(self):
#     def log_scalar_metric(self, metric_name, value, step=None):
#     def get_last_metrics(self):
#     def __init__(self, name, step, timestamp, value):
# def linearize_metrics(logged_metrics):
# 
# Path: sacred/metrics_logger.py
# def linearize_metrics(logged_metrics):
#     """
#     Group metrics by name.
# 
#     Takes a list of individual measurements, possibly belonging
#     to different metrics and groups them by name.
# 
#     :param logged_metrics: A list of ScalarMetricLogEntries
#     :return: Measured values grouped by the metric name:
#     {"metric_name1": {"steps": [0,1,2], "values": [4, 5, 6],
#     "timestamps": [datetime, datetime, datetime]},
#     "metric_name2": {...}}
#     """
#     metrics_by_name = {}
#     for metric_entry in logged_metrics:
#         if metric_entry.name not in metrics_by_name:
#             metrics_by_name[metric_entry.name] = {
#                 "steps": [],
#                 "values": [],
#                 "timestamps": [],
#                 "name": metric_entry.name,
#             }
#         metrics_by_name[metric_entry.name]["steps"].append(metric_entry.step)
#         metrics_by_name[metric_entry.name]["values"].append(metric_entry.value)
#         metrics_by_name[metric_entry.name]["timestamps"].append(metric_entry.timestamp)
#     return metrics_by_name
# 
# Path: sacred/randomness.py
# def set_global_seed(seed):
#     random.seed(seed)
#     if opt.has_numpy:
#         opt.np.random.seed(seed)
#     if module_is_in_cache("tensorflow"):
#         tf = opt.get_tensorflow()
#         tf.set_random_seed(seed)
#     if module_is_in_cache("torch"):
#         import torch
# 
#         torch.manual_seed(seed)
#         if torch.cuda.is_available():
#             torch.cuda.manual_seed_all(seed)
# 
# Path: sacred/utils.py
# class SacredInterrupt(Exception):
#     """Base-Class for all custom interrupts.
# 
#     For more information see :ref:`custom_interrupts`.
#     """
# 
#     STATUS = "INTERRUPTED"
# 
# def join_paths(*parts):
#     """Join different parts together to a valid dotted path."""
#     return ".".join(str(p).strip(".") for p in parts if p)
# 
# class IntervalTimer(threading.Thread):
#     @classmethod
#     def create(cls, func, interval=10):
#         stop_event = threading.Event()
#         timer_thread = cls(stop_event, func, interval)
#         return stop_event, timer_thread
# 
#     def __init__(self, event, func, interval=10.0):
#         super().__init__()
#         self.stopped = event
#         self.func = func
#         self.interval = interval
# 
#     def run(self):
#         while not self.stopped.wait(self.interval):
#             self.func()
#         self.func()
# 
# Path: sacred/stdout_capturing.py
# def get_stdcapturer(mode=None):
#     mode = mode if mode is not None else SETTINGS.CAPTURE_MODE
#     capture_options = {"no": no_tee, "fd": tee_output_fd, "sys": tee_output_python}
#     if mode not in capture_options:
#         raise KeyError(
#             "Unknown capture mode '{}'. Available options are {}".format(
#                 mode, sorted(capture_options.keys())
#             )
#         )
#     return mode, capture_options[mode]


# Path: sacred/run.py
import datetime
import os.path
import sys
import traceback as tb
from sacred import metrics_logger
from sacred.metrics_logger import linearize_metrics
from sacred.randomness import set_global_seed
from sacred.utils import SacredInterrupt, join_paths, IntervalTimer
from sacred.stdout_capturing import get_stdcapturer

        self.status = "QUEUED"
        queue_time = datetime.datetime.utcnow()
        self.meta_info["queue_time"] = queue_time
        command = join_paths(
            self.main_function.prefix, self.main_function.signature.name
        )
        self.run_logger.info("Queuing-up command '%s'", command)
        for observer in self.observers:
            _id = observer.queued_event(
                ex_info=self.experiment_info,
                command=command,
                host_info=self.host_info,
                queue_time=queue_time,
                config=self.config,
                meta_info=self.meta_info,
                _id=self._id,
            )
            if self._id is None:
                self._id = _id
            # do not catch any exceptions on startup:
            # the experiment SHOULD fail if any of the observers fails

        if self._id is None:
            self.run_logger.info("Queued")
        else:
            self.run_logger.info('Queued-up run with ID "{}"'.format(self._id))

    def _emit_started(self):
        self.status = "RUNNING"
        self.start_time = datetime.datetime.utcnow()

        command = join_paths(