lumen-resources 0.3.2__tar.gz → 0.4.1__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.
Files changed (40) hide show
  1. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/PKG-INFO +1 -1
  2. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/lumen_config.py +67 -39
  3. lumen_resources-0.4.1/src/lumen_resources/result_schemas/README.md +29 -0
  4. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/schemas/config-schema.yaml +14 -9
  5. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources.egg-info/PKG-INFO +1 -1
  6. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources.egg-info/SOURCES.txt +0 -1
  7. lumen_resources-0.3.2/src/lumen_resources/result_schemas/README.md +0 -14
  8. lumen_resources-0.3.2/uv.lock +0 -1320
  9. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/.gitignore +0 -0
  10. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/README.md +0 -0
  11. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/docs/examples/clip_torch_cn.yaml +0 -0
  12. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/docs/examples/hub-service.yaml +0 -0
  13. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/docs/examples/model_info_template.json +0 -0
  14. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/docs/examples/single-service.yaml +0 -0
  15. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/pyproject.toml +0 -0
  16. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/setup.cfg +0 -0
  17. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/__init__.py +0 -0
  18. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/cli.py +0 -0
  19. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/downloader.py +0 -0
  20. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/exceptions.py +0 -0
  21. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/lumen_config_validator.py +0 -0
  22. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/model_info.py +0 -0
  23. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/model_info_validator.py +0 -0
  24. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/platform.py +0 -0
  25. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/result_schemas/__init__.py +0 -0
  26. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/result_schemas/embedding_v1.py +0 -0
  27. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/result_schemas/face_v1.py +0 -0
  28. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/result_schemas/labels_v1.py +0 -0
  29. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/result_schemas/ocr_v1.py +0 -0
  30. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/result_schemas/text_generation_v1.py +0 -0
  31. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/schemas/model_info-schema.json +0 -0
  32. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/schemas/result_schemas/embedding_v1.json +0 -0
  33. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/schemas/result_schemas/face_v1.json +0 -0
  34. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/schemas/result_schemas/labels_v1.json +0 -0
  35. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/schemas/result_schemas/ocr_v1.json +0 -0
  36. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources/schemas/result_schemas/text_generation_v1.json +0 -0
  37. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources.egg-info/dependency_links.txt +0 -0
  38. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources.egg-info/entry_points.txt +0 -0
  39. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources.egg-info/requires.txt +0 -0
  40. {lumen_resources-0.3.2 → lumen_resources-0.4.1}/src/lumen_resources.egg-info/top_level.txt +0 -0
@@ -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
@@ -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
@@ -0,0 +1,29 @@
1
+ ```bash
2
+ datamodel-codegen \
3
+ --input src/lumen_resources/schemas/result_schemas \
4
+ --output src/lumen_resources/result_schemas/ \
5
+ --use-schema-description \
6
+ --use-field-description \
7
+ --target-python-version 3.10 \
8
+ --use-standard-collections \
9
+ --use-union-operator \
10
+ --output-model-type pydantic_v2.BaseModel \
11
+ --field-constraints \
12
+ --input-file-type jsonschema \
13
+ --allow-population-by-field-name
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
@@ -1,7 +1,6 @@
1
1
  .gitignore
2
2
  README.md
3
3
  pyproject.toml
4
- uv.lock
5
4
  docs/examples/clip_torch_cn.yaml
6
5
  docs/examples/hub-service.yaml
7
6
  docs/examples/model_info_template.json
@@ -1,14 +0,0 @@
1
- ```bash
2
- datamodel-codegen \
3
- --input src/lumen_resources/schemas/result_schemas \
4
- --output src/lumen_resources/result_schemas/ \
5
- --use-schema-description \
6
- --use-field-description \
7
- --target-python-version 3.10 \
8
- --use-standard-collections \
9
- --use-union-operator \
10
- --output-model-type pydantic_v2.BaseModel \
11
- --field-constraints \
12
- --input-file-type jsonschema
13
- ```
14
-