Skip to content

Commit

Permalink
fix PickleError when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amyasnikov committed Oct 16, 2024
1 parent 0e7f89b commit 275035f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions validity/scripts/runtests/apply.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from functools import cached_property
from functools import cached_property, partial
from itertools import chain
from typing import Annotated, Any, Callable, Iterable, Iterator

Expand All @@ -10,7 +10,6 @@
from validity.compliance.eval.eval_defaults import DEFAULT_NAMESET
from validity.compliance.exceptions import EvalError, SerializationError
from validity.models import ComplianceSelector, ComplianceTest, ComplianceTestResult, NameSet, VDataSource, VDevice
from validity.utils.misc import partialcls
from ..data_models import ExecutionResult, FullRunTestsParams, TestResultRatio
from ..logger import Logger
from ..parent_jobs import JobExtractor
Expand Down Expand Up @@ -136,7 +135,9 @@ class ApplyWorker:
Provides a function to execute specified tests, save the results to DB and return ExecutionResult
"""

test_executor_cls: type[TestExecutor] = partialcls(TestExecutor, extra_globals=DEFAULT_NAMESET)
test_executor_factory: Callable[[int, int, int], TestExecutor] = partial(
TestExecutor, extra_globals=DEFAULT_NAMESET
)
logger_factory: Callable[[str], Logger] = Logger
device_test_gen: type[DeviceTestIterator] = DeviceTestIterator
result_batch_size: Annotated[int, "validity_settings.result_batch_size"]
Expand All @@ -145,7 +146,7 @@ class ApplyWorker:

def __call__(self, *, params: FullRunTestsParams, worker_id: int) -> ExecutionResult:
try:
executor = self.test_executor_cls(worker_id, params.explanation_verbosity, params.report_id)
executor = self.test_executor_factory(worker_id, params.explanation_verbosity, params.report_id)
test_results = self.get_test_results(params, worker_id, executor)
self.save_results_to_db(test_results)
return ExecutionResult(
Expand Down

0 comments on commit 275035f

Please sign in to comment.