Esempio n. 1
0
 def execute(self, server_info, channel):
     api_client = write_service_pb2_grpc.TensorBoardWriterServiceStub(
         channel
     )
     _die_if_bad_experiment_name(self.name)
     _die_if_bad_experiment_description(self.description)
     uploader = uploader_lib.TensorBoardUploader(
         api_client,
         self.logdir,
         name=self.name,
         description=self.description,
     )
     experiment_id = uploader.create_experiment()
     url = server_info_lib.experiment_url(server_info, experiment_id)
     print(
         "Upload started and will continue reading any new data as it's added"
     )
     print("to the logdir. To stop uploading, press Ctrl-C.")
     print("View your TensorBoard live at: %s" % url)
     try:
         uploader.start_uploading()
     except uploader_lib.ExperimentNotFoundError:
         print("Experiment was deleted; uploading has been cancelled")
         return
     except KeyboardInterrupt:
         print()
         print("Upload stopped. View your TensorBoard at %s" % url)
         return
     # TODO(@nfelt): make it possible for the upload cycle to end once we
     #   detect that no more runs are active, so this code can be reached.
     print("Done! View your TensorBoard at %s" % url)
Esempio n. 2
0
 def execute(self, server_info, channel):
     api_client = write_service_pb2_grpc.TensorBoardWriterServiceStub(
         channel)
     experiment_id = self.experiment_id
     _die_if_bad_experiment_name(self.name)
     _die_if_bad_experiment_description(self.description)
     if not experiment_id:
         raise base_plugin.FlagsError(
             "Must specify a non-empty experiment ID to modify.")
     try:
         uploader_lib.update_experiment_metadata(
             api_client,
             experiment_id,
             name=self.name,
             description=self.description,
         )
     except uploader_lib.ExperimentNotFoundError:
         _die("No such experiment %s. Either it never existed or it has "
              "already been deleted." % experiment_id)
     except uploader_lib.PermissionDeniedError:
         _die("Cannot modify experiment %s because it is owned by a "
              "different user." % experiment_id)
     except uploader_lib.InvalidArgumentError as e:
         _die("Server cannot modify experiment as requested: %s" % e)
     except grpc.RpcError as e:
         _die("Internal error modifying experiment: %s" % e)
     logging.info("Modified experiment %s.", experiment_id)
     if self.name is not None:
         logging.info("Set name to %r", self.name)
     if self.description is not None:
         logging.info("Set description to %r", repr(self.description))
Esempio n. 3
0
 def execute(self, server_info, channel):
     if self.dry_run:
         api_client = dry_run_stubs.DryRunTensorBoardWriterStub()
     else:
         api_client = write_service_pb2_grpc.TensorBoardWriterServiceStub(
             channel
         )
     _die_if_bad_experiment_name(self.name)
     _die_if_bad_experiment_description(self.description)
     uploader = uploader_lib.TensorBoardUploader(
         api_client,
         self.logdir,
         allowed_plugins=server_info_lib.allowed_plugins(server_info),
         upload_limits=server_info_lib.upload_limits(server_info),
         name=self.name,
         description=self.description,
         verbosity=self.verbosity,
         one_shot=self.one_shot,
     )
     if self.one_shot and not os.path.isdir(self.logdir):
         print("%s: No such directory." % self.logdir)
         print(
             "User specified `one_shot` mode with an unavailable "
             "logdir. Exiting without creating an experiment."
         )
         return
     experiment_id = uploader.create_experiment()
     url = server_info_lib.experiment_url(server_info, experiment_id)
     if self.experiment_url_callback is not None:
         self.experiment_url_callback(url)
     print(
         "Upload started and will continue reading any new data as it's "
         "added to the logdir.\n\nTo stop uploading, press Ctrl-C."
     )
     if self.dry_run:
         print(
             "\n** This is a dry run. "
             "No data will be sent to tensorboard.dev. **\n"
         )
     else:
         print("\nView your TensorBoard live at: %s\n" % url)
     interrupted = False
     try:
         uploader.start_uploading()
     except uploader_lib.ExperimentNotFoundError:
         print("Experiment was deleted; uploading has been cancelled")
         return
     except KeyboardInterrupt:
         interrupted = True
     finally:
         end_message = "\n"
         if interrupted:
             end_message += "Interrupted."
         else:
             end_message += "Done."
         if not self.dry_run:
             end_message += " View your TensorBoard at %s" % url
         sys.stdout.write(end_message + "\n")
         sys.stdout.flush()
Esempio n. 4
0
 def _create_mock_client(self):
     # Create a stub instance (using a test channel) in order to derive a mock
     # from it with autospec enabled. Mocking TensorBoardWriterServiceStub itself
     # doesn't work with autospec because grpc constructs stubs via metaclassing.
     test_channel = grpc_testing.channel(
         service_descriptors=[], time=grpc_testing.strict_real_time()
     )
     stub = write_service_pb2_grpc.TensorBoardWriterServiceStub(test_channel)
     mock_client = mock.create_autospec(stub)
     return mock_client
