moose-lib 0.4.304__py3-none-any.whl → 0.4.306__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 moose-lib might be problematic. Click here for more details.

moose_lib/query_param.py CHANGED
@@ -1,12 +1,13 @@
1
1
  import dataclasses
2
2
  from dataclasses import dataclass, fields, is_dataclass
3
3
  from datetime import datetime
4
- from typing import Optional, Literal, Union, Any
4
+ from typing import Optional, Union, Any
5
5
  import inspect
6
6
 
7
7
  from pydantic import BaseModel
8
+ from .data_models import DataEnum, py_type_to_column_type, ArrayType as DataModelArrayType
8
9
 
9
- scalar_types = Literal['String', 'Float', 'Int', 'Boolean', 'DateTime']
10
+ scalar_types = Union[str, DataEnum]
10
11
 
11
12
 
12
13
  @dataclass
@@ -23,30 +24,27 @@ class QueryField:
23
24
 
24
25
 
25
26
  def to_scalar_type(t: type) -> scalar_types:
26
- if t == str:
27
- return 'String'
28
- elif t == int:
29
- return 'Int'
30
- elif t == float:
31
- return 'Float'
32
- elif t == bool:
33
- return 'Boolean'
34
- elif t == datetime:
35
- return 'DateTime'
36
- raise ValueError(f"Unsupported type: {t}")
27
+ optional, mds, data_type = py_type_to_column_type(t, [])
28
+
29
+ # Check if the result is a scalar type (str or DataEnum)
30
+ if isinstance(data_type, str) or isinstance(data_type, DataEnum):
31
+ return data_type
32
+ else:
33
+ raise ValueError(f"Type {t} maps to non-scalar ClickHouse type: {data_type}")
37
34
 
38
35
 
39
36
  def unwrap_optional(union_type):
40
37
  return Union[*[arg for arg in union_type.__args__ if arg is not type(None)]]
41
38
 
42
39
 
40
+ # dmV1 code, won't upgrade to include the rich types
43
41
  def parse_scalar_value(value: str, t: scalar_types) -> Any:
44
42
  match t:
45
43
  case 'String':
46
44
  return value
47
45
  case 'Int':
48
46
  return int(value)
49
- case 'Float':
47
+ case 'Float' | 'Float64' | 'Float32':
50
48
  return float(value)
51
49
  case 'Boolean':
52
50
  value_lower = value.lower()
@@ -56,7 +54,8 @@ def parse_scalar_value(value: str, t: scalar_types) -> Any:
56
54
  case 'DateTime':
57
55
  return datetime.fromisoformat(value)
58
56
  case _:
59
- raise ValueError(f"Unsupported type: {t}")
57
+ # enum parsing will not be added to dmV1 code
58
+ return value
60
59
 
61
60
 
62
61
  def convert_pydantic_definition(cls: type) -> list[QueryField]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moose_lib
3
- Version: 0.4.304
3
+ Version: 0.4.306
4
4
  Home-page: https://www.fiveonefour.com/moose
5
5
  Author: Fiveonefour Labs Inc.
6
6
  Author-email: support@fiveonefour.com
@@ -5,7 +5,7 @@ moose_lib/data_models.py,sha256=FjFNd88WWCGMG5p5gV-Vjgp1cXARBeFapEHqDy0-WX8,9792
5
5
  moose_lib/dmv2-serializer.py,sha256=CL_Pvvg8tJOT8Qk6hywDNzY8MYGhMVdTOw8arZi3jng,49
6
6
  moose_lib/internal.py,sha256=ezqTTWS3T6nAPAxcjMPGYs-6ZwZwxOTZVuVFHiSkEmw,14269
7
7
  moose_lib/main.py,sha256=uyHkaPaKMOZGAgZrj8T4thRVC4cuPxP5CC0em2m83G8,16482
8
- moose_lib/query_param.py,sha256=AB5BKu610Ji-h1iYGMBZKfnEFqt85rS94kzhDwhWJnc,6288
8
+ moose_lib/query_param.py,sha256=FWhMXsdIexuJv57nG1YcepD-OZp7k4dNG4LkGVN1q-g,6486
9
9
  moose_lib/tasks.py,sha256=6MXA0j7nhvQILAJVTQHCAsquwrSOi2zAevghAc_7kXs,1554
10
10
  moose_lib/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  moose_lib/clients/redis_client.py,sha256=UBCdxwgZpIOIOy2EnPyxJIAYjw_qmNwGsJQCQ66SxUI,8117
@@ -31,7 +31,7 @@ tests/__init__.py,sha256=0Gh4yzPkkC3TzBGKhenpMIxJcRhyrrCfxLSfpTZnPMQ,53
31
31
  tests/conftest.py,sha256=ZVJNbnr4DwbcqkTmePW6U01zAzE6QD0kNAEZjPG1f4s,169
32
32
  tests/test_moose.py,sha256=mBsx_OYWmL8ppDzL_7Bd7xR6qf_i3-pCIO3wm2iQNaA,2136
33
33
  tests/test_redis_client.py,sha256=d9_MLYsJ4ecVil_jPB2gW3Q5aWnavxmmjZg2uYI3LVo,3256
34
- moose_lib-0.4.304.dist-info/METADATA,sha256=-0dHQIPTw7j6qDnG2pjxpiwNYcCQx8f0x7ilugWxTLk,731
35
- moose_lib-0.4.304.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- moose_lib-0.4.304.dist-info/top_level.txt,sha256=XEns2-4aCmGp2XjJAeEH9TAUcGONLnSLy6ycT9FSJh8,16
37
- moose_lib-0.4.304.dist-info/RECORD,,
34
+ moose_lib-0.4.306.dist-info/METADATA,sha256=grr5i2PVmf1luQ27A7Ppxw7Sa_lU-XvOa7MLRehAaQA,731
35
+ moose_lib-0.4.306.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
+ moose_lib-0.4.306.dist-info/top_level.txt,sha256=XEns2-4aCmGp2XjJAeEH9TAUcGONLnSLy6ycT9FSJh8,16
37
+ moose_lib-0.4.306.dist-info/RECORD,,