haiway 0.15.2__tar.gz → 0.17.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {haiway-0.15.2 → haiway-0.17.0}/Makefile +1 -1
- {haiway-0.15.2 → haiway-0.17.0}/PKG-INFO +1 -1
- {haiway-0.15.2 → haiway-0.17.0}/junit/test-results.xml +1 -1
- {haiway-0.15.2 → haiway-0.17.0}/pyproject.toml +1 -1
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/__init__.py +0 -2
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/context/__init__.py +0 -2
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/context/access.py +7 -62
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/context/metrics.py +0 -38
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/helpers/metrics.py +0 -36
- {haiway-0.15.2 → haiway-0.17.0}/uv.lock +32 -32
- {haiway-0.15.2 → haiway-0.17.0}/.github/workflows/ci.yml +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/.github/workflows/publish.yml +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/.gitignore +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/LICENSE +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/README.md +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/config/pre-push +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/.dockerignore +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/Dockerfile +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/Makefile +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/README.md +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/config/.env.example +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/config/unit.json +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/docker-compose.yml +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/pyproject.toml +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/features/__int__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/features/todos/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/features/todos/config.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/features/todos/state.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/features/todos/types.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/features/todos/user_tasks.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/integrations/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/integrations/postgres/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/integrations/postgres/client.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/integrations/postgres/config.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/integrations/postgres/state.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/integrations/postgres/types.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/migrations/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/migrations/__main__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/migrations/postgres/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/migrations/postgres/execution.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/migrations/postgres/migration_0.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/migrations/postgres/types.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/server/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/server/__main__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/server/application.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/server/config.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/server/middlewares/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/server/middlewares/context.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/server/routes/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/server/routes/technical.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/server/routes/todos.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/solutions/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/solutions/user_tasks/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/solutions/user_tasks/config.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/solutions/user_tasks/postgres.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/solutions/user_tasks/state.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/src/solutions/user_tasks/types.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/examples/fastAPI/uv.lock +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/guidelines/functionalities.md +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/guidelines/packages.md +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/context/disposables.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/context/identifier.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/context/logging.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/context/state.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/context/tasks.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/context/types.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/helpers/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/helpers/asynchrony.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/helpers/caching.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/helpers/retries.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/helpers/throttling.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/helpers/timeouted.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/helpers/tracing.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/py.typed +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/state/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/state/attributes.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/state/path.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/state/requirement.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/state/structure.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/state/validation.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/types/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/types/default.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/types/frozen.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/types/missing.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/always.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/collections.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/env.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/freezing.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/logs.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/mimic.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/noop.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/queue.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/src/haiway/utils/stream.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/__init__.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/test_async_queue.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/test_async_stream.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/test_attribute_path.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/test_auto_retry.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/test_cache.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/test_context.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/test_state.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/test_streaming.py +0 -0
- {haiway-0.15.2 → haiway-0.17.0}/tests/test_timeout.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: haiway
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.17.0
|
4
4
|
Summary: Framework for dependency injection and state management within structured concurrency model.
|
5
5
|
Project-URL: Homepage, https://miquido.com
|
6
6
|
Project-URL: Repository, https://github.com/miquido/haiway.git
|
@@ -1 +1 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="88" time="1.
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="88" time="1.112" timestamp="2025-05-01T12:14:10.633598" hostname="fv-az1372-752"><testcase classname="tests.test_async_queue" name="test_fails_when_stream_fails" time="0.001" /><testcase classname="tests.test_async_queue" name="test_cancels_when_iteration_cancels" time="0.001" /><testcase classname="tests.test_async_queue" name="test_ends_when_stream_ends" time="0.001" /><testcase classname="tests.test_async_queue" name="test_buffers_values_when_not_reading" time="0.001" /><testcase classname="tests.test_async_queue" name="test_delivers_buffer_when_streaming_fails" time="0.001" /><testcase classname="tests.test_async_queue" name="test_delivers_updates_when_sending" time="0.001" /><testcase classname="tests.test_async_queue" name="test_fails_when_sending_to_finished" time="0.001" /><testcase classname="tests.test_async_queue" name="test_ignores_when_finishing_when_finished" time="0.001" /><testcase classname="tests.test_async_stream" name="test_fails_when_stream_fails" time="0.001" /><testcase classname="tests.test_async_stream" name="test_cancels_when_iteration_cancels" time="0.001" /><testcase classname="tests.test_async_stream" name="test_ends_when_stream_ends" time="0.001" /><testcase classname="tests.test_async_stream" name="test_finishes_without_buffer" time="0.001" /><testcase classname="tests.test_async_stream" name="test_fails_without_buffer" time="0.001" /><testcase classname="tests.test_async_stream" name="test_delivers_updates_when_sending" time="0.001" /><testcase classname="tests.test_async_stream" name="test_ignores_when_sending_to_finished" time="0.001" /><testcase classname="tests.test_async_stream" name="test_ignores_when_sending_to_failed" time="0.001" /><testcase classname="tests.test_async_stream" name="test_ignores_when_finishing_when_finished" time="0.001" /><testcase classname="tests.test_async_stream" name="test_delivers_all_when_sending_async" time="0.001" /><testcase classname="tests.test_attribute_path" name="test_id_path_points_to_self" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_attribute_path_points_to_attribute" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_nested_attribute_path_points_to_nested_attribute" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_recursive_attribute_path_points_to_attribute" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_list_item_path_points_to_item" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_tuple_item_path_points_to_item" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_mixed_tuple_item_path_points_to_item" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_dict_item_path_points_to_item" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_id_path_set_updates_self" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_attribute_path_set_updates_attribute" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_nested_attribute_path_set_updates_nested_attribute" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_recursive_attribute_set_updates_attribute" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_list_item_path_set_updates_item" time="0.001" /><testcase classname="tests.test_attribute_path" name="test_tuple_item_path_set_updates_item" time="0.001" /><testcase classname="tests.test_attribute_path" name="test_mixed_tuple_item_set_updates_item" time="0.000" /><testcase classname="tests.test_attribute_path" name="test_dict_item_path_set_updates_item" time="0.000" /><testcase classname="tests.test_auto_retry" name="test_returns_value_without_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_retries_with_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_logs_issue_with_errors" time="0.005" /><testcase classname="tests.test_auto_retry" name="test_fails_with_exceeding_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_fails_with_cancellation" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_retries_with_selected_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_fails_with_not_selected_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_async_returns_value_without_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_async_retries_with_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_async_fails_with_exceeding_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_async_fails_with_cancellation" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_async_fails_when_cancelled" time="0.021" /><testcase classname="tests.test_auto_retry" name="test_async_uses_delay_with_errors" time="0.102" /><testcase classname="tests.test_auto_retry" name="test_async_uses_computed_delay_with_errors" time="0.107" /><testcase classname="tests.test_auto_retry" name="test_async_logs_issue_with_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_async_retries_with_selected_errors" time="0.001" /><testcase classname="tests.test_auto_retry" name="test_async_fails_with_not_selected_errors" time="0.001" /><testcase classname="tests.test_cache" name="test_returns_cache_value_with_same_argument" time="0.001" /><testcase classname="tests.test_cache" name="test_returns_fresh_value_with_different_argument" time="0.000" /><testcase classname="tests.test_cache" name="test_returns_fresh_value_with_limit_exceed" time="0.000" /><testcase classname="tests.test_cache" name="test_returns_same_value_with_repeating_argument" time="0.000" /><testcase classname="tests.test_cache" name="test_fails_with_error" time="0.000" /><testcase classname="tests.test_cache" name="test_returns_fresh_value_with_expiration_time_exceed" time="0.021" /><testcase classname="tests.test_cache" name="test_async_returns_cache_value_with_same_argument" time="0.001" /><testcase classname="tests.test_cache" name="test_async_returns_fresh_value_with_different_argument" time="0.001" /><testcase classname="tests.test_cache" name="test_async_returns_fresh_value_with_limit_exceed" time="0.001" /><testcase classname="tests.test_cache" name="test_async_returns_same_value_with_repeating_argument" time="0.001" /><testcase classname="tests.test_cache" name="test_async_returns_fresh_value_with_expiration_time_exceed" time="0.021" /><testcase classname="tests.test_cache" name="test_async_cancel_waiting_does_not_cancel_task" time="0.502" /><testcase classname="tests.test_cache" name="test_async_expiration_does_not_cancel_task" time="0.021" /><testcase classname="tests.test_cache" name="test_async_fails_with_error" time="0.001" /><testcase classname="tests.test_context" name="test_state_is_available_according_to_context" time="0.001" /><testcase classname="tests.test_context" name="test_state_update_updates_local_context" time="0.001" /><testcase classname="tests.test_context" name="test_exceptions_are_propagated" time="0.001" /><testcase classname="tests.test_state" name="test_basic_initializes_with_arguments" time="0.002" /><testcase classname="tests.test_state" name="test_basic_initializes_with_defaults" time="0.001" /><testcase classname="tests.test_state" name="test_basic_equals_checks_properties" time="0.000" /><testcase classname="tests.test_state" name="test_basic_initializes_with_arguments_and_defaults" time="0.000" /><testcase classname="tests.test_state" name="test_parametrized_initializes_with_proper_parameters" time="0.000" /><testcase classname="tests.test_state" name="test_nested_initializes_with_proper_arguments" time="0.001" /><testcase classname="tests.test_state" name="test_dict_skips_missing_properties" time="0.000" /><testcase classname="tests.test_state" name="test_initialization_allows_missing_properties" time="0.000" /><testcase classname="tests.test_state" name="test_generic_subtypes_validation" time="0.002" /><testcase classname="tests.test_state" name="test_copying_leaves_same_object" time="0.001" /><testcase classname="tests.test_streaming" name="test_fails_when_generator_fails" time="0.001" /><testcase classname="tests.test_streaming" name="test_cancels_when_iteration_cancels" time="0.001" /><testcase classname="tests.test_streaming" name="test_ends_when_generator_ends" time="0.001" /><testcase classname="tests.test_streaming" name="test_delivers_updates_when_generating" time="0.001" /><testcase classname="tests.test_streaming" name="test_streaming_context_variables_access_is_preserved" time="0.001" /><testcase classname="tests.test_streaming" name="test_nested_streaming_streams_correctly" time="0.001" /><testcase classname="tests.test_timeout" name="test_returns_result_when_returning_value" time="0.001" /><testcase classname="tests.test_timeout" name="test_raises_with_error" time="0.001" /><testcase classname="tests.test_timeout" name="test_raises_with_cancel" time="0.011" /><testcase classname="tests.test_timeout" name="test_raises_with_timeout" time="0.012" /></testsuite></testsuites>
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
5
5
|
[project]
|
6
6
|
name = "haiway"
|
7
7
|
description = "Framework for dependency injection and state management within structured concurrency model."
|
8
|
-
version = "0.
|
8
|
+
version = "0.17.0"
|
9
9
|
readme = "README.md"
|
10
10
|
maintainers = [
|
11
11
|
{ name = "Kacper Kaliński", email = "kacper.kalinski@miquido.com" },
|
@@ -3,7 +3,6 @@ from haiway.context import (
|
|
3
3
|
Disposables,
|
4
4
|
MetricsContext,
|
5
5
|
MetricsHandler,
|
6
|
-
MetricsReading,
|
7
6
|
MetricsRecording,
|
8
7
|
MetricsScopeEntering,
|
9
8
|
MetricsScopeExiting,
|
@@ -76,7 +75,6 @@ __all__ = [
|
|
76
75
|
"MetricsHandler",
|
77
76
|
"MetricsHolder",
|
78
77
|
"MetricsLogger",
|
79
|
-
"MetricsReading",
|
80
78
|
"MetricsRecording",
|
81
79
|
"MetricsScopeEntering",
|
82
80
|
"MetricsScopeExiting",
|
@@ -4,7 +4,6 @@ from haiway.context.identifier import ScopeIdentifier
|
|
4
4
|
from haiway.context.metrics import (
|
5
5
|
MetricsContext,
|
6
6
|
MetricsHandler,
|
7
|
-
MetricsReading,
|
8
7
|
MetricsRecording,
|
9
8
|
MetricsScopeEntering,
|
10
9
|
MetricsScopeExiting,
|
@@ -17,7 +16,6 @@ __all__ = [
|
|
17
16
|
"Disposables",
|
18
17
|
"MetricsContext",
|
19
18
|
"MetricsHandler",
|
20
|
-
"MetricsReading",
|
21
19
|
"MetricsRecording",
|
22
20
|
"MetricsScopeEntering",
|
23
21
|
"MetricsScopeExiting",
|
@@ -20,7 +20,7 @@ from haiway.context.disposables import Disposable, Disposables
|
|
20
20
|
from haiway.context.identifier import ScopeIdentifier
|
21
21
|
from haiway.context.logging import LoggerContext
|
22
22
|
from haiway.context.metrics import MetricsContext, MetricsHandler
|
23
|
-
from haiway.context.state import StateContext
|
23
|
+
from haiway.context.state import ScopeState, StateContext
|
24
24
|
from haiway.context.tasks import TaskGroupContext
|
25
25
|
from haiway.state import State
|
26
26
|
from haiway.utils import mimic_function
|
@@ -70,9 +70,7 @@ class ScopeContext:
|
|
70
70
|
object.__setattr__(
|
71
71
|
self,
|
72
72
|
"_task_group_context",
|
73
|
-
TaskGroupContext(
|
74
|
-
task_group=task_group,
|
75
|
-
)
|
73
|
+
TaskGroupContext(task_group=task_group)
|
76
74
|
if task_group is not None or self._identifier.is_root
|
77
75
|
else None,
|
78
76
|
)
|
@@ -175,8 +173,11 @@ class ScopeContext:
|
|
175
173
|
self,
|
176
174
|
"_state_context",
|
177
175
|
StateContext(
|
178
|
-
state=
|
179
|
-
|
176
|
+
state=ScopeState(
|
177
|
+
(
|
178
|
+
*await disposables.__aenter__(),
|
179
|
+
*self._state_context._state._state.values(),
|
180
|
+
)
|
180
181
|
),
|
181
182
|
),
|
182
183
|
)
|
@@ -512,62 +513,6 @@ class ctx:
|
|
512
513
|
|
513
514
|
MetricsContext.record(metric)
|
514
515
|
|
515
|
-
@overload
|
516
|
-
@staticmethod
|
517
|
-
async def read[Metric: State](
|
518
|
-
metric: type[Metric],
|
519
|
-
/,
|
520
|
-
*,
|
521
|
-
merged: bool = False,
|
522
|
-
) -> Metric | None: ...
|
523
|
-
|
524
|
-
@overload
|
525
|
-
@staticmethod
|
526
|
-
async def read[Metric: State](
|
527
|
-
metric: type[Metric],
|
528
|
-
/,
|
529
|
-
*,
|
530
|
-
merged: bool = False,
|
531
|
-
default: Metric,
|
532
|
-
) -> Metric: ...
|
533
|
-
|
534
|
-
@staticmethod
|
535
|
-
async def read[Metric: State](
|
536
|
-
metric: type[Metric],
|
537
|
-
/,
|
538
|
-
*,
|
539
|
-
merged: bool = False,
|
540
|
-
default: Metric | None = None,
|
541
|
-
) -> Metric | None:
|
542
|
-
"""
|
543
|
-
Read metric within current scope context.
|
544
|
-
|
545
|
-
Parameters
|
546
|
-
----------
|
547
|
-
metric: type[Metric]
|
548
|
-
type of metric to be read from current context.
|
549
|
-
|
550
|
-
merged: bool
|
551
|
-
control wheather to merge metrics from nested scopes (True)\
|
552
|
-
or access only the current scope value (False) without combining them
|
553
|
-
|
554
|
-
default: Metric | None
|
555
|
-
default value to return when metric was not recorded yet.
|
556
|
-
|
557
|
-
Returns
|
558
|
-
-------
|
559
|
-
Metric | None
|
560
|
-
"""
|
561
|
-
|
562
|
-
value: Metric | None = await MetricsContext.read(
|
563
|
-
metric,
|
564
|
-
merged=merged,
|
565
|
-
)
|
566
|
-
if value is None:
|
567
|
-
return default
|
568
|
-
|
569
|
-
return value
|
570
|
-
|
571
516
|
@staticmethod
|
572
517
|
def log_error(
|
573
518
|
message: str,
|
@@ -9,7 +9,6 @@ from haiway.state import State
|
|
9
9
|
__all__ = [
|
10
10
|
"MetricsContext",
|
11
11
|
"MetricsHandler",
|
12
|
-
"MetricsReading",
|
13
12
|
"MetricsRecording",
|
14
13
|
"MetricsScopeEntering",
|
15
14
|
"MetricsScopeExiting",
|
@@ -26,18 +25,6 @@ class MetricsRecording(Protocol):
|
|
26
25
|
) -> None: ...
|
27
26
|
|
28
27
|
|
29
|
-
@runtime_checkable
|
30
|
-
class MetricsReading(Protocol):
|
31
|
-
async def __call__[Metric: State](
|
32
|
-
self,
|
33
|
-
scope: ScopeIdentifier,
|
34
|
-
/,
|
35
|
-
*,
|
36
|
-
metric: type[Metric],
|
37
|
-
merged: bool,
|
38
|
-
) -> Metric | None: ...
|
39
|
-
|
40
|
-
|
41
28
|
@runtime_checkable
|
42
29
|
class MetricsScopeEntering(Protocol):
|
43
30
|
def __call__[Metric: State](
|
@@ -58,7 +45,6 @@ class MetricsScopeExiting(Protocol):
|
|
58
45
|
|
59
46
|
class MetricsHandler(State):
|
60
47
|
record: MetricsRecording
|
61
|
-
read: MetricsReading
|
62
48
|
enter_scope: MetricsScopeEntering
|
63
49
|
exit_scope: MetricsScopeExiting
|
64
50
|
|
@@ -114,30 +100,6 @@ class MetricsContext:
|
|
114
100
|
exception=exc,
|
115
101
|
)
|
116
102
|
|
117
|
-
@classmethod
|
118
|
-
async def read[Metric: State](
|
119
|
-
cls,
|
120
|
-
metric: type[Metric],
|
121
|
-
/,
|
122
|
-
merged: bool,
|
123
|
-
) -> Metric | None:
|
124
|
-
try: # catch exceptions - we don't wan't to blow up on metrics
|
125
|
-
metrics: Self = cls._context.get()
|
126
|
-
|
127
|
-
if metrics._metrics is not None:
|
128
|
-
return await metrics._metrics.read(
|
129
|
-
metrics._scope,
|
130
|
-
metric=metric,
|
131
|
-
merged=merged,
|
132
|
-
)
|
133
|
-
|
134
|
-
except Exception as exc:
|
135
|
-
LoggerContext.log_error(
|
136
|
-
"Failed to read metric: %s",
|
137
|
-
metric.__qualname__,
|
138
|
-
exception=exc,
|
139
|
-
)
|
140
|
-
|
141
103
|
__slots__ = (
|
142
104
|
"_metrics",
|
143
105
|
"_scope",
|
@@ -105,7 +105,6 @@ class MetricsHolder:
|
|
105
105
|
store_handler: Self = cls()
|
106
106
|
return MetricsHandler(
|
107
107
|
record=store_handler.record,
|
108
|
-
read=store_handler.read,
|
109
108
|
enter_scope=store_handler.enter_scope,
|
110
109
|
exit_scope=store_handler.exit_scope,
|
111
110
|
)
|
@@ -135,23 +134,6 @@ class MetricsHolder:
|
|
135
134
|
|
136
135
|
metrics[type(metric)] = metric
|
137
136
|
|
138
|
-
async def read[Metric: State](
|
139
|
-
self,
|
140
|
-
scope: ScopeIdentifier,
|
141
|
-
/,
|
142
|
-
*,
|
143
|
-
metric: type[Metric],
|
144
|
-
merged: bool,
|
145
|
-
) -> Metric | None:
|
146
|
-
assert self.root_scope is not None # nosec: B101
|
147
|
-
assert scope.scope_id in self.scopes # nosec: B101
|
148
|
-
|
149
|
-
if merged:
|
150
|
-
return self.scopes[scope.scope_id].merged(metric)
|
151
|
-
|
152
|
-
else:
|
153
|
-
return cast(Metric | None, self.scopes[scope.scope_id].metrics.get(metric))
|
154
|
-
|
155
137
|
def enter_scope[Metric: State](
|
156
138
|
self,
|
157
139
|
scope: ScopeIdentifier,
|
@@ -207,7 +189,6 @@ class MetricsLogger:
|
|
207
189
|
)
|
208
190
|
return MetricsHandler(
|
209
191
|
record=logger_handler.record,
|
210
|
-
read=logger_handler.read,
|
211
192
|
enter_scope=logger_handler.enter_scope,
|
212
193
|
exit_scope=logger_handler.exit_scope,
|
213
194
|
)
|
@@ -251,23 +232,6 @@ class MetricsLogger:
|
|
251
232
|
):
|
252
233
|
ctx.log_debug(f"Recorded metric:\n⎡ {type(metric).__qualname__}:{log}\n⌊")
|
253
234
|
|
254
|
-
async def read[Metric: State](
|
255
|
-
self,
|
256
|
-
scope: ScopeIdentifier,
|
257
|
-
/,
|
258
|
-
*,
|
259
|
-
metric: type[Metric],
|
260
|
-
merged: bool,
|
261
|
-
) -> Metric | None:
|
262
|
-
assert self.root_scope is not None # nosec: B101
|
263
|
-
assert scope.scope_id in self.scopes # nosec: B101
|
264
|
-
|
265
|
-
if merged:
|
266
|
-
return self.scopes[scope.scope_id].merged(metric)
|
267
|
-
|
268
|
-
else:
|
269
|
-
return cast(Metric | None, self.scopes[scope.scope_id].metrics.get(metric))
|
270
|
-
|
271
235
|
def enter_scope[Metric: State](
|
272
236
|
self,
|
273
237
|
scope: ScopeIdentifier,
|
@@ -67,7 +67,7 @@ wheels = [
|
|
67
67
|
|
68
68
|
[[package]]
|
69
69
|
name = "haiway"
|
70
|
-
version = "0.
|
70
|
+
version = "0.17.0"
|
71
71
|
source = { editable = "." }
|
72
72
|
|
73
73
|
[package.optional-dependencies]
|
@@ -133,11 +133,11 @@ wheels = [
|
|
133
133
|
|
134
134
|
[[package]]
|
135
135
|
name = "packaging"
|
136
|
-
version = "
|
136
|
+
version = "25.0"
|
137
137
|
source = { registry = "https://pypi.org/simple" }
|
138
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
138
|
+
sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727 }
|
139
139
|
wheels = [
|
140
|
-
{ url = "https://files.pythonhosted.org/packages/
|
140
|
+
{ url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469 },
|
141
141
|
]
|
142
142
|
|
143
143
|
[[package]]
|
@@ -172,15 +172,15 @@ wheels = [
|
|
172
172
|
|
173
173
|
[[package]]
|
174
174
|
name = "pyright"
|
175
|
-
version = "1.1.
|
175
|
+
version = "1.1.400"
|
176
176
|
source = { registry = "https://pypi.org/simple" }
|
177
177
|
dependencies = [
|
178
178
|
{ name = "nodeenv" },
|
179
179
|
{ name = "typing-extensions" },
|
180
180
|
]
|
181
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
181
|
+
sdist = { url = "https://files.pythonhosted.org/packages/6c/cb/c306618a02d0ee8aed5fb8d0fe0ecfed0dbf075f71468f03a30b5f4e1fe0/pyright-1.1.400.tar.gz", hash = "sha256:b8a3ba40481aa47ba08ffb3228e821d22f7d391f83609211335858bf05686bdb", size = 3846546 }
|
182
182
|
wheels = [
|
183
|
-
{ url = "https://files.pythonhosted.org/packages/
|
183
|
+
{ url = "https://files.pythonhosted.org/packages/c8/a5/5d285e4932cf149c90e3c425610c5efaea005475d5f96f1bfdb452956c62/pyright-1.1.400-py3-none-any.whl", hash = "sha256:c80d04f98b5a4358ad3a35e241dbf2a408eee33a40779df365644f8054d2517e", size = 5563460 },
|
184
184
|
]
|
185
185
|
|
186
186
|
[[package]]
|
@@ -264,36 +264,36 @@ wheels = [
|
|
264
264
|
|
265
265
|
[[package]]
|
266
266
|
name = "ruff"
|
267
|
-
version = "0.11.
|
267
|
+
version = "0.11.7"
|
268
268
|
source = { registry = "https://pypi.org/simple" }
|
269
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
269
|
+
sdist = { url = "https://files.pythonhosted.org/packages/5b/89/6f9c9674818ac2e9cc2f2b35b704b7768656e6b7c139064fc7ba8fbc99f1/ruff-0.11.7.tar.gz", hash = "sha256:655089ad3224070736dc32844fde783454f8558e71f501cb207485fe4eee23d4", size = 4054861 }
|
270
270
|
wheels = [
|
271
|
-
{ url = "https://files.pythonhosted.org/packages/
|
272
|
-
{ url = "https://files.pythonhosted.org/packages/
|
273
|
-
{ url = "https://files.pythonhosted.org/packages/
|
274
|
-
{ url = "https://files.pythonhosted.org/packages/
|
275
|
-
{ url = "https://files.pythonhosted.org/packages/
|
276
|
-
{ url = "https://files.pythonhosted.org/packages/
|
277
|
-
{ url = "https://files.pythonhosted.org/packages/
|
278
|
-
{ url = "https://files.pythonhosted.org/packages/
|
279
|
-
{ url = "https://files.pythonhosted.org/packages/
|
280
|
-
{ url = "https://files.pythonhosted.org/packages/
|
281
|
-
{ url = "https://files.pythonhosted.org/packages/
|
282
|
-
{ url = "https://files.pythonhosted.org/packages/
|
283
|
-
{ url = "https://files.pythonhosted.org/packages/
|
284
|
-
{ url = "https://files.pythonhosted.org/packages/
|
285
|
-
{ url = "https://files.pythonhosted.org/packages/
|
286
|
-
{ url = "https://files.pythonhosted.org/packages/
|
287
|
-
{ url = "https://files.pythonhosted.org/packages/
|
271
|
+
{ url = "https://files.pythonhosted.org/packages/b4/ec/21927cb906c5614b786d1621dba405e3d44f6e473872e6df5d1a6bca0455/ruff-0.11.7-py3-none-linux_armv6l.whl", hash = "sha256:d29e909d9a8d02f928d72ab7837b5cbc450a5bdf578ab9ebee3263d0a525091c", size = 10245403 },
|
272
|
+
{ url = "https://files.pythonhosted.org/packages/e2/af/fec85b6c2c725bcb062a354dd7cbc1eed53c33ff3aa665165871c9c16ddf/ruff-0.11.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:dd1fb86b168ae349fb01dd497d83537b2c5541fe0626e70c786427dd8363aaee", size = 11007166 },
|
273
|
+
{ url = "https://files.pythonhosted.org/packages/31/9a/2d0d260a58e81f388800343a45898fd8df73c608b8261c370058b675319a/ruff-0.11.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:d3d7d2e140a6fbbc09033bce65bd7ea29d6a0adeb90b8430262fbacd58c38ada", size = 10378076 },
|
274
|
+
{ url = "https://files.pythonhosted.org/packages/c2/c4/9b09b45051404d2e7dd6d9dbcbabaa5ab0093f9febcae664876a77b9ad53/ruff-0.11.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4809df77de390a1c2077d9b7945d82f44b95d19ceccf0c287c56e4dc9b91ca64", size = 10557138 },
|
275
|
+
{ url = "https://files.pythonhosted.org/packages/5e/5e/f62a1b6669870a591ed7db771c332fabb30f83c967f376b05e7c91bccd14/ruff-0.11.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f3a0c2e169e6b545f8e2dba185eabbd9db4f08880032e75aa0e285a6d3f48201", size = 10095726 },
|
276
|
+
{ url = "https://files.pythonhosted.org/packages/45/59/a7aa8e716f4cbe07c3500a391e58c52caf665bb242bf8be42c62adef649c/ruff-0.11.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:49b888200a320dd96a68e86736cf531d6afba03e4f6cf098401406a257fcf3d6", size = 11672265 },
|
277
|
+
{ url = "https://files.pythonhosted.org/packages/dd/e3/101a8b707481f37aca5f0fcc3e42932fa38b51add87bfbd8e41ab14adb24/ruff-0.11.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:2b19cdb9cf7dae00d5ee2e7c013540cdc3b31c4f281f1dacb5a799d610e90db4", size = 12331418 },
|
278
|
+
{ url = "https://files.pythonhosted.org/packages/dd/71/037f76cbe712f5cbc7b852e4916cd3cf32301a30351818d32ab71580d1c0/ruff-0.11.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:64e0ee994c9e326b43539d133a36a455dbaab477bc84fe7bfbd528abe2f05c1e", size = 11794506 },
|
279
|
+
{ url = "https://files.pythonhosted.org/packages/ca/de/e450b6bab1fc60ef263ef8fcda077fb4977601184877dce1c59109356084/ruff-0.11.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bad82052311479a5865f52c76ecee5d468a58ba44fb23ee15079f17dd4c8fd63", size = 13939084 },
|
280
|
+
{ url = "https://files.pythonhosted.org/packages/0e/2c/1e364cc92970075d7d04c69c928430b23e43a433f044474f57e425cbed37/ruff-0.11.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7940665e74e7b65d427b82bffc1e46710ec7f30d58b4b2d5016e3f0321436502", size = 11450441 },
|
281
|
+
{ url = "https://files.pythonhosted.org/packages/9d/7d/1b048eb460517ff9accd78bca0fa6ae61df2b276010538e586f834f5e402/ruff-0.11.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:169027e31c52c0e36c44ae9a9c7db35e505fee0b39f8d9fca7274a6305295a92", size = 10441060 },
|
282
|
+
{ url = "https://files.pythonhosted.org/packages/3a/57/8dc6ccfd8380e5ca3d13ff7591e8ba46a3b330323515a4996b991b10bd5d/ruff-0.11.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:305b93f9798aee582e91e34437810439acb28b5fc1fee6b8205c78c806845a94", size = 10058689 },
|
283
|
+
{ url = "https://files.pythonhosted.org/packages/23/bf/20487561ed72654147817885559ba2aa705272d8b5dee7654d3ef2dbf912/ruff-0.11.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a681db041ef55550c371f9cd52a3cf17a0da4c75d6bd691092dfc38170ebc4b6", size = 11073703 },
|
284
|
+
{ url = "https://files.pythonhosted.org/packages/9d/27/04f2db95f4ef73dccedd0c21daf9991cc3b7f29901a4362057b132075aa4/ruff-0.11.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:07f1496ad00a4a139f4de220b0c97da6d4c85e0e4aa9b2624167b7d4d44fd6b6", size = 11532822 },
|
285
|
+
{ url = "https://files.pythonhosted.org/packages/e1/72/43b123e4db52144c8add336581de52185097545981ff6e9e58a21861c250/ruff-0.11.7-py3-none-win32.whl", hash = "sha256:f25dfb853ad217e6e5f1924ae8a5b3f6709051a13e9dad18690de6c8ff299e26", size = 10362436 },
|
286
|
+
{ url = "https://files.pythonhosted.org/packages/c5/a0/3e58cd76fdee53d5c8ce7a56d84540833f924ccdf2c7d657cb009e604d82/ruff-0.11.7-py3-none-win_amd64.whl", hash = "sha256:0a931d85959ceb77e92aea4bbedfded0a31534ce191252721128f77e5ae1f98a", size = 11566676 },
|
287
|
+
{ url = "https://files.pythonhosted.org/packages/68/ca/69d7c7752bce162d1516e5592b1cc6b6668e9328c0d270609ddbeeadd7cf/ruff-0.11.7-py3-none-win_arm64.whl", hash = "sha256:778c1e5d6f9e91034142dfd06110534ca13220bfaad5c3735f6cb844654f6177", size = 10677936 },
|
288
288
|
]
|
289
289
|
|
290
290
|
[[package]]
|
291
291
|
name = "setuptools"
|
292
|
-
version = "
|
292
|
+
version = "80.1.0"
|
293
293
|
source = { registry = "https://pypi.org/simple" }
|
294
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
294
|
+
sdist = { url = "https://files.pythonhosted.org/packages/aa/b2/bd26ed086b842b68c8fe9aac380ad7e5118cf84fa7abd45bb059a88368a8/setuptools-80.1.0.tar.gz", hash = "sha256:2e308396e1d83de287ada2c2fd6e64286008fe6aca5008e0b6a8cb0e2c86eedd", size = 1354038 }
|
295
295
|
wheels = [
|
296
|
-
{ url = "https://files.pythonhosted.org/packages/
|
296
|
+
{ url = "https://files.pythonhosted.org/packages/8b/f6/126c9309c8fe93e5d6bb850593cd58d591daf2da45cc78b61e48d8d95879/setuptools-80.1.0-py3-none-any.whl", hash = "sha256:ea0e7655c05b74819f82e76e11a85b31779fee7c4969e82f72bab0664e8317e4", size = 1240689 },
|
297
297
|
]
|
298
298
|
|
299
299
|
[[package]]
|
@@ -310,9 +310,9 @@ wheels = [
|
|
310
310
|
|
311
311
|
[[package]]
|
312
312
|
name = "typing-extensions"
|
313
|
-
version = "4.13.
|
313
|
+
version = "4.13.2"
|
314
314
|
source = { registry = "https://pypi.org/simple" }
|
315
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
315
|
+
sdist = { url = "https://files.pythonhosted.org/packages/f6/37/23083fcd6e35492953e8d2aaaa68b860eb422b34627b13f2ce3eb6106061/typing_extensions-4.13.2.tar.gz", hash = "sha256:e6c81219bd689f51865d9e372991c540bda33a0379d5573cddb9a3a23f7caaef", size = 106967 }
|
316
316
|
wheels = [
|
317
|
-
{ url = "https://files.pythonhosted.org/packages/
|
317
|
+
{ url = "https://files.pythonhosted.org/packages/8b/54/b1ae86c0973cc6f0210b53d508ca3641fb6d0c56823f288d108bc7ab3cc8/typing_extensions-4.13.2-py3-none-any.whl", hash = "sha256:a439e7c04b49fec3e5d3e2beaa21755cadbbdc391694e28ccdd36ca4a1408f8c", size = 45806 },
|
318
318
|
]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|