flock-core 0.4.0b17__py3-none-any.whl → 0.4.0b19__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.
Potentially problematic release.
This version of flock-core might be problematic. Click here for more details.
- flock/cli/runner.py +1 -1
- flock/core/logging/logging.py +2 -0
- flock/core/serialization/serialization_utils.py +70 -1
- flock/core/util/hydrator.py +305 -285
- flock_core-0.4.0b19.dist-info/METADATA +280 -0
- {flock_core-0.4.0b17.dist-info → flock_core-0.4.0b19.dist-info}/RECORD +9 -10
- flock/modules/output/output_module.py +0 -194
- flock_core-0.4.0b17.dist-info/METADATA +0 -572
- {flock_core-0.4.0b17.dist-info → flock_core-0.4.0b19.dist-info}/WHEEL +0 -0
- {flock_core-0.4.0b17.dist-info → flock_core-0.4.0b19.dist-info}/entry_points.txt +0 -0
- {flock_core-0.4.0b17.dist-info → flock_core-0.4.0b19.dist-info}/licenses/LICENSE +0 -0
flock/cli/runner.py
CHANGED
flock/core/logging/logging.py
CHANGED
|
@@ -79,6 +79,7 @@ COLOR_MAP = {
|
|
|
79
79
|
"api.ui.routes": "light-blue",
|
|
80
80
|
"api.ui.utils": "cyan",
|
|
81
81
|
# Default/Unknown
|
|
82
|
+
"evaluators.declarative": "light-green",
|
|
82
83
|
"unknown": "light-black",
|
|
83
84
|
}
|
|
84
85
|
|
|
@@ -90,6 +91,7 @@ LOGGERS = [
|
|
|
90
91
|
"serialization", # General serialization (new - can be base for others)
|
|
91
92
|
"serialization.utils", # Serialization helpers (new, more specific)
|
|
92
93
|
"evaluator", # Base evaluator category (new/optional)
|
|
94
|
+
"evaluators.declarative", # Declarative evaluator specifics
|
|
93
95
|
"module", # Base module category (new/optional)
|
|
94
96
|
"router", # Base router category (new/optional)
|
|
95
97
|
"mixin.dspy", # DSPy integration specifics (new)
|
|
@@ -5,8 +5,17 @@ import ast
|
|
|
5
5
|
import builtins
|
|
6
6
|
import importlib
|
|
7
7
|
import sys
|
|
8
|
+
import types
|
|
9
|
+
import typing
|
|
8
10
|
from collections.abc import Mapping, Sequence
|
|
9
|
-
from typing import
|
|
11
|
+
from typing import (
|
|
12
|
+
TYPE_CHECKING,
|
|
13
|
+
Any,
|
|
14
|
+
Literal,
|
|
15
|
+
Union,
|
|
16
|
+
get_args,
|
|
17
|
+
get_origin,
|
|
18
|
+
)
|
|
10
19
|
|
|
11
20
|
from pydantic import BaseModel
|
|
12
21
|
|
|
@@ -14,6 +23,7 @@ from pydantic import BaseModel
|
|
|
14
23
|
if TYPE_CHECKING:
|
|
15
24
|
pass
|
|
16
25
|
|
|
26
|
+
from flock.core.flock_registry import get_registry
|
|
17
27
|
from flock.core.logging.logging import get_logger
|
|
18
28
|
|
|
19
29
|
logger = get_logger("serialization.utils")
|
|
@@ -23,6 +33,65 @@ logger = get_logger("serialization.utils")
|
|
|
23
33
|
|
|
24
34
|
# --- Serialization Helper ---
|
|
25
35
|
|
|
36
|
+
# src/flock/util/hydrator.py (or import from serialization_utils)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _format_type_to_string(type_hint: type) -> str:
|
|
40
|
+
"""Converts a Python type object back into its string representation."""
|
|
41
|
+
# This needs to handle various typing scenarios (List, Dict, Union, Optional, Literal, custom types)
|
|
42
|
+
origin = typing.get_origin(type_hint)
|
|
43
|
+
args = typing.get_args(type_hint)
|
|
44
|
+
|
|
45
|
+
# Handle common cases first
|
|
46
|
+
if origin is list or origin is list:
|
|
47
|
+
if args:
|
|
48
|
+
return f"list[{_format_type_to_string(args[0])}]"
|
|
49
|
+
return "list[Any]" # Or just "list"
|
|
50
|
+
elif origin is dict or origin is dict:
|
|
51
|
+
if args and len(args) == 2:
|
|
52
|
+
return f"dict[{_format_type_to_string(args[0])}, {_format_type_to_string(args[1])}]"
|
|
53
|
+
return "dict[Any, Any]" # Or just "dict"
|
|
54
|
+
elif origin is Union or origin is types.UnionType:
|
|
55
|
+
# Handle Optional[T] as Union[T, NoneType]
|
|
56
|
+
if len(args) == 2 and type(None) in args:
|
|
57
|
+
inner_type = next(t for t in args if t is not type(None))
|
|
58
|
+
return _format_type_to_string(inner_type)
|
|
59
|
+
# return f"Optional[{_format_type_to_string(inner_type)}]"
|
|
60
|
+
return (
|
|
61
|
+
f"Union[{', '.join(_format_type_to_string(arg) for arg in args)}]"
|
|
62
|
+
)
|
|
63
|
+
elif origin is Literal:
|
|
64
|
+
formatted_args = []
|
|
65
|
+
for arg in args:
|
|
66
|
+
if isinstance(arg, str):
|
|
67
|
+
formatted_args.append(f"'{arg}'")
|
|
68
|
+
else:
|
|
69
|
+
formatted_args.append(str(arg))
|
|
70
|
+
return f"Literal[{', '.join(formatted_args)}]"
|
|
71
|
+
elif hasattr(
|
|
72
|
+
type_hint, "__forward_arg__"
|
|
73
|
+
): # Handle ForwardRefs if necessary
|
|
74
|
+
return type_hint.__forward_arg__
|
|
75
|
+
elif hasattr(type_hint, "__name__"):
|
|
76
|
+
# Handle custom types registered in registry (get preferred name)
|
|
77
|
+
registry = get_registry()
|
|
78
|
+
for (
|
|
79
|
+
name,
|
|
80
|
+
reg_type,
|
|
81
|
+
) in registry._types.items(): # Access internal for lookup
|
|
82
|
+
if reg_type == type_hint:
|
|
83
|
+
return name # Return registered name
|
|
84
|
+
return type_hint.__name__ # Fallback to class name if not registered
|
|
85
|
+
else:
|
|
86
|
+
# Fallback for complex types or types not handled above
|
|
87
|
+
type_repr = str(type_hint).replace("typing.", "") # Basic cleanup
|
|
88
|
+
type_repr = str(type_hint).replace("| None", "")
|
|
89
|
+
type_repr = type_repr.strip()
|
|
90
|
+
logger.debug(
|
|
91
|
+
f"Using fallback string representation for type: {type_repr}"
|
|
92
|
+
)
|
|
93
|
+
return type_repr
|
|
94
|
+
|
|
26
95
|
|
|
27
96
|
def extract_identifiers_from_type_str(type_str: str) -> set[str]:
|
|
28
97
|
"""Extract all identifiers from a type annotation string using the AST."""
|