lumen-resources 0.3.2__py3-none-any.whl → 0.4.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.
@@ -1,11 +1,11 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: config-schema.yaml
3
- # timestamp: 2025-12-12T07:57:50+00:00
3
+ # timestamp: 2025-12-23T18:16:59+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
7
  from enum import Enum
8
- from typing import Literal
8
+ from typing import Any, Literal
9
9
 
10
10
  from pydantic import BaseModel, ConfigDict, Field, RootModel
11
11
 
@@ -15,13 +15,16 @@ class Region(Enum):
15
15
  Platform region selection (cn=ModelScope, other=HuggingFace)
16
16
  """
17
17
 
18
- cn = "cn"
19
- other = "other"
18
+ cn = 'cn'
19
+ other = 'other'
20
20
 
21
21
 
22
22
  class Metadata(BaseModel):
23
+ model_config = ConfigDict(
24
+ populate_by_name=True,
25
+ )
23
26
  version: str = Field(
24
- ..., examples=["1.0.0", "2.1.3"], pattern="^\\d+\\.\\d+\\.\\d+$"
27
+ ..., examples=['1.0.0', '2.1.3'], pattern='^\\d+\\.\\d+\\.\\d+$'
25
28
  )
26
29
  """
27
30
  Configuration version (semantic versioning)
@@ -30,7 +33,7 @@ class Metadata(BaseModel):
30
33
  """
31
34
  Platform region selection (cn=ModelScope, other=HuggingFace)
32
35
  """
33
- cache_dir: str = Field(..., examples=["~/.lumen/models", "/opt/lumen/models"])
36
+ cache_dir: str = Field(..., examples=['~/.lumen/models', '/opt/lumen/models'])
34
37
  """
35
38
  Model cache directory path (supports ~ expansion)
36
39
  """
@@ -41,20 +44,26 @@ class Mode(Enum):
41
44
  Deployment mode
42
45
  """
43
46
 
44
- single = "single"
45
- hub = "hub"
47
+ single = 'single'
48
+ hub = 'hub'
46
49
 
47
50
 
48
51
  class Service(RootModel[str]):
49
- root: str = Field(..., pattern="^[a-z][a-z0-9_]*$")
52
+ model_config = ConfigDict(
53
+ populate_by_name=True,
54
+ )
55
+ root: str = Field(..., pattern='^[a-z][a-z0-9_]*$')
50
56
 
51
57
 
52
58
  class Deployment(BaseModel):
53
- mode: Literal["single"]
59
+ model_config = ConfigDict(
60
+ populate_by_name=True,
61
+ )
62
+ mode: Literal['single']
54
63
  """
55
64
  Deployment mode
56
65
  """
57
- service: str = Field(..., pattern="^[a-z][a-z0-9_]*$")
66
+ service: str = Field(..., pattern='^[a-z][a-z0-9_]*$')
58
67
  """
59
68
  Service name for single mode (required if mode=single)
60
69
  """
@@ -65,11 +74,14 @@ class Deployment(BaseModel):
65
74
 
66
75
 
67
76
  class Deployment1(BaseModel):
68
- mode: Literal["hub"]
77
+ model_config = ConfigDict(
78
+ populate_by_name=True,
79
+ )
80
+ mode: Literal['hub']
69
81
  """
70
82
  Deployment mode
71
83
  """
72
- service: str | None = Field(None, pattern="^[a-z][a-z0-9_]*$")
84
+ service: str | None = Field(None, pattern='^[a-z][a-z0-9_]*$')
73
85
  """
74
86
  Service name for single mode (required if mode=single)
75
87
  """
@@ -80,12 +92,15 @@ class Deployment1(BaseModel):
80
92
 
81
93
 
82
94
  class Mdns(BaseModel):
95
+ model_config = ConfigDict(
96
+ populate_by_name=True,
97
+ )
83
98
  enabled: bool | None = False
84
99
  """
85
100
  Enable mDNS service discovery
