mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Revert "[BE][Easy] replace import pathlib
with from pathlib import Path
(#129426)"
This reverts commit 6d75604ef135925e8c85363c2f4a5e0b6f7fef28. Reverted https://github.com/pytorch/pytorch/pull/129426 on behalf of https://github.com/XuehaiPan due to recognize `Path` as new exported API ([comment](https://github.com/pytorch/pytorch/pull/129426#issuecomment-2198371625))
This commit is contained in:
@ -1,16 +1,13 @@
|
||||
# Owner(s): ["module: unknown"]
|
||||
|
||||
import expecttest
|
||||
import io
|
||||
import numpy as np
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import expecttest
|
||||
import numpy as np
|
||||
|
||||
|
||||
TEST_TENSORBOARD = True
|
||||
try:
|
||||
@ -39,15 +36,14 @@ skipIfNoMatplotlib = unittest.skipIf(not TEST_MATPLOTLIB, "no matplotlib")
|
||||
import torch
|
||||
from torch.testing._internal.common_utils import (
|
||||
instantiate_parametrized_tests,
|
||||
IS_MACOS,
|
||||
IS_WINDOWS,
|
||||
parametrize,
|
||||
TestCase,
|
||||
run_tests,
|
||||
TEST_WITH_CROSSREF,
|
||||
TestCase,
|
||||
IS_WINDOWS,
|
||||
IS_MACOS,
|
||||
)
|
||||
|
||||
|
||||
def tensor_N(shape, dtype=float):
|
||||
numel = np.prod(shape)
|
||||
x = (np.arange(numel, dtype=dtype)).reshape(shape)
|
||||
@ -79,16 +75,15 @@ class BaseTestCase(TestCase):
|
||||
|
||||
|
||||
if TEST_TENSORBOARD:
|
||||
from google.protobuf import text_format
|
||||
from PIL import Image
|
||||
from tensorboard.compat.proto.graph_pb2 import GraphDef
|
||||
from tensorboard.compat.proto.types_pb2 import DataType
|
||||
|
||||
from torch.utils.tensorboard import summary, SummaryWriter
|
||||
from torch.utils.tensorboard._utils import _prepare_video, convert_to_HWC
|
||||
from tensorboard.compat.proto.types_pb2 import DataType
|
||||
from torch.utils.tensorboard.summary import int_to_half, tensor_proto
|
||||
from torch.utils.tensorboard._convert_np import make_np
|
||||
from torch.utils.tensorboard._pytorch_graph import graph
|
||||
from torch.utils.tensorboard._utils import _prepare_video, convert_to_HWC
|
||||
from torch.utils.tensorboard.summary import int_to_half, tensor_proto
|
||||
from google.protobuf import text_format
|
||||
from PIL import Image
|
||||
|
||||
class TestTensorBoardPyTorchNumpy(BaseTestCase):
|
||||
def test_pytorch_np(self):
|
||||
@ -294,8 +289,9 @@ class TestTensorBoardSummaryWriter(BaseTestCase):
|
||||
self.assertTrue(passed)
|
||||
|
||||
def test_pathlib(self):
|
||||
import pathlib
|
||||
with tempfile.TemporaryDirectory(prefix="test_tensorboard_pathlib") as d:
|
||||
p = Path(d)
|
||||
p = pathlib.Path(d)
|
||||
with SummaryWriter(p) as writer:
|
||||
writer.add_scalar('test', 1)
|
||||
|
||||
|
Reference in New Issue
Block a user