def test_eq(self):
   a1 = provider.Run(run_id="a", run_name="aa", start_time=1.25)
   a2 = provider.Run(run_id="a", run_name="aa", start_time=1.25)
   b = provider.Run(run_id="b", run_name="bb", start_time=-1.75)
   self.assertEqual(a1, a2)
   self.assertNotEqual(a1, b)
   self.assertNotEqual(b, object())
    def test_list_runs(self):
        # We can't control the timestamps of events written to disk (without
        # manually reading the tfrecords, modifying the data, and writing
        # them back out), so we provide a fake multiplexer instead.
        start_times = {
            "second_2": 2.0,
            "first": 1.5,
            "no_time": None,
            "second_1": 2.0,
        }

        class FakeMultiplexer(object):
            def Runs(multiplexer):
                result = ["second_2", "first", "no_time", "second_1"]
                self.assertItemsEqual(result, start_times)
                return result

            def FirstEventTimestamp(multiplexer, run):
                self.assertIn(run, start_times)
                result = start_times[run]
                if result is None:
                    raise ValueError("No event timestep could be found")
                else:
                    return result

        multiplexer = FakeMultiplexer()
        provider = data_provider.MultiplexerDataProvider(
            multiplexer, "fake_logdir")
        result = provider.list_runs(experiment_id="unused")
        self.assertItemsEqual(result, [
            base_provider.Run(run_id=run, run_name=run, start_time=start_time)
            for (run, start_time) in six.iteritems(start_times)
        ])
Beispiel #3
0
    def test_list_runs(self):
        res = data_provider_pb2.ListRunsResponse()
        res.runs.add(name="val", start_time=1234.5)
        res.runs.add(name="test", start_time=6789.0)
        self.stub.ListRuns.return_value = res

        actual = self.provider.list_runs(self.ctx, experiment_id="123")
        expected = [
            provider.Run(run_id="val", run_name="val", start_time=1234.5),
            provider.Run(run_id="test", run_name="test", start_time=6789.0),
        ]
        self.assertEqual(actual, expected)

        req = data_provider_pb2.ListRunsRequest()
        req.experiment_id = "123"
        self.stub.ListRuns.assert_called_once_with(req)
Beispiel #4
0
 def list_runs(self, experiment_id):
     self._validate_experiment_id(experiment_id)
     return [
         provider.Run(
             run_id=run,  # use names as IDs
             run_name=run,
             start_time=self._get_first_event_timestamp(run),
         ) for run in self._multiplexer.Runs()
     ]
Beispiel #5
0
 def list_runs(self, experiment_id):
     del experiment_id  # ignored for now
     return [
         provider.Run(
             run_id=run,  # use names as IDs
             run_name=run,
             start_time=self._get_first_event_timestamp(run),
         ) for run in self._multiplexer.Runs()
     ]
Beispiel #6
0
 def list_runs(self, ctx, *, experiment_id):
     req = data_provider_pb2.ListRunsRequest()
     req.experiment_id = experiment_id
     with _translate_grpc_error():
         res = self._stub.ListRuns(req)
     return [
         provider.Run(
             run_id=run.name,
             run_name=run.name,
             start_time=run.start_time,
         ) for run in res.runs
     ]
Beispiel #7
0
    def list_runs(self, ctx=None, *, experiment_id):
        """List runs available.

        Args:
          experiment_id: currently unused, because the backing
            DebuggerV2EventMultiplexer does not accommodate multiple experiments.

        Returns:
          Run names as a list of str.
        """
        return [
            provider.Run(
                run_id=run,  # use names as IDs
                run_name=run,
                start_time=self._get_first_event_timestamp(run),
            ) for run in self._multiplexer.Runs()
        ]
 def test_repr(self):
   x = provider.Run(run_id="alpha", run_name="bravo", start_time=1.25)
   repr_ = repr(x)
   self.assertIn(repr(x.run_id), repr_)
   self.assertIn(repr(x.run_name), repr_)
   self.assertIn(repr(x.start_time), repr_)