krons 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl
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.
- {kronos → krons}/core/__init__.py +31 -31
- {kronos → krons}/core/broadcaster.py +1 -1
- {kronos → krons}/core/element.py +3 -3
- {kronos → krons}/core/event.py +4 -4
- {kronos → krons}/core/eventbus.py +1 -1
- {kronos → krons}/core/flow.py +4 -4
- {kronos → krons}/core/graph.py +4 -4
- {kronos → krons}/core/node.py +11 -11
- {kronos → krons}/core/pile.py +5 -5
- {kronos → krons}/core/processor.py +2 -2
- {kronos → krons}/core/progression.py +2 -2
- {kronos → krons}/enforcement/__init__.py +1 -1
- {kronos → krons}/enforcement/context.py +3 -3
- {kronos → krons}/enforcement/policy.py +3 -3
- {kronos → krons}/enforcement/rule.py +2 -2
- {kronos → krons}/enforcement/service.py +1 -1
- {kronos → krons}/enforcement/validator.py +3 -3
- {kronos → krons}/operations/builder.py +4 -4
- {kronos → krons}/operations/flow.py +5 -5
- {kronos → krons}/operations/node.py +3 -3
- {kronos → krons}/services/__init__.py +13 -13
- {kronos → krons}/services/backend.py +3 -3
- {kronos → krons}/services/hook.py +3 -3
- {kronos → krons}/services/imodel.py +5 -5
- {kronos → krons}/services/registry.py +2 -2
- {kronos → krons}/services/utilities/rate_limited_executor.py +4 -4
- {kronos → krons}/services/utilities/rate_limiter.py +1 -1
- {kronos → krons}/services/utilities/resilience.py +2 -2
- {kronos → krons}/session/exchange.py +3 -3
- {kronos → krons}/session/message.py +1 -1
- {kronos → krons}/session/session.py +7 -7
- {kronos → krons}/specs/adapters/dataclass_field.py +4 -4
- {kronos → krons}/specs/adapters/pydantic_adapter.py +5 -5
- {kronos → krons}/specs/adapters/sql_ddl.py +6 -6
- {kronos → krons}/specs/catalog/__init__.py +2 -2
- {kronos → krons}/specs/catalog/_audit.py +3 -3
- {kronos → krons}/specs/catalog/_common.py +2 -2
- {kronos → krons}/specs/catalog/_content.py +5 -5
- {kronos → krons}/specs/catalog/_enforcement.py +4 -4
- {kronos → krons}/specs/factory.py +7 -7
- {kronos → krons}/specs/operable.py +2 -2
- {kronos → krons}/specs/phrase.py +4 -4
- {kronos → krons}/specs/protocol.py +1 -1
- {kronos → krons}/specs/spec.py +7 -7
- {kronos → krons}/types/base.py +3 -3
- {kronos → krons}/types/db_types.py +2 -2
- {kronos → krons}/types/identity.py +1 -1
- {kronos → krons}/utils/_to_list.py +1 -1
- {kronos → krons}/utils/_utils.py +3 -3
- {kronos → krons}/utils/concurrency/__init__.py +38 -38
- {kronos → krons}/utils/concurrency/_async_call.py +3 -3
- {kronos → krons}/utils/fuzzy/_fuzzy_match.py +2 -2
- {kronos → krons}/utils/sql/_sql_validation.py +1 -1
- {krons-0.1.0.dist-info → krons-0.1.1.dist-info}/METADATA +5 -5
- krons-0.1.1.dist-info/RECORD +101 -0
- krons-0.1.0.dist-info/RECORD +0 -101
- {kronos → krons}/__init__.py +0 -0
- {kronos → krons}/enforcement/common/__init__.py +0 -0
- {kronos → krons}/enforcement/common/boolean.py +0 -0
- {kronos → krons}/enforcement/common/choice.py +0 -0
- {kronos → krons}/enforcement/common/mapping.py +0 -0
- {kronos → krons}/enforcement/common/model.py +0 -0
- {kronos → krons}/enforcement/common/number.py +0 -0
- {kronos → krons}/enforcement/common/string.py +0 -0
- {kronos → krons}/enforcement/registry.py +0 -0
- {kronos → krons}/errors.py +0 -0
- {kronos → krons}/operations/__init__.py +0 -0
- {kronos → krons}/operations/registry.py +0 -0
- {kronos → krons}/protocols.py +0 -0
- {kronos → krons}/py.typed +0 -0
- {kronos → krons}/services/endpoint.py +0 -0
- {kronos → krons}/services/utilities/__init__.py +0 -0
- {kronos → krons}/services/utilities/header_factory.py +0 -0
- {kronos → krons}/session/__init__.py +0 -0
- {kronos → krons}/specs/__init__.py +0 -0
- {kronos → krons}/specs/adapters/__init__.py +0 -0
- {kronos → krons}/specs/adapters/_utils.py +0 -0
- {kronos → krons}/specs/adapters/factory.py +0 -0
- {kronos → krons}/types/__init__.py +0 -0
- {kronos → krons}/types/_sentinel.py +0 -0
- {kronos → krons}/utils/__init__.py +0 -0
- {kronos → krons}/utils/_hash.py +0 -0
- {kronos → krons}/utils/_json_dump.py +0 -0
- {kronos → krons}/utils/_lazy_init.py +0 -0
- {kronos → krons}/utils/_to_num.py +0 -0
- {kronos → krons}/utils/concurrency/_cancel.py +0 -0
- {kronos → krons}/utils/concurrency/_errors.py +0 -0
- {kronos → krons}/utils/concurrency/_patterns.py +0 -0
- {kronos → krons}/utils/concurrency/_primitives.py +0 -0
- {kronos → krons}/utils/concurrency/_priority_queue.py +0 -0
- {kronos → krons}/utils/concurrency/_resource_tracker.py +0 -0
- {kronos → krons}/utils/concurrency/_run_async.py +0 -0
- {kronos → krons}/utils/concurrency/_task.py +0 -0
- {kronos → krons}/utils/concurrency/_utils.py +0 -0
- {kronos → krons}/utils/fuzzy/__init__.py +0 -0
- {kronos → krons}/utils/fuzzy/_extract_json.py +0 -0
- {kronos → krons}/utils/fuzzy/_fuzzy_json.py +0 -0
- {kronos → krons}/utils/fuzzy/_string_similarity.py +0 -0
- {kronos → krons}/utils/fuzzy/_to_dict.py +0 -0
- {kronos → krons}/utils/sql/__init__.py +0 -0
- {krons-0.1.0.dist-info → krons-0.1.1.dist-info}/WHEEL +0 -0
- {krons-0.1.0.dist-info → krons-0.1.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -17,14 +17,14 @@ from dataclasses import field as dc_field
|
|
|
17
17
|
from dataclasses import fields
|
|
18
18
|
from typing import TYPE_CHECKING, Any
|
|
19
19
|
|
|
20
|
-
from
|
|
20
|
+
from krons.types._sentinel import Unset, UnsetType, is_sentinel
|
|
21
21
|
|
|
22
22
|
from ..protocol import SpecAdapter
|
|
23
23
|
from ..spec import Spec
|
|
24
24
|
from ._utils import resolve_annotation_to_base_types
|
|
25
25
|
|
|
26
26
|
if TYPE_CHECKING:
|
|
27
|
-
from
|
|
27
|
+
from krons.types.base import DataClass, ModelConfig, Params
|
|
28
28
|
|
|
29
29
|
from ..operable import Operable
|
|
30
30
|
|
|
@@ -149,7 +149,7 @@ class DataClassSpecAdapter(SpecAdapter[dict[str, Any]]):
|
|
|
149
149
|
Returns:
|
|
150
150
|
Dynamically created dataclass with validators wired in
|
|
151
151
|
"""
|
|
152
|
-
from
|
|
152
|
+
from krons.types.base import DataClass, Params
|
|
153
153
|
|
|
154
154
|
use_specs = op.get_specs(include=include, exclude=exclude)
|
|
155
155
|
|
|
@@ -227,7 +227,7 @@ class DataClassSpecAdapter(SpecAdapter[dict[str, Any]]):
|
|
|
227
227
|
Raises:
|
|
228
228
|
TypeError: If structure is not a DataClass or Params subclass
|
|
229
229
|
"""
|
|
230
|
-
from
|
|
230
|
+
from krons.types.base import DataClass, Params
|
|
231
231
|
|
|
232
232
|
if not isinstance(structure, type) or not issubclass(structure, (DataClass, Params)):
|
|
233
233
|
raise TypeError(
|
|
@@ -20,15 +20,15 @@ from pydantic.fields import FieldInfo
|
|
|
20
20
|
from pydantic_core import PydanticUndefined
|
|
21
21
|
from pydantic_core._pydantic_core import PydanticUndefinedType
|
|
22
22
|
|
|
23
|
-
from
|
|
24
|
-
from
|
|
25
|
-
from
|
|
26
|
-
from
|
|
23
|
+
from krons.specs.protocol import SpecAdapter
|
|
24
|
+
from krons.specs.spec import Spec
|
|
25
|
+
from krons.types._sentinel import Unset, UnsetType, is_sentinel, is_unset, not_sentinel
|
|
26
|
+
from krons.types.db_types import FKMeta, VectorMeta
|
|
27
27
|
|
|
28
28
|
from ._utils import resolve_annotation_to_base_types
|
|
29
29
|
|
|
30
30
|
if TYPE_CHECKING:
|
|
31
|
-
from
|
|
31
|
+
from krons.specs.operable import Operable
|
|
32
32
|
|
|
33
33
|
__all__ = ("PydanticSpecAdapter",)
|
|
34
34
|
|
|
@@ -27,16 +27,16 @@ from enum import StrEnum
|
|
|
27
27
|
from typing import TYPE_CHECKING, Annotated, Any, get_args, get_origin
|
|
28
28
|
from uuid import UUID
|
|
29
29
|
|
|
30
|
-
from
|
|
31
|
-
from
|
|
32
|
-
from
|
|
30
|
+
from krons.types._sentinel import Unset, UnsetType, is_sentinel
|
|
31
|
+
from krons.types.db_types import FK, FKMeta, Vector, VectorMeta, extract_kron_db_meta
|
|
32
|
+
from krons.utils.sql import validate_identifier
|
|
33
33
|
|
|
34
34
|
from ..protocol import SpecAdapter
|
|
35
35
|
from ._utils import resolve_annotation_to_base_types
|
|
36
36
|
|
|
37
37
|
if TYPE_CHECKING:
|
|
38
|
-
from
|
|
39
|
-
from
|
|
38
|
+
from krons.specs.operable import Operable
|
|
39
|
+
from krons.specs.spec import Spec
|
|
40
40
|
|
|
41
41
|
__all__ = (
|
|
42
42
|
# Enums
|
|
@@ -672,7 +672,7 @@ class SchemaSpec:
|
|
|
672
672
|
Returns:
|
|
673
673
|
SchemaSpec with version hash computed from table definitions.
|
|
674
674
|
"""
|
|
675
|
-
from
|
|
675
|
+
from krons.utils import compute_hash
|
|
676
676
|
|
|
677
677
|
tables = [
|
|
678
678
|
TableSpec.from_operable(op, name, schema=schema)
|
|
@@ -9,14 +9,14 @@ Pre-defined Specs for common database patterns:
|
|
|
9
9
|
- **CommonSpecs**: name, slug, status, email, phone, tenant_id, settings
|
|
10
10
|
|
|
11
11
|
Usage:
|
|
12
|
-
from
|
|
12
|
+
from krons.specs.catalog import ContentSpecs, AuditSpecs
|
|
13
13
|
|
|
14
14
|
content_specs = ContentSpecs.get_specs(dim=1536)
|
|
15
15
|
audit_specs = AuditSpecs.get_specs(use_uuid=True)
|
|
16
16
|
all_specs = content_specs + audit_specs
|
|
17
17
|
|
|
18
18
|
For custom Specs, use the factories directly:
|
|
19
|
-
from
|
|
19
|
+
from krons.specs.factory import create_embedding_spec, create_content_spec
|
|
20
20
|
|
|
21
21
|
my_embedding = create_embedding_spec("embedding", dim=1536)
|
|
22
22
|
my_content = create_content_spec("payload", content_type=MyModel)
|
|
@@ -10,9 +10,9 @@ from uuid import UUID
|
|
|
10
10
|
|
|
11
11
|
from pydantic import BaseModel, Field
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
13
|
+
from krons.specs.operable import Operable
|
|
14
|
+
from krons.specs.spec import Spec
|
|
15
|
+
from krons.utils import now_utc
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class AuditSpecs(BaseModel):
|
|
@@ -10,8 +10,8 @@ from uuid import UUID
|
|
|
10
10
|
|
|
11
11
|
from pydantic import BaseModel
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from
|
|
13
|
+
from krons.specs.operable import Operable
|
|
14
|
+
from krons.specs.spec import Spec
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class CommonSpecs(BaseModel):
|
|
@@ -11,11 +11,11 @@ from uuid import UUID, uuid4
|
|
|
11
11
|
|
|
12
12
|
from pydantic import BaseModel, Field
|
|
13
13
|
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from
|
|
18
|
-
from
|
|
14
|
+
from krons.specs.operable import Operable
|
|
15
|
+
from krons.specs.spec import Spec
|
|
16
|
+
from krons.types._sentinel import Unset, UnsetType
|
|
17
|
+
from krons.types.db_types import VectorMeta
|
|
18
|
+
from krons.utils import now_utc
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class ContentSpecs(BaseModel):
|
|
@@ -10,10 +10,10 @@ from typing import Any
|
|
|
10
10
|
|
|
11
11
|
from pydantic import BaseModel, Field, field_validator
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
13
|
+
from krons.specs.operable import Operable
|
|
14
|
+
from krons.specs.spec import Spec
|
|
15
|
+
from krons.types.base import Enum
|
|
16
|
+
from krons.utils import now_utc
|
|
17
17
|
|
|
18
18
|
__all__ = (
|
|
19
19
|
"EnforcementLevel",
|
|
@@ -8,14 +8,14 @@ from __future__ import annotations
|
|
|
8
8
|
from datetime import datetime
|
|
9
9
|
from uuid import UUID, uuid4
|
|
10
10
|
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
from
|
|
11
|
+
from krons.specs.spec import Spec, not_sentinel
|
|
12
|
+
from krons.types import UnsetType
|
|
13
|
+
from krons.types._sentinel import Unset
|
|
14
|
+
from krons.types.base import is_sentinel
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def create_datetime_spec(name: str, *, use_default: bool) -> Spec:
|
|
18
|
-
from
|
|
18
|
+
from krons.utils._utils import coerce_created_at, now_utc
|
|
19
19
|
|
|
20
20
|
return Spec(
|
|
21
21
|
datetime,
|
|
@@ -26,7 +26,7 @@ def create_datetime_spec(name: str, *, use_default: bool) -> Spec:
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
def create_uuid_spec(name: str, *, use_default: bool) -> Spec:
|
|
29
|
-
from
|
|
29
|
+
from krons.utils._utils import to_uuid
|
|
30
30
|
|
|
31
31
|
return Spec(
|
|
32
32
|
UUID,
|
|
@@ -74,7 +74,7 @@ def create_embedding_spec(
|
|
|
74
74
|
return Spec(list[float], name=name, default_factory=list)
|
|
75
75
|
return Spec(list[float], name=name)
|
|
76
76
|
|
|
77
|
-
from
|
|
77
|
+
from krons.specs.adapters.sql_ddl import Vector
|
|
78
78
|
|
|
79
79
|
return Spec(Vector[dim], name=name)
|
|
80
80
|
|
|
@@ -6,8 +6,8 @@ from __future__ import annotations
|
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from typing import TYPE_CHECKING, Any, Self
|
|
8
8
|
|
|
9
|
-
from
|
|
10
|
-
from
|
|
9
|
+
from krons.protocols import Allowable, Hashable, implements
|
|
10
|
+
from krons.types._sentinel import MaybeUnset, Unset, UnsetType, is_unset, not_sentinel
|
|
11
11
|
|
|
12
12
|
from .adapters.factory import AdapterType, get_adapter
|
|
13
13
|
from .protocol import SpecAdapter
|
{kronos → krons}/specs/phrase.py
RENAMED
|
@@ -6,7 +6,7 @@ A Phrase wraps an async handler with:
|
|
|
6
6
|
- Validation via Operable
|
|
7
7
|
|
|
8
8
|
Usage with decorator (custom handler):
|
|
9
|
-
from
|
|
9
|
+
from krons.specs import Operable, phrase
|
|
10
10
|
|
|
11
11
|
consent_operable = Operable([
|
|
12
12
|
Spec("subject_id", UUID),
|
|
@@ -25,7 +25,7 @@ Usage with decorator (custom handler):
|
|
|
25
25
|
result = await verify_consent({"subject_id": id, "scope": "background"}, ctx)
|
|
26
26
|
|
|
27
27
|
Usage with CrudPattern (declarative):
|
|
28
|
-
from
|
|
28
|
+
from krons.specs import Operable, phrase, CrudPattern
|
|
29
29
|
|
|
30
30
|
def check_has_consent(row):
|
|
31
31
|
return {"has_consent": row["status"] in {"active"} if row else False}
|
|
@@ -50,8 +50,8 @@ from enum import Enum
|
|
|
50
50
|
from types import MappingProxyType
|
|
51
51
|
from typing import Any
|
|
52
52
|
|
|
53
|
-
from
|
|
54
|
-
from
|
|
53
|
+
from krons.types import Unset, is_unset
|
|
54
|
+
from krons.utils.sql import validate_identifier
|
|
55
55
|
|
|
56
56
|
from .operable import Operable
|
|
57
57
|
|
|
@@ -24,7 +24,7 @@ from __future__ import annotations
|
|
|
24
24
|
from abc import ABC, abstractmethod
|
|
25
25
|
from typing import TYPE_CHECKING, Any, Generic, TypeVar
|
|
26
26
|
|
|
27
|
-
from
|
|
27
|
+
from krons.types._sentinel import Unset, UnsetType
|
|
28
28
|
|
|
29
29
|
if TYPE_CHECKING:
|
|
30
30
|
from .operable import Operable
|
{kronos → krons}/specs/spec.py
RENAMED
|
@@ -11,16 +11,16 @@ from collections.abc import Callable
|
|
|
11
11
|
from dataclasses import dataclass
|
|
12
12
|
from typing import Annotated, Any, Self
|
|
13
13
|
|
|
14
|
-
from
|
|
15
|
-
from
|
|
14
|
+
from krons.protocols import Hashable, implements
|
|
15
|
+
from krons.types._sentinel import (
|
|
16
16
|
MaybeUndefined,
|
|
17
17
|
Undefined,
|
|
18
18
|
is_sentinel,
|
|
19
19
|
is_undefined,
|
|
20
20
|
not_sentinel,
|
|
21
21
|
)
|
|
22
|
-
from
|
|
23
|
-
from
|
|
22
|
+
from krons.types.base import Enum, Meta
|
|
23
|
+
from krons.utils.concurrency import is_coro_func
|
|
24
24
|
|
|
25
25
|
# Global cache for annotated types with bounded size
|
|
26
26
|
_MAX_CACHE_SIZE = int(os.environ.get("kron_FIELD_CACHE_SIZE", "10000"))
|
|
@@ -81,7 +81,7 @@ class CommonMeta(Enum):
|
|
|
81
81
|
) -> tuple[Meta, ...]:
|
|
82
82
|
"""Prepare metadata tuple from args/kw. Validates no duplicates, constraints."""
|
|
83
83
|
# Lazy import to avoid circular dependency
|
|
84
|
-
from
|
|
84
|
+
from krons.utils._to_list import to_list
|
|
85
85
|
|
|
86
86
|
seen_keys = set()
|
|
87
87
|
metas = []
|
|
@@ -407,7 +407,7 @@ class Spec:
|
|
|
407
407
|
if not is_undefined(fk):
|
|
408
408
|
from uuid import UUID
|
|
409
409
|
|
|
410
|
-
from
|
|
410
|
+
from krons.types.db_types import FKMeta
|
|
411
411
|
|
|
412
412
|
t_ = Annotated[UUID, FKMeta(fk)] # type: ignore[valid-type]
|
|
413
413
|
if self.is_listable:
|
|
@@ -440,7 +440,7 @@ class Spec:
|
|
|
440
440
|
if not is_undefined(resolved_fk):
|
|
441
441
|
from uuid import UUID
|
|
442
442
|
|
|
443
|
-
from
|
|
443
|
+
from krons.types.db_types import FKMeta
|
|
444
444
|
|
|
445
445
|
actual_type = UUID # FK fields are UUID references
|
|
446
446
|
extra_annotations.append(FKMeta(resolved_fk))
|
{kronos → krons}/types/base.py
RENAMED
|
@@ -28,8 +28,8 @@ from typing import Any, ClassVar, Literal, Self, TypedDict
|
|
|
28
28
|
from pydantic import BaseModel as _PydanticBaseModel
|
|
29
29
|
from typing_extensions import override
|
|
30
30
|
|
|
31
|
-
from
|
|
32
|
-
from
|
|
31
|
+
from krons.protocols import Allowable, Hashable, Serializable, implements
|
|
32
|
+
from krons.utils._hash import hash_obj
|
|
33
33
|
|
|
34
34
|
from ._sentinel import Undefined, Unset, is_sentinel, is_undefined
|
|
35
35
|
|
|
@@ -152,7 +152,7 @@ class _SentinelMixin:
|
|
|
152
152
|
if not self._is_sentinel(v):
|
|
153
153
|
data[k] = self._normalize_value(v)
|
|
154
154
|
if mode == "json":
|
|
155
|
-
from
|
|
155
|
+
from krons.utils._json_dump import json_dump
|
|
156
156
|
|
|
157
157
|
return json_dump(data, decode=True, as_loaded=True, **kwargs)
|
|
158
158
|
|
|
@@ -18,7 +18,7 @@ import types
|
|
|
18
18
|
from typing import Annotated, Any, Literal, Union, get_args, get_origin
|
|
19
19
|
from uuid import UUID
|
|
20
20
|
|
|
21
|
-
from
|
|
21
|
+
from krons.types._sentinel import Unset, UnsetType, not_sentinel
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def _is_field_info(obj: Any) -> bool:
|
|
@@ -237,7 +237,7 @@ def extract_kron_db_meta(
|
|
|
237
237
|
|
|
238
238
|
else:
|
|
239
239
|
# Try Spec (lazy import to avoid circular)
|
|
240
|
-
from
|
|
240
|
+
from krons.specs.spec import Spec
|
|
241
241
|
|
|
242
242
|
if isinstance(from_, Spec):
|
|
243
243
|
if metas in ("FK", "BOTH"):
|
|
@@ -7,7 +7,7 @@ Provides ID[T] syntax for associating UUIDs with specific model types,
|
|
|
7
7
|
enabling compile-time type checking and runtime semantic clarity.
|
|
8
8
|
|
|
9
9
|
Usage:
|
|
10
|
-
from
|
|
10
|
+
from krons.types import ID
|
|
11
11
|
|
|
12
12
|
user_id: ID[User] = uuid4()
|
|
13
13
|
org_id: ID[Organization] = uuid4()
|
|
@@ -29,7 +29,7 @@ def _do_init() -> None:
|
|
|
29
29
|
from pydantic import BaseModel
|
|
30
30
|
from pydantic_core import PydanticUndefinedType
|
|
31
31
|
|
|
32
|
-
from
|
|
32
|
+
from krons.types import UndefinedType, UnsetType
|
|
33
33
|
|
|
34
34
|
global _MODEL_LIKE, _MAP_LIKE, _SINGLETONE_TYPES, _SKIP_TYPE, _SKIP_TUPLE_SET
|
|
35
35
|
_MODEL_LIKE = (BaseModel,)
|
{kronos → krons}/utils/_utils.py
RENAMED
|
@@ -13,7 +13,7 @@ from uuid import UUID, uuid4
|
|
|
13
13
|
|
|
14
14
|
from anyio import Path as AsyncPath
|
|
15
15
|
|
|
16
|
-
from
|
|
16
|
+
from krons.protocols import Observable
|
|
17
17
|
|
|
18
18
|
__all__ = (
|
|
19
19
|
"create_path",
|
|
@@ -188,7 +188,7 @@ def is_import_installed(package_name: str) -> bool:
|
|
|
188
188
|
|
|
189
189
|
_TYPE_CACHE: dict[str, type] = {}
|
|
190
190
|
|
|
191
|
-
_DEFAULT_ALLOWED_PREFIXES: frozenset[str] = frozenset({"
|
|
191
|
+
_DEFAULT_ALLOWED_PREFIXES: frozenset[str] = frozenset({"krons."})
|
|
192
192
|
_ALLOWED_MODULE_PREFIXES: set[str] = set(_DEFAULT_ALLOWED_PREFIXES)
|
|
193
193
|
|
|
194
194
|
|
|
@@ -210,7 +210,7 @@ def register_type_prefix(prefix: str) -> None:
|
|
|
210
210
|
|
|
211
211
|
|
|
212
212
|
def load_type_from_string(type_str: str) -> type:
|
|
213
|
-
"""Load type from fully qualified path (e.g., '
|
|
213
|
+
"""Load type from fully qualified path (e.g., 'krons.core.Node').
|
|
214
214
|
|
|
215
215
|
Security: Only allowlisted module prefixes can be loaded.
|
|
216
216
|
|
|
@@ -37,63 +37,63 @@ from typing import TYPE_CHECKING
|
|
|
37
37
|
|
|
38
38
|
_LAZY_IMPORTS: dict[str, tuple[str, str]] = {
|
|
39
39
|
# _cancel
|
|
40
|
-
"CancelScope": ("
|
|
41
|
-
"effective_deadline": ("
|
|
42
|
-
"fail_after": ("
|
|
43
|
-
"fail_at": ("
|
|
44
|
-
"move_on_after": ("
|
|
45
|
-
"move_on_at": ("
|
|
40
|
+
"CancelScope": ("krons.utils.concurrency._cancel", "CancelScope"),
|
|
41
|
+
"effective_deadline": ("krons.utils.concurrency._cancel", "effective_deadline"),
|
|
42
|
+
"fail_after": ("krons.utils.concurrency._cancel", "fail_after"),
|
|
43
|
+
"fail_at": ("krons.utils.concurrency._cancel", "fail_at"),
|
|
44
|
+
"move_on_after": ("krons.utils.concurrency._cancel", "move_on_after"),
|
|
45
|
+
"move_on_at": ("krons.utils.concurrency._cancel", "move_on_at"),
|
|
46
46
|
# _errors
|
|
47
47
|
"get_cancelled_exc_class": (
|
|
48
|
-
"
|
|
48
|
+
"krons.utils.concurrency._errors",
|
|
49
49
|
"get_cancelled_exc_class",
|
|
50
50
|
),
|
|
51
|
-
"is_cancelled": ("
|
|
51
|
+
"is_cancelled": ("krons.utils.concurrency._errors", "is_cancelled"),
|
|
52
52
|
"non_cancel_subgroup": (
|
|
53
|
-
"
|
|
53
|
+
"krons.utils.concurrency._errors",
|
|
54
54
|
"non_cancel_subgroup",
|
|
55
55
|
),
|
|
56
|
-
"shield": ("
|
|
56
|
+
"shield": ("krons.utils.concurrency._errors", "shield"),
|
|
57
57
|
# _patterns
|
|
58
|
-
"CompletionStream": ("
|
|
59
|
-
"bounded_map": ("
|
|
60
|
-
"gather": ("
|
|
61
|
-
"race": ("
|
|
62
|
-
"retry": ("
|
|
58
|
+
"CompletionStream": ("krons.utils.concurrency._patterns", "CompletionStream"),
|
|
59
|
+
"bounded_map": ("krons.utils.concurrency._patterns", "bounded_map"),
|
|
60
|
+
"gather": ("krons.utils.concurrency._patterns", "gather"),
|
|
61
|
+
"race": ("krons.utils.concurrency._patterns", "race"),
|
|
62
|
+
"retry": ("krons.utils.concurrency._patterns", "retry"),
|
|
63
63
|
# _primitives
|
|
64
|
-
"CapacityLimiter": ("
|
|
65
|
-
"Condition": ("
|
|
66
|
-
"Event": ("
|
|
67
|
-
"Lock": ("
|
|
68
|
-
"Queue": ("
|
|
69
|
-
"Semaphore": ("
|
|
64
|
+
"CapacityLimiter": ("krons.utils.concurrency._primitives", "CapacityLimiter"),
|
|
65
|
+
"Condition": ("krons.utils.concurrency._primitives", "Condition"),
|
|
66
|
+
"Event": ("krons.utils.concurrency._primitives", "Event"),
|
|
67
|
+
"Lock": ("krons.utils.concurrency._primitives", "Lock"),
|
|
68
|
+
"Queue": ("krons.utils.concurrency._primitives", "Queue"),
|
|
69
|
+
"Semaphore": ("krons.utils.concurrency._primitives", "Semaphore"),
|
|
70
70
|
# _priority_queue
|
|
71
|
-
"PriorityQueue": ("
|
|
72
|
-
"QueueEmpty": ("
|
|
73
|
-
"QueueFull": ("
|
|
71
|
+
"PriorityQueue": ("krons.utils.concurrency._priority_queue", "PriorityQueue"),
|
|
72
|
+
"QueueEmpty": ("krons.utils.concurrency._priority_queue", "QueueEmpty"),
|
|
73
|
+
"QueueFull": ("krons.utils.concurrency._priority_queue", "QueueFull"),
|
|
74
74
|
# _resource_tracker
|
|
75
|
-
"LeakInfo": ("
|
|
76
|
-
"LeakTracker": ("
|
|
75
|
+
"LeakInfo": ("krons.utils.concurrency._resource_tracker", "LeakInfo"),
|
|
76
|
+
"LeakTracker": ("krons.utils.concurrency._resource_tracker", "LeakTracker"),
|
|
77
77
|
"track_resource": (
|
|
78
|
-
"
|
|
78
|
+
"krons.utils.concurrency._resource_tracker",
|
|
79
79
|
"track_resource",
|
|
80
80
|
),
|
|
81
81
|
"untrack_resource": (
|
|
82
|
-
"
|
|
82
|
+
"krons.utils.concurrency._resource_tracker",
|
|
83
83
|
"untrack_resource",
|
|
84
84
|
),
|
|
85
85
|
# _run_async
|
|
86
|
-
"run_async": ("
|
|
86
|
+
"run_async": ("krons.utils.concurrency._run_async", "run_async"),
|
|
87
87
|
# _task
|
|
88
|
-
"TaskGroup": ("
|
|
89
|
-
"create_task_group": ("
|
|
88
|
+
"TaskGroup": ("krons.utils.concurrency._task", "TaskGroup"),
|
|
89
|
+
"create_task_group": ("krons.utils.concurrency._task", "create_task_group"),
|
|
90
90
|
# _utils
|
|
91
|
-
"current_time": ("
|
|
92
|
-
"is_coro_func": ("
|
|
93
|
-
"run_sync": ("
|
|
94
|
-
"sleep": ("
|
|
95
|
-
"alcall": ("
|
|
96
|
-
"bcall": ("
|
|
91
|
+
"current_time": ("krons.utils.concurrency._utils", "current_time"),
|
|
92
|
+
"is_coro_func": ("krons.utils.concurrency._utils", "is_coro_func"),
|
|
93
|
+
"run_sync": ("krons.utils.concurrency._utils", "run_sync"),
|
|
94
|
+
"sleep": ("krons.utils.concurrency._utils", "sleep"),
|
|
95
|
+
"alcall": ("krons.utils.concurrency._async_call", "alcall"),
|
|
96
|
+
"bcall": ("krons.utils.concurrency._async_call", "bcall"),
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
_LOADED: dict[str, object] = {}
|
|
@@ -122,7 +122,7 @@ def __getattr__(name: str) -> object:
|
|
|
122
122
|
_LOADED[name] = value
|
|
123
123
|
return value
|
|
124
124
|
|
|
125
|
-
raise AttributeError(f"module '
|
|
125
|
+
raise AttributeError(f"module 'krons.utils.concurrency' has no attribute {name!r}")
|
|
126
126
|
|
|
127
127
|
|
|
128
128
|
def __dir__() -> list[str]:
|
|
@@ -11,9 +11,9 @@ Primary exports:
|
|
|
11
11
|
from collections.abc import AsyncGenerator, Callable
|
|
12
12
|
from typing import Any, ParamSpec, TypeVar
|
|
13
13
|
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
14
|
+
from krons.types._sentinel import Unset, not_sentinel
|
|
15
|
+
from krons.utils._lazy_init import LazyInit
|
|
16
|
+
from krons.utils._to_list import to_list
|
|
17
17
|
|
|
18
18
|
from ._cancel import move_on_after
|
|
19
19
|
from ._errors import get_cancelled_exc_class
|
|
@@ -4,9 +4,9 @@ from enum import Enum
|
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Literal
|
|
5
5
|
|
|
6
6
|
if TYPE_CHECKING:
|
|
7
|
-
from
|
|
7
|
+
from krons.types import KeysLike
|
|
8
8
|
|
|
9
|
-
from
|
|
9
|
+
from krons.types._sentinel import Unset
|
|
10
10
|
|
|
11
11
|
from ._string_similarity import SimilarityAlgo, string_similarity
|
|
12
12
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: krons
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Spec-based composable framework for building type-safe systems
|
|
5
|
-
Project-URL: Homepage, https://github.com/khive-ai/
|
|
6
|
-
Project-URL: Repository, https://github.com/khive-ai/
|
|
7
|
-
Project-URL: Issues, https://github.com/khive-ai/
|
|
5
|
+
Project-URL: Homepage, https://github.com/khive-ai/krons
|
|
6
|
+
Project-URL: Repository, https://github.com/khive-ai/krons
|
|
7
|
+
Project-URL: Issues, https://github.com/khive-ai/krons/issues
|
|
8
8
|
Author-email: HaiyangLi <quantocean.li@gmail.com>
|
|
9
9
|
License-Expression: Apache-2.0
|
|
10
10
|
License-File: LICENSE
|
|
@@ -46,7 +46,7 @@ pip install krons
|
|
|
46
46
|
## Quick Start
|
|
47
47
|
|
|
48
48
|
```python
|
|
49
|
-
from
|
|
49
|
+
from krons.specs import Spec, Operable
|
|
50
50
|
|
|
51
51
|
# Define specs
|
|
52
52
|
name_spec = Spec(str, name="name")
|