86
101
  """
87
102
  service_name: str | None = Field(
88
- None, examples=["lumen-clip", "lumen-hub"], pattern="^[a-z][a-z0-9-]*$"
103
+ None, examples=['lumen-clip', 'lumen-hub'], pattern='^[a-z][a-z0-9-]*$'
89
104
  )
90
105
  """
91
106
  mDNS service name (required if enabled=true)
@@ -93,25 +108,31 @@ class Mdns(BaseModel):
93
108
 
94
109
 
95
110
  class Server(BaseModel):
111
+ model_config = ConfigDict(
112
+ populate_by_name=True,
113
+ )
96
114
  port: int = Field(..., ge=1024, le=65535)
97
115
  """
98
116
  gRPC server port
99
117
  """
100
- host: str | None = Field("0.0.0.0", examples=["0.0.0.0", "127.0.0.1", "[::]"])
118
+ host: str | None = Field('0.0.0.0', examples=['0.0.0.0', '127.0.0.1', '[::]'])
101
119
  """
102
120
  Server bind address
103
121
  """
104
122
  mdns: Mdns | None = None
105
123
 
106
124
 
107
- class Import(BaseModel):
125
+ class ImportInfo(BaseModel):
126
+ model_config = ConfigDict(
127
+ populate_by_name=True,
128
+ )
108
129
  registry_class: str = Field(
109
130
  ...,
110
131
  examples=[
111
- "lumen_clip.service_registry.ClipService",
112
- "lumen_face.service_registry.FaceService",
132
+ 'lumen_clip.service_registry.ClipService',
133
+ 'lumen_face.service_registry.FaceService',
113
134
  ],
114
- pattern="^[a-z_][a-z0-9_.]*\\.[A-Z][a-zA-Z0-9]*$",
135
+ pattern='^[a-z_][a-z0-9_.]*\\.[A-Z][a-zA-Z0-9]*$',
115
136
  )
116
137
  """
117
138
  Full dotted path to service registry class
@@ -119,10 +140,10 @@ class Import(BaseModel):
119
140
  add_to_server: str = Field(
120
141
  ...,
121
142
  examples=[
122
- "lumen_clip.proto.ml_service_pb2_grpc.add_InferenceServicer_to_server",
123
- "lumen_face.proto.ml_service_pb2_grpc.add_FaceServicer_to_server",
143
+ 'lumen_clip.proto.ml_service_pb2_grpc.add_InferenceServicer_to_server',
144
+ 'lumen_face.proto.ml_service_pb2_grpc.add_FaceServicer_to_server',
124
145
  ],
125
- pattern="^[a-z_][a-z0-9_.]*\\.add_[A-Za-z0-9_]+_to_server$",
146
+ pattern='^[a-z_][a-z0-9_.]*\\.add_[A-Za-z0-9_]+_to_server$',
126
147
  )
127
148
  """
128
149
  Full dotted path to gRPC add_to_server function
@@ -135,7 +156,8 @@ class BackendSettings(BaseModel):
135
156
  """
136
157
 
137
158
  model_config = ConfigDict(
138
- extra="forbid",
159
+ extra='forbid',
160
+ populate_by_name=True,
139
161
  )
140
162
  device: str | None = None
141
163
  """
@@ -145,14 +167,9 @@ class BackendSettings(BaseModel):
145
167
  """
146
168
  Maximum batch size for inference.
147
169
  """
148
- onnx_providers: list[str] | None = None
170
+ onnx_providers: list[Any] | None = None
149
171
  """
150
- List of ONNX execution providers. If null, uses ONNX Runtime defaults.
151
- """
152
- prefer_fp16: bool | None = True
153
- """
154
- Whether to prefer FP16 model files over FP32 when available.
155
- Improves performance on supported hardware.
172
+ List of ONNX execution providers. Each item can be a string or a tuple of (name, config_dict).
156
173
  """
157
174
 
158
175
 
@@ -161,13 +178,16 @@ class Runtime(Enum):
161
178
  Model runtime type
