diff options
| author | robot-piglet <[email protected]> | 2024-02-14 13:31:06 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2024-02-14 13:41:14 +0300 |
| commit | f712f1ef01ce85418be783606914eb7ccfb51c08 (patch) | |
| tree | dc79a330d350106f6e95d014de2c2362eebdd4b9 | |
| parent | dc2f170b5ffa9adec92ab22a0d59e87e9a96a8e1 (diff) | |
Intermediate changes
10 files changed, 48 insertions, 28 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA index 8338cfd8cc6..29c5c3f3236 100644 --- a/contrib/python/hypothesis/py3/.dist-info/METADATA +++ b/contrib/python/hypothesis/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: hypothesis -Version: 6.97.1 +Version: 6.97.3 Summary: A library for property-based testing Home-page: https://hypothesis.works Author: David R. MacIver and Zac Hatfield-Dodds diff --git a/contrib/python/hypothesis/py3/hypothesis/core.py b/contrib/python/hypothesis/py3/hypothesis/core.py index 17876c37157..601c33e176d 100644 --- a/contrib/python/hypothesis/py3/hypothesis/core.py +++ b/contrib/python/hypothesis/py3/hypothesis/core.py @@ -628,7 +628,7 @@ def get_random_for_wrapped_test(test, wrapped_test): return Random(global_force_seed) else: global _hypothesis_global_random - if _hypothesis_global_random is None: + if _hypothesis_global_random is None: # pragma: no cover _hypothesis_global_random = Random() seed = _hypothesis_global_random.getrandbits(128) wrapped_test._hypothesis_internal_use_generated_seed = seed @@ -1054,7 +1054,9 @@ class StateForActualGivenExecution: if TESTCASE_CALLBACKS: if self.failed_normally or self.failed_due_to_deadline: phase = "shrink" - else: + elif runner := getattr(self, "_runner", None): + phase = runner._current_phase + else: # pragma: no cover # in case of messing with internals phase = "unknown" tc = make_testcase( start_timestamp=self._start_timestamp, @@ -1084,7 +1086,7 @@ class StateForActualGivenExecution: else: database_key = None - runner = ConjectureRunner( + runner = self._runner = ConjectureRunner( self._execute_once_for_engine, settings=self.settings, random=self.random, @@ -1510,8 +1512,7 @@ def given( except UnsatisfiedAssumption: raise DidNotReproduce( "The test data failed to satisfy an assumption in the " - "test. Have you added it since this blob was " - "generated?" + "test. Have you added it since this blob was generated?" ) from None # There was no @reproduce_failure, so start by running any explicit diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py index 961774816f8..99a170ca647 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py @@ -129,6 +129,7 @@ class ConjectureRunner: # Global dict of per-phase statistics, and a list of per-call stats # which transfer to the global dict at the end of each phase. + self._current_phase = "(not a phase)" self.statistics = {} self.stats_per_test_case = [] @@ -175,6 +176,7 @@ class ConjectureRunner: self.stats_per_test_case.clear() start_time = time.perf_counter() try: + self._current_phase = phase yield finally: self.statistics[phase + "-phase"] = { @@ -554,7 +556,7 @@ class ConjectureRunner: corpus.extend(extra) for existing in corpus: - data = self.cached_test_function(existing) + data = self.cached_test_function(existing, extend=BUFFER_SIZE) if data.status != Status.INTERESTING: self.settings.database.delete(self.database_key, existing) self.settings.database.delete(self.secondary_key, existing) @@ -569,7 +571,7 @@ class ConjectureRunner: pareto_corpus.sort(key=sort_key) for existing in pareto_corpus: - data = self.cached_test_function(existing) + data = self.cached_test_function(existing, extend=BUFFER_SIZE) if data not in self.pareto_front: self.settings.database.delete(self.pareto_key, existing) if data.status == Status.INTERESTING: @@ -693,6 +695,7 @@ class ConjectureRunner: ran_optimisations = False while self.should_generate_more(): + self._current_phase = "generate" prefix = self.generate_novel_prefix() assert len(prefix) <= BUFFER_SIZE if ( @@ -763,6 +766,7 @@ class ConjectureRunner: and not ran_optimisations ): ran_optimisations = True + self._current_phase = "target" self.optimise_targets() def generate_mutations_from(self, data): @@ -884,7 +888,8 @@ class ConjectureRunner: if any_improvements: continue - self.pareto_optimise() + if self.best_observed_targets: + self.pareto_optimise() if prev_calls == self.call_count: break @@ -902,6 +907,7 @@ class ConjectureRunner: # but if we've been asked to run it but not generation then we have to # run it explciitly on its own here. if Phase.generate not in self.settings.phases: + self._current_phase = "target" self.optimise_targets() with self._log_phase_statistics("shrink"): self.shrink_interesting_examples() @@ -1011,6 +1017,7 @@ class ConjectureRunner: predicate, allow_transition=allow_transition, explain=Phase.explain in self.settings.phases, + in_target_phase=self._current_phase == "target", ) def cached_test_function(self, buffer, *, error_on_discard=False, extend=0): diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/pareto.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/pareto.py index d82408f97ee..146b1b56f4f 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/pareto.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/pareto.py @@ -317,7 +317,7 @@ class ParetoOptimiser: # If ``destination`` dominates ``source`` then ``source`` # must be dominated in the front - either ``destination`` is in # the front, or it was not added to it because it was - # dominated by something in it., + # dominated by something in it. try: self.front.front.remove(source) except ValueError: diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py index f965829759a..39a515d2962 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py @@ -271,6 +271,7 @@ class Shrinker: *, allow_transition: bool, explain: bool, + in_target_phase: bool = False, ): """Create a shrinker for a particular engine, with a given starting point and predicate. When shrink() is called it will attempt to find an @@ -309,6 +310,14 @@ class Shrinker: # testing and learning purposes. self.extra_dfas: Dict[str, ConcreteDFA] = {} + # Because the shrinker is also used to `pareto_optimise` in the target phase, + # we sometimes want to allow extending buffers instead of aborting at the end. + if in_target_phase: + from hypothesis.internal.conjecture.engine import BUFFER_SIZE + + self.__extend = BUFFER_SIZE + else: + self.__extend = 0 self.should_explain = explain @derived_value # type: ignore @@ -417,7 +426,7 @@ class Shrinker: with status >= INVALID that would result from running this buffer.""" buffer = bytes(buffer) - result = self.engine.cached_test_function(buffer) + result = self.engine.cached_test_function(buffer, extend=self.__extend) self.incorporate_test_data(result) if self.calls - self.calls_at_last_shrink >= self.max_stall: raise StopShrinking diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py index 81c33333c35..00661fde996 100644 --- a/contrib/python/hypothesis/py3/hypothesis/version.py +++ b/contrib/python/hypothesis/py3/hypothesis/version.py @@ -8,5 +8,5 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at https://mozilla.org/MPL/2.0/. -__version_info__ = (6, 97, 1) +__version_info__ = (6, 97, 3) __version__ = ".".join(map(str, __version_info__)) diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make index b2ecf2aa296..38361352c09 100644 --- a/contrib/python/hypothesis/py3/ya.make +++ b/contrib/python/hypothesis/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(6.97.1) +VERSION(6.97.3) LICENSE(MPL-2.0) diff --git a/util/generic/array_ref.pxd b/util/generic/array_ref.pxd index 41a4c72d697..a4ba42e357a 100644 --- a/util/generic/array_ref.pxd +++ b/util/generic/array_ref.pxd @@ -3,23 +3,23 @@ from libcpp cimport bool as bool_t cdef extern from "util/generic/array_ref.h" nogil: cdef cppclass TArrayRef[T]: - TArrayRef(...) except + + TArrayRef(...) T& operator[](size_t) bool_t empty() - T* data() except + - size_t size() except + - T* begin() except + - T* end() except + + T* data() + size_t size() + T* begin() + T* end() cdef cppclass TConstArrayRef[T]: - TConstArrayRef(...) except + + TConstArrayRef(...) const T& operator[](size_t) bool_t empty() - const T* data() except + - size_t size() except + - const T* begin() except + - const T* end() except + + const T* data() + size_t size() + const T* begin() + const T* end() diff --git a/yt/yt/client/federated/cache.cpp b/yt/yt/client/federated/cache.cpp index 39ad3fbe1bf..a3462977fb8 100644 --- a/yt/yt/client/federated/cache.cpp +++ b/yt/yt/client/federated/cache.cpp @@ -37,13 +37,14 @@ protected: StringSplitter(clusterUrl).SplitByString(ClusterSeparator_).SkipEmpty().Collect(&clusters); switch (clusters.size()) { case 0: - THROW_ERROR_EXCEPTION("Can't create client without cluster"); + THROW_ERROR_EXCEPTION("Cannot create client without cluster"); case 1: return NCache::CreateClient(NCache::MakeClusterConfig(ClustersConfig_, clusterUrl), Options_); default: return CreateFederatedClient(clusters); } } + private: NApi::IClientPtr CreateFederatedClient(const std::vector<TString>& clusters) { @@ -51,24 +52,25 @@ private: for (const auto& connectionConfig : FederationConfig_->RpcProxyConnections) { THROW_ERROR_EXCEPTION_UNLESS( connectionConfig->ClusterUrl, - "Cluster url is mandatory for federated client connection config"); + "Cluster URL is mandatory for federated client connection config"); seenClusters.insert(connectionConfig->ClusterUrl.value()); } THROW_ERROR_EXCEPTION_UNLESS( clusters.size() == seenClusters.size(), - "Desired (%v) and configured (%v) clusters count mismatch", + "Numbers of desired (%Qv) and configured (%Qv) clusters do not match", clusters, seenClusters); for (const auto& cluster : clusters) { THROW_ERROR_EXCEPTION_UNLESS( seenClusters.contains(cluster), - "No federated client configuration for cluster %v", cluster); + "No federated client configuration for cluster %Qv", cluster); } if (!FederatedConnection_) { - NYT::NApi::NRpcProxy::TConnectionOptions options; // TODO(ashishkin): use proper invoker here? + // TODO(ashishkin): use proper invoker here? + NYT::NApi::NRpcProxy::TConnectionOptions options; FederatedConnection_ = CreateConnection(FederationConfig_, std::move(options)); } return FederatedConnection_->CreateClient(Options_); diff --git a/yt/yt/client/federated/unittests/cache_ut.cpp b/yt/yt/client/federated/unittests/cache_ut.cpp index d13bfff5ddf..5f5fdf1a913 100644 --- a/yt/yt/client/federated/unittests/cache_ut.cpp +++ b/yt/yt/client/federated/unittests/cache_ut.cpp @@ -2,6 +2,7 @@ #include <yt/yt/client/federated/config.h> #include <yt/yt/client/api/options.h> #include <yt/yt/client/cache/cache.h> + #include <yt/yt/core/misc/error.h> #include <yt/yt_proto/yt/client/cache/proto/config.pb.h> |
