Skip to content

Commit

Permalink
Add settings.py of testgen
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed May 9, 2023
1 parent d4be8f1 commit 1008714
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import json
from typing import Iterable, AnyStr, Any, Callable
import traceback
import multiprocessing
from collections import namedtuple

from ruamel.yaml import (
Expand All @@ -28,21 +27,19 @@
from eth2spec.test.exceptions import SkippedTest

from .gen_typing import TestProvider
from .settings import (
GENERATOR_MODE,
MODE_MULTIPROCESSING,
MODE_SINGLE_PROCESS,
NUM_PROCESS,
TIME_THRESHOLD_TO_PRINT,
)


# Flag that the runner does NOT run test via pytest
context.is_pytest = False


TIME_THRESHOLD_TO_PRINT = 1.0 # seconds

# Generator mode setting
MODE_SINGLE_PROCESS = 'MODE_SINGLE_PROCESS'
MODE_MULTIPROCESSING = 'MODE_MULTIPROCESSING'

GENERATOR_MODE = MODE_MULTIPROCESSING


@dataclass
class Diagnostics(object):
collected_test_count: int = 0
Expand Down Expand Up @@ -243,8 +240,7 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
all_test_case_params.append(item)

if GENERATOR_MODE == MODE_MULTIPROCESSING:
num_process = multiprocessing.cpu_count() // 2 - 1
with Pool(processes=num_process) as pool:
with Pool(processes=NUM_PROCESS) as pool:
results = pool.map(worker_function, iter(all_test_case_params))

for result in results:
Expand Down
13 changes: 13 additions & 0 deletions tests/core/pyspec/eth2spec/gen_helpers/gen_base/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import multiprocessing


# Generator mode setting
MODE_SINGLE_PROCESS = 'MODE_SINGLE_PROCESS'
MODE_MULTIPROCESSING = 'MODE_MULTIPROCESSING'
# Test generator mode
GENERATOR_MODE = MODE_MULTIPROCESSING
# Number of subprocesses when using MODE_MULTIPROCESSING
NUM_PROCESS = multiprocessing.cpu_count() // 2 - 1

# Diagnostics
TIME_THRESHOLD_TO_PRINT = 1.0 # seconds

0 comments on commit 1008714

Please sign in to comment.