162
179
  """
163
180
 
164
- torch = "torch"
165
- onnx = "onnx"
166
- rknn = "rknn"
181
+ torch = 'torch'
182
+ onnx = 'onnx'
183
+ rknn = 'rknn'
167
184
 
168
185
 
169
186
  class ModelConfig(BaseModel):
170
- model: str = Field(..., examples=["ViT-B-32", "CN-CLIP-ViT-B-16", "MobileCLIP-S2"])
187
+ model_config = ConfigDict(
188
+ populate_by_name=True,
189
+ )
190
+ model: str = Field(..., examples=['ViT-B-32', 'CN-CLIP-ViT-B-16', 'MobileCLIP-S2'])
171
191
  """
172
192
  Model repository name
173
193
  """
@@ -176,29 +196,36 @@ class ModelConfig(BaseModel):
176
196
  Model runtime type
177
197
  """
178
198
  rknn_device: str | None = Field(
179
- None, examples=["rk3566", "rk3588"], pattern="^rk\\d+$"
199
+ None, examples=['rk3566', 'rk3588'], pattern='^rk\\d+$'
180
200
  )
181
201
  """
182
202
  RKNN device identifier (required if runtime=rknn)
183
203
  """
184
- dataset: str | None = Field(None, examples=["ImageNet_1k", "TreeOfLife-10M"])
204
+ dataset: str | None = Field(None, examples=['ImageNet_1k', 'TreeOfLife-10M'])
185
205
  """
186
206
  Dataset name for zero-shot classification (optional)
187
207
  """
208
+ precision: str | None = Field(None, examples=['fp32', 'int8', 'q4fp16'])
209
+ """
210
+ Preferred precision for running the model, valid only when runtime is 'onnx' or 'rknn'. The download validator will check the precision field in model_info.json to verify if the preferred precision is available for the current model.
211
+ """
188
212
 
189
213
 
190
214
  class Services(BaseModel):
215
+ model_config = ConfigDict(
216
+ populate_by_name=True,
217
+ )
191
218
  enabled: bool
192
219
  """
193
220
  Whether to load this service
194
221
  """
195
222
  package: str = Field(
196
- ..., examples=["lumen_clip", "lumen_face"], pattern="^[a-z][a-z0-9_]*$"
223
+ ..., examples=['lumen_clip', 'lumen_face'], pattern='^[a-z][a-z0-9_]*$'
197
224
  )
198
225
  """
199
226
  Python package name
200
227
  """
201
- import_: Import = Field(..., alias="import")
228
+ import_info: ImportInfo | None = None
202
229
  backend_settings: BackendSettings | None = None
203
230
  models: dict[str, ModelConfig]
204
231
  """
@@ -212,7 +239,8 @@ class LumenConfig(BaseModel):
212
239
  """
213
240
 
214
241
  model_config = ConfigDict(
215
- extra="forbid",
242
+ extra='forbid',
243
+ populate_by_name=True,
216
244
  )
217
245
  metadata: Metadata
218
246
  deployment: Deployment | Deployment1
@@ -9,6 +9,21 @@ datamodel-codegen \
9
9
  --use-union-operator \
10
10
  --output-model-type pydantic_v2.BaseModel \
11
11
  --field-constraints \