Esempio n. 5
0
def _create_mock_client():
    # Create a stub instance (using a test channel) in order to derive a mock
    # from it with autospec enabled. Mocking TensorBoardWriterServiceStub itself
    # doesn't work with autospec because grpc constructs stubs via metaclassing.
    test_channel = grpc_testing.channel(service_descriptors=[],
                                        time=grpc_testing.strict_real_time())
    stub = write_service_pb2_grpc.TensorBoardWriterServiceStub(test_channel)
    mock_client = mock.create_autospec(stub)
    fake_exp_response = write_service_pb2.CreateExperimentResponse(
        experiment_id="123", url="should not be used!")
    mock_client.CreateExperiment.return_value = fake_exp_response
    return mock_client
Esempio n. 6
0
 def execute(self, server_info, channel):
     api_client = write_service_pb2_grpc.TensorBoardWriterServiceStub(
         channel)
     if not self.experiment_id_list:
         raise base_plugin.FlagsError(
             "Must specify at least one experiment ID to delete.")
     # Map from eid to (msg, action) pair.
     results = {}
     NO_ACTION = "NO_ACTION"
     DIE_ACTION = "DIE_ACTION"
     for experiment_id in set(self.experiment_id_list):
         if not experiment_id:
             results[experiment_id] = (
                 "Skipping empty experiment_id.",
                 NO_ACTION,
             )
             continue
         try:
             uploader_lib.delete_experiment(api_client, experiment_id)
             results[experiment_id] = (
                 "Deleted experiment %s." % experiment_id,
                 NO_ACTION,
             )
         except uploader_lib.ExperimentNotFoundError:
             results[experiment_id] = (
                 "No such experiment %s. Either it never existed or it has "
                 "already been deleted." % experiment_id,
                 DIE_ACTION,
             )
         except uploader_lib.PermissionDeniedError:
             results[experiment_id] = (
                 "Cannot delete experiment %s because it is owned by a "
                 "different user." % experiment_id,
                 DIE_ACTION,
             )
         except grpc.RpcError as e:
             results[experiment_id] = (
                 ("Internal error deleting experiment %s: %s." %
                  (experiment_id, e)),
                 DIE_ACTION,
             )
     # business logic on the receipt
     any_die_action = False
     err_msg = ""
     for (msg, action) in results.values():
         if action == NO_ACTION:
             print(msg)
         if action == DIE_ACTION:
             err_msg += msg + "\n"
             any_die_action = True
     if any_die_action:
         _die(err_msg)
Esempio n. 7
0
 def execute(self, server_info, channel):
     api_client = write_service_pb2_grpc.TensorBoardWriterServiceStub(
         channel)
     experiment_id = self.experiment_id
     if not experiment_id:
         raise base_plugin.FlagsError(
             "Must specify a non-empty experiment ID to delete.")
     try:
         uploader_lib.delete_experiment(api_client, experiment_id)
     except uploader_lib.ExperimentNotFoundError:
         _die("No such experiment %s. Either it never existed or it has "
              "already been deleted." % experiment_id)
     except uploader_lib.PermissionDeniedError:
         _die("Cannot delete experiment %s because it is owned by a "
              "different user." % experiment_id)
     except grpc.RpcError as e:
         _die("Internal error deleting experiment: %s" % e)
     print("Deleted experiment %s." % experiment_id)
Esempio n. 8
0
 def execute(self, server_info, channel):
     if self.dry_run:
         api_client = dry_run_stubs.DryRunTensorBoardWriterStub()
     else:
         api_client = write_service_pb2_grpc.TensorBoardWriterServiceStub(
             channel
         )
     _die_if_bad_experiment_name(self.name)
     _die_if_bad_experiment_description(self.description)
     uploader = uploader_lib.TensorBoardUploader(
         api_client,
         self.logdir,
         allowed_plugins=server_info_lib.allowed_plugins(server_info),
         upload_limits=server_info_lib.upload_limits(server_info),
         name=self.name,
         description=self.description,
         verbosity=self.verbosity,
         one_shot=self.one_shot,
     )
     experiment_id = uploader.create_experiment()
     url = server_info_lib.experiment_url(server_info, experiment_id)
     print(
         "Upload started and will continue reading any new data as it's added"
     )
     print("to the logdir. To stop uploading, press Ctrl-C.")
     if self.dry_run:
         print(
             "\n** This is a dry run. "
             "No data will be sent to tensorboard.dev. **\n"
         )
     else:
         print("View your TensorBoard live at: %s" % url)
     try:
         uploader.start_uploading()
     except uploader_lib.ExperimentNotFoundError:
         print("Experiment was deleted; uploading has been cancelled")
         return
     except KeyboardInterrupt:
         pass
     finally:
         if not self.dry_run:
             print()
             print("Done! View your TensorBoard at %s" % url)
Esempio n. 9
0
    def execute(self):
        api_client = write_service_pb2_grpc.TensorBoardWriterServiceStub(
            self.channel)

        uploader = uploader_lib.TensorBoardUploader(
            api_client,
            self.args.logdir,
            allowed_plugins=server_info_lib.allowed_plugins(self.server_info),
            name=self.args.name,
            description=self.args.description,
        )
        experiment_id = uploader.create_experiment()
        url = server_info_lib.experiment_url(self.server_info, experiment_id)

        # Blocks forever to continuously upload data from the logdir
        #print("Upload started and will continue reading any new data as it's added")
        #print("View your TensorBoard live at: %s" % url)
        #uploader.start_uploading()
        # Runs one upload cycle
        uploader._upload_once()

        return url