Example #1
0
def upload_limits(server_info):
    """Returns UploadLimits, from server_info if possible, otherwise from defaults.

    Args:
      server_info: A `server_info_pb2.ServerInfoResponse` message.

    Returns:
      An instance of UploadLimits.
    """
    if server_info.HasField("upload_limits"):
        upload_limits = server_info.upload_limits
    else:
        upload_limits = server_info_pb2.UploadLimits()

    if not upload_limits.max_scalar_request_size:
        upload_limits.max_scalar_request_size = _DEFAULT_MAX_SCALAR_REQUEST_SIZE
    if not upload_limits.max_tensor_request_size:
        upload_limits.max_tensor_request_size = _DEFAULT_MAX_TENSOR_REQUEST_SIZE
    if not upload_limits.max_blob_request_size:
        upload_limits.max_blob_request_size = _DEFAULT_MAX_BLOB_REQUEST_SIZE
    if not upload_limits.min_scalar_request_interval:
        upload_limits.min_scalar_request_interval = (
            _DEFAULT_MIN_SCALAR_REQUEST_INTERVAL)
    if not upload_limits.min_tensor_request_interval:
        upload_limits.min_tensor_request_interval = (
            _DEFAULT_MIN_TENSOR_REQUEST_INTERVAL)
    if not upload_limits.min_blob_request_interval:
        upload_limits.min_blob_request_interval = (
            _DEFAULT_MIN_BLOB_REQUEST_INTERVAL)
    if not upload_limits.max_blob_size:
        upload_limits.max_blob_size = _DEFAULT_MAX_BLOB_SIZE

    if not upload_limits.max_tensor_point_size:
        upload_limits.max_tensor_point_size = _DEFAULT_MAX_TENSOR_POINT_SIZE
    return upload_limits
def _make_upload_limits() -> server_info_pb2.UploadLimits:
    """Creates the upload limits for tensorboard.

    Returns:
        An UploadLimits object.
    """
    upload_limits = server_info_pb2.UploadLimits()
    upload_limits.min_blob_request_interval = 10
    upload_limits.max_blob_request_size = 4 * (2**20) - 256 * (2**10)
    upload_limits.max_blob_size = 10 * (2**30)  # 10GiB

    return upload_limits
Example #3
0
    def test_upload_limits_from_server_info(self):
        info_upload_limits = server_info_pb2.UploadLimits()
        info_upload_limits.max_scalar_request_size = 1
        info_upload_limits.max_tensor_request_size = 2
        info_upload_limits.max_blob_request_size = 3
        info_upload_limits.min_scalar_request_interval = 4
        info_upload_limits.min_tensor_request_interval = 5
        info_upload_limits.min_blob_request_interval = 6
        info_upload_limits.max_blob_size = 7
        info_upload_limits.max_tensor_point_size = 8

        info = server_info_pb2.ServerInfoResponse()
        info.upload_limits.CopyFrom(info_upload_limits)

        actual = server_info.upload_limits(info)
        self.assertEqual(actual, info_upload_limits)
Example #4
0
    def test_no_upload_limits_in_server_info(self):
        info = server_info_pb2.ServerInfoResponse()
        actual = server_info.upload_limits(info)

        expected = server_info_pb2.UploadLimits()
        expected.max_scalar_request_size = (
            server_info._DEFAULT_MAX_SCALAR_REQUEST_SIZE)
        expected.max_tensor_request_size = (
            server_info._DEFAULT_MAX_TENSOR_REQUEST_SIZE)
        expected.max_blob_request_size = (
            server_info._DEFAULT_MAX_BLOB_REQUEST_SIZE)
        expected.min_scalar_request_interval = (
            server_info._DEFAULT_MIN_SCALAR_REQUEST_INTERVAL)
        expected.min_tensor_request_interval = (
            server_info._DEFAULT_MIN_TENSOR_REQUEST_INTERVAL)
        expected.min_blob_request_interval = (
            server_info._DEFAULT_MIN_BLOB_REQUEST_INTERVAL)
        expected.max_blob_size = server_info._DEFAULT_MAX_BLOB_SIZE
        expected.max_tensor_point_size = (
            server_info._DEFAULT_MAX_TENSOR_POINT_SIZE)
        self.assertEqual(actual, expected)
 def testUploadIntentUnderDryRunOneShot(self):
     """Test the upload intent under the dry-run + one-shot mode."""
     mock_server_info = mock.MagicMock()
     mock_channel = mock.MagicMock()
     upload_limits = server_info_pb2.UploadLimits(
         max_scalar_request_size=128000,
         max_tensor_request_size=128000,
         max_tensor_point_size=11111,
         max_blob_request_size=128000,
         max_blob_size=128000,
     )
     mock_stdout_write = mock.MagicMock()
     with mock.patch.object(
         server_info_lib,
         "allowed_plugins",
         return_value=_SCALARS_HISTOGRAMS_AND_GRAPHS,
     ), mock.patch.object(
         server_info_lib, "upload_limits", return_value=upload_limits
     ), mock.patch.object(
         sys.stdout, "write", mock_stdout_write
     ), mock.patch.object(
         dry_run_stubs,
         "DryRunTensorBoardWriterStub",
         side_effect=dry_run_stubs.DryRunTensorBoardWriterStub,
     ) as mock_dry_run_stub:
         intent = uploader_subcommand.UploadIntent(
             self.get_temp_dir(), dry_run=True, one_shot=True
         )
         intent.execute(mock_server_info, mock_channel)
     self.assertEqual(mock_dry_run_stub.call_count, 1)
     self.assertRegex(
         mock_stdout_write.call_args_list[-2][0][0],
         ".*Done scanning logdir.*",
     )
     self.assertEqual(
         mock_stdout_write.call_args_list[-1][0][0], "\nDone.\n"
     )