types: fix type checking errors in dvc.experiments (#4949)

This commit is contained in:
Saugat Pachhai
2020-11-24 07:22:42 +05:45
committed by GitHub
parent cb56f57908
commit 85ad7358d9
2 changed files with 12 additions and 8 deletions
+7 -8
View File
@@ -9,7 +9,7 @@ from collections.abc import Mapping
from concurrent.futures import ThreadPoolExecutor, as_completed
from contextlib import contextmanager
from functools import partial, wraps
from typing import Iterable, Optional
from typing import Iterable, Optional, no_type_check
from funcy import cached_property, first
@@ -375,11 +375,9 @@ class Experiments:
if not self.scm.is_dirty(untracked_files=True):
raise UnchangedExperimentError(self.scm.get_rev())
rev = self.scm.get_rev()
if not baseline_rev:
baseline_rev = rev
checkpoint = "-checkpoint" if checkpoint else ""
exp_name = f"{baseline_rev[:7]}-{exp_hash}{checkpoint}"
rev = baseline_rev or self.scm.get_rev()
suffix = "-checkpoint" if checkpoint else ""
exp_name = f"{rev[:7]}-{exp_hash}{suffix}"
if create_branch:
if (
check_exists or checkpoint
@@ -450,7 +448,7 @@ class Experiments:
"""
if checkpoint_resume is not None:
return self._resume_checkpoint(
*args, **kwargs, checkpoint_resume=checkpoint_resume
*args, checkpoint_resume=checkpoint_resume, **kwargs
)
if branch:
@@ -628,7 +626,7 @@ class Experiments:
Returns dict containing successfully executed experiments.
"""
result = {}
result: dict = {}
collect_lock = threading.Lock()
@@ -701,6 +699,7 @@ class Experiments:
finally:
lock.release()
@no_type_check
def _checkpoint_callback(
self,
result: Mapping,
+5
View File
@@ -41,6 +41,7 @@ class ExperimentExecutor:
self.branch = branch
self.repro_args = kwargs.pop("repro_args", [])
self.repro_kwargs = kwargs.pop("repro_kwargs", {})
self.tmp_dir: Optional[TemporaryDirectory] = None
@property
def tree(self) -> BaseTree:
@@ -86,6 +87,10 @@ class ExperimentExecutor:
data = pickle.load(fobj)
return data["args"], data["kwargs"]
@staticmethod
def collect_files(tree: BaseTree, repo_tree: RepoTree):
raise NotImplementedError
class LocalExecutor(ExperimentExecutor):
"""Local machine experiment executor."""