12
- --input-file-type jsonschema
12
+ --input-file-type jsonschema \
13
+ --allow-population-by-field-name
13
14
  ```
14
15
 
16
+ ```bash
17
+ datamodel-codegen \
18
+ --input src/lumen_resources/schemas/config-schema.yaml \
19
+ --output src/lumen_resources/lumen_config.py \
20
+ --use-schema-description \
21
+ --use-field-description \
22
+ --target-python-version 3.10 \
23
+ --use-standard-collections \
24
+ --use-union-operator \
25
+ --output-model-type pydantic_v2.BaseModel \
26
+ --field-constraints \
27
+ --input-file-type jsonschema \
28
+ --allow-population-by-field-name
29
+ ```
@@ -131,6 +131,9 @@ properties:
131
131
  patternProperties:
132
132
  "^[a-z][a-z0-9_]*$":
133
133
  type: object
134
+ x-pydantic-config:
135
+ validate_by_name: true
136
+ validate_by_alias: true
134
137
  required:
135
138
  - enabled
136
139
  - package
@@ -150,7 +153,7 @@ properties:
150
153
  - "lumen_clip"
151
154
  - "lumen_face"
152
155
 
153
- import:
156
+ import_info:
154
157
  type: object
155
158
  required:
156
159
  - registry_class
@@ -197,15 +200,10 @@ definitions:
197
200
  minimum: 1
198
201
  default: 8
199
202
  onnx_providers:
200
- type: [array, "null"] # Allow array or null
201
- items:
202
- type: string
203
- description: "List of ONNX execution providers. If null, uses ONNX Runtime defaults."
203
+ type: [array, "null"]
204
+ description: "List of ONNX execution providers. Each item can be a string or a tuple of (name, config_dict)."
204
205
  default: null
205
- prefer_fp16:
206
- type: boolean
207
- description: "Whether to prefer FP16 model files over FP32 when available. Improves performance on supported hardware."
208
- default: true
206
+
209
207
  additionalProperties: false
210
208
  ModelConfig:
211
209
  type: object
@@ -240,6 +238,13 @@ definitions:
240
238
  examples:
241
239
  - "ImageNet_1k"
242
240
  - "TreeOfLife-10M"
241
+ precision:
242
+ type: string
243
+ description: Preferred precision for running the model, valid only when runtime is 'onnx' or 'rknn'. The download validator will check the precision field in model_info.json to verify if the preferred precision is available for the current model.
244
+ examples:
245
+ - "fp32"
246
+ - "int8"
247
+ - "q4fp16"
243
248
 
244
249
  # If runtime=rknn, rknn_device is required
245
250
  if:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lumen-resources
3
- Version: 0.3.2
3
+ Version: 0.4.1
4
4
  Summary: Unified model resource management for Lumen ML services
5
5
  Author-email: EdwinZhanCN <support@lumilio.org>
6
6
  License: MIT
@@ -2,27 +2,27 @@ lumen_resources/__init__.py,sha256=EwI0cDEF9eIlWT4eYWwL8MUR8-vaHEzpZ0Kf94Kxn60,2
2
2
  lumen_resources/cli.py,sha256=gGGfe0BmqjZX-2fIEEQ-MgElMn21OrabPs7Fcu6aY6A,14204
3
3
  lumen_resources/downloader.py,sha256=Gn0or7qvk3BfmKu7VtKklXxVKuBj2lk9b5Nq7Cll-kY,21589
4
4
  lumen_resources/exceptions.py,sha256=cUS76Revda0Vt6rPeUNLI2QhluNyLon1GiF5ZM4Kx30,3148
5
- lumen_resources/lumen_config.py,sha256=9lrsdVcqlwJ1lwrKRfD449FKBKtQ4ut5D26tmwuObdA,5176
5
+ lumen_resources/lumen_config.py,sha256=YqJohnwSjL1rUb9UzFv3fwav4PcU6etIJ96y0zi1XqM,6042
6
6
  lumen_resources/lumen_config_validator.py,sha256=6GIBwresO1k7yALaNt5EgQZpcxFVq7k1obRQjl4AEEI,9734
7
7
  lumen_resources/model_info.py,sha256=O7LRJnC2OJ5uAuic074hzWThruHhVyMg5Kt7eNAdZQ4,2355
8
8
  lumen_resources/model_info_validator.py,sha256=91QsUCRuxZT3wCt7xI3wsLVBmEiVXxJUk8d2MOHwNb0,9294
9
9
  lumen_resources/platform.py,sha256=EwqjQMoQY2jK0VP1jstgIW_Lu82Cxn9HDxwdCj1EN8w,9824
10
- lumen_resources/result_schemas/README.md,sha256=nPbihM4RCJxFbBHyUsRYLljyaRjULuMQgW6K1nWYGy0,384
10
+ lumen_resources/result_schemas/README.md,sha256=jQ_J3WBcZJZbD9kVkbEj6wngDBN_HQ5S-wRiUy_ociI,845
11
11
  lumen_resources/result_schemas/__init__.py,sha256=iOxu2V8w5tXrFF5jH-Qn-En7nr2b3ZlcaiswyJCtxCQ,357
12
12
  lumen_resources/result_schemas/embedding_v1.py,sha256=XlruWBMKefG7p_f06KS-_iLs8fSwO_wxkfFuBUWgSTk,671
13
13
  lumen_resources/result_schemas/face_v1.py,sha256=Vqd-VxzmmPC0tqNtRV9qYx7Xaax5CXxjJhjJ5whiT9w,1314
14
14
  lumen_resources/result_schemas/labels_v1.py,sha256=alrU2XKiLSVXGTAfcOZlPbGGKX2s-UrGQ6uYluM-BBY,829
15
15
  lumen_resources/result_schemas/ocr_v1.py,sha256=5YFAwBkRJ_dMlyENxosXRYEIyZnDOAYx7JRDVnY7ah4,1259
16
16
  lumen_resources/result_schemas/text_generation_v1.py,sha256=DQ6vb5e9tHYzd1Qf-JkDTflzbnyUWOCgleeJnTImt50,2147
17
- lumen_resources/schemas/config-schema.yaml,sha256=TXw3Gn1q0DcqVHM4jyvSA_sWfmX_GNXe_nXLvRU7_2I,8388
17
+ lumen_resources/schemas/config-schema.yaml,sha256=ts_X2ANVcWpDDeCdHYiQA-7cvEIWxPxWIjMVQFB3sHY,8671
18
18
  lumen_resources/schemas/model_info-schema.json,sha256=VkARnNvzdFKee_AROQG9AUU5Q9s2P_dt7Nvm9Mj39aU,5837
19
19
  lumen_resources/schemas/result_schemas/embedding_v1.json,sha256=6iZaXbmkP0J5fXGD4Gkrt6AZPvpK6FZaQ754sOXxFrc,841
20
20
  lumen_resources/schemas/result_schemas/face_v1.json,sha256=XcnHxwP_KR8lAv6s6npjWQxwyYAQTuBLEKrvlOqH84g,1771
21
21
  lumen_resources/schemas/result_schemas/labels_v1.json,sha256=AnOiM0VCuIKrLdrbA73pmu4QD4QaHIDNsANeU3BIOeg,1222
22
22
  lumen_resources/schemas/result_schemas/ocr_v1.json,sha256=btVUZjR_RW4CLJjIyEGCITPJFJxMqGSM7QX8OyfVguo,1653
23
23
  lumen_resources/schemas/result_schemas/text_generation_v1.json,sha256=f_qwzlfKR_zZMZsn9qQ3U1U3t7HkSk9j7XED-q_s2hc,2876
24
- lumen_resources-0.3.2.dist-info/METADATA,sha256=16Os1V15jiQlyhm8FucFSQ55YAx682maKWK-BhEUwGw,4002
25
- lumen_resources-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- lumen_resources-0.3.2.dist-info/entry_points.txt,sha256=fLCrIB9BxyIDAbJVqDGW4QyvLPlvL53WI-6lkTZ3h2M,61
27
- lumen_resources-0.3.2.dist-info/top_level.txt,sha256=XgLNoNrF2RIpI2sYIpjLuUREYRVHW13ElHoCnFYHjAQ,16
28
- lumen_resources-0.3.2.dist-info/RECORD,,
24
+ lumen_resources-0.4.1.dist-info/METADATA,sha256=bR2AusEUZ-YGSMpEazIe79PFhXgIXhuK5UZI9MOOKxE,4002
25
+ lumen_resources-0.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
+ lumen_resources-0.4.1.dist-info/entry_points.txt,sha256=fLCrIB9BxyIDAbJVqDGW4QyvLPlvL53WI-6lkTZ3h2M,61
27
+ lumen_resources-0.4.1.dist-info/top_level.txt,sha256=XgLNoNrF2RIpI2sYIpjLuUREYRVHW13ElHoCnFYHjAQ,16
28
+ lumen_resources-0.4.1.dist-info/RECORD,,