From be602fe1c7b93cb43113689ad0be0d23b4dbf184 Mon Sep 17 00:00:00 2001
From: Yifan Zhao <yifanz16@illinois.edu>
Date: Mon, 25 Jan 2021 03:46:03 -0600
Subject: [PATCH] Fixed PathLike being defined everywhere

---
 predtuner/_dbloader.py         | 4 ++--
 predtuner/approxapp.py         | 5 ++---
 predtuner/approxes/approxes.py | 5 ++---
 predtuner/modeledapp.py        | 4 ++--
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/predtuner/_dbloader.py b/predtuner/_dbloader.py
index 834ca7d..702e48a 100644
--- a/predtuner/_dbloader.py
+++ b/predtuner/_dbloader.py
@@ -1,15 +1,15 @@
 import logging
 from pathlib import Path
-from typing import List, Tuple, Union
+from typing import List, Tuple
 
 from opentuner import resultsdb
 from opentuner.resultsdb.models import Configuration, Result, TuningRun
 from sqlalchemy.orm.session import Session
 from sqlalchemy.sql.expression import func
 
+from ._logging import PathLike
 
 msg_logger = logging.getLogger(__name__)
-PathLike = Union[Path, str]
 
 
 def read_opentuner_db(filepath_or_uri: PathLike) -> List[Tuple[Result, Configuration]]:
diff --git a/predtuner/approxapp.py b/predtuner/approxapp.py
index c1f86f8..5b38a8d 100644
--- a/predtuner/approxapp.py
+++ b/predtuner/approxapp.py
@@ -1,19 +1,18 @@
 import abc
 import logging
 from pathlib import Path
-from typing import Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union
+from typing import Dict, Generic, List, Optional, Tuple, Type, TypeVar
 
 import matplotlib.pyplot as plt
 import numpy as np
 from opentuner.measurement.interface import MeasurementInterface
 from opentuner.search.manipulator import ConfigurationManipulator, EnumParameter
 
-from ._logging import override_opentuner_config
+from ._logging import PathLike, override_opentuner_config
 from ._pareto import is_pareto_efficient
 
 msg_logger = logging.getLogger(__name__)
 KnobsT = Dict[str, str]
-PathLike = Union[Path, str]
 TunerConfigT = Dict[int, int]
 
 
diff --git a/predtuner/approxes/approxes.py b/predtuner/approxes/approxes.py
index 25aaf92..4882522 100644
--- a/predtuner/approxes/approxes.py
+++ b/predtuner/approxes/approxes.py
@@ -1,15 +1,14 @@
 """Approximation techniques for torch.nn layers."""
 from pathlib import Path
-from typing import Dict, Iterable, Set, Type, Union
+from typing import Dict, Iterable, Set, Type
 
 import torch
 from torch.nn import Conv2d, Linear, Module, Parameter
 
+from .._logging import PathLike
 from ..torchapp import BaselineKnob, TorchApproxKnob
 from ._copy import module_only_deepcopy
 
-PathLike = Union[Path, str]
-
 
 def _interpolate_first_dim(tensor: torch.Tensor, interp_indices: Iterable[int]):
     def tensor_at(idx_: int):
diff --git a/predtuner/modeledapp.py b/predtuner/modeledapp.py
index b48633e..b4eee06 100644
--- a/predtuner/modeledapp.py
+++ b/predtuner/modeledapp.py
@@ -9,10 +9,10 @@ import numpy as np
 import pandas as pd
 import torch
 
-from .approxapp import ApproxApp, ApproxKnob, ApproxTuner, Config, KnobsT
+from .approxapp import ApproxApp, ApproxTuner, Config, KnobsT
+from ._logging import PathLike
 
 msg_logger = logging.getLogger(__name__)
-PathLike = Union[Path, str]
 
 
 class ModeledApp(ApproxApp, abc.ABC):
-- 
GitLab