88from ..models .validate_model_request_quantization import (
99 ValidateModelRequestQuantization ,
1010)
11+ from ..models .validate_model_request_weight_source import (
12+ ValidateModelRequestWeightSource ,
13+ )
1114from ..types import UNSET , Unset
1215
1316T = TypeVar ("T" , bound = "ValidateModelRequest" )
1720class ValidateModelRequest :
1821 """
1922 Attributes:
20- huggingface_model_id (str):
23+ huggingface_model_id (str): Required when `weight_source` is `huggingface`. Carried
24+ through on the `s3_assume_role` path as the canonical
25+ model identifier (used for naming + LoRA classification
26+ hints), but architecture detection comes from `config.json`
27+ in the customer's bucket, not the HF Hub.
28+ weight_source (ValidateModelRequestWeightSource | Unset): Which validation path to run. `huggingface` (default)
29+ queries
30+ the HuggingFace Hub API. `s3_assume_role` chains the same
31+ two-hop AssumeRole the smart-loader uses (bootstrap user
32+ → platform role → customer role with ExternalId) and
33+ probes `<s3_url>config.json` directly, so an unsupported
34+ architecture surfaces before AF provisions a download Job.
35+ `s3_presigned` is intentionally not accepted: presigned
36+ URLs deliver a single archive object and architecture
37+ detection requires the full extract.
38+ Default: ValidateModelRequestWeightSource.HUGGINGFACE.
39+ s3_url (None | str | Unset): S3 prefix (must end with `/`). Required when
40+ `weight_source` is `s3_assume_role`. Points at the
41+ directory containing `config.json` + safetensors in
42+ HuggingFace layout; the smart-loader uses `aws s3 sync`
43+ on this path so a single archive object is rejected at
44+ the API boundary.
45+ s3_role_arn (None | str | Unset): Customer IAM role ARN. Required when `weight_source` is
46+ `s3_assume_role`. Role name must start with `graphn-byom-`
47+ (the platform IAM is scoped to that prefix as
48+ defense-in-depth).
49+ s3_external_id (None | str | Unset): ExternalId from the customer's IAM trust policy. Required
50+ when `weight_source` is `s3_assume_role`.
2151 hf_token_secret_id (None | str | Unset): ID of a workspace secret holding a HuggingFace token.
2252 quantization (ValidateModelRequestQuantization | Unset):
2353 gpu_memory_utilization (float | Unset): Default: 0.9.
@@ -26,17 +56,57 @@ class ValidateModelRequest:
2656 from this hint instead of waiting for a HuggingFace head-bytes
2757 probe; useful for very large models where the probe would
2858 otherwise stall the validate response.
59+ base_model_id (None | str | Unset): LoRA base override / hint, mirroring
60+ `CustomModelCreate.base_model_id`. When the validator
61+ detects a LoRA adapter and this field is set, the
62+ override **wins** over
63+ `adapter_config.json::base_model_name_or_path` -- so the
64+ allowlist check and the base-model sizing probe both run
65+ against the override. Useful for adapters whose adapter
66+ config records a local filesystem path
67+ (e.g. `C:/users/.../base`) that isn't a valid HF id.
68+ Silently ignored when the validator resolves the repo as
69+ a full model (`artifact_type=base`).
2970 """
3071
3172 huggingface_model_id : str
73+ weight_source : ValidateModelRequestWeightSource | Unset = (
74+ ValidateModelRequestWeightSource .HUGGINGFACE
75+ )
76+ s3_url : None | str | Unset = UNSET
77+ s3_role_arn : None | str | Unset = UNSET
78+ s3_external_id : None | str | Unset = UNSET
3279 hf_token_secret_id : None | str | Unset = UNSET
3380 quantization : ValidateModelRequestQuantization | Unset = UNSET
3481 gpu_memory_utilization : float | Unset = 0.9
3582 model_size_gb : int | None | Unset = UNSET
83+ base_model_id : None | str | Unset = UNSET
3684
3785 def to_dict (self ) -> dict [str , Any ]:
3886 huggingface_model_id = self .huggingface_model_id
3987
88+ weight_source : str | Unset = UNSET
89+ if not isinstance (self .weight_source , Unset ):
90+ weight_source = self .weight_source .value
91+
92+ s3_url : None | str | Unset
93+ if isinstance (self .s3_url , Unset ):
94+ s3_url = UNSET
95+ else :
96+ s3_url = self .s3_url
97+
98+ s3_role_arn : None | str | Unset
99+ if isinstance (self .s3_role_arn , Unset ):
100+ s3_role_arn = UNSET
101+ else :
102+ s3_role_arn = self .s3_role_arn
103+
104+ s3_external_id : None | str | Unset
105+ if isinstance (self .s3_external_id , Unset ):
106+ s3_external_id = UNSET
107+ else :
108+ s3_external_id = self .s3_external_id
109+
40110 hf_token_secret_id : None | str | Unset
41111 if isinstance (self .hf_token_secret_id , Unset ):
42112 hf_token_secret_id = UNSET
@@ -55,13 +125,27 @@ def to_dict(self) -> dict[str, Any]:
55125 else :
56126 model_size_gb = self .model_size_gb
57127
128+ base_model_id : None | str | Unset
129+ if isinstance (self .base_model_id , Unset ):
130+ base_model_id = UNSET
131+ else :
132+ base_model_id = self .base_model_id
133+
58134 field_dict : dict [str , Any ] = {}
59135
60136 field_dict .update (
61137 {
62138 "huggingface_model_id" : huggingface_model_id ,
63139 }
64140 )
141+ if weight_source is not UNSET :
142+ field_dict ["weight_source" ] = weight_source
143+ if s3_url is not UNSET :
144+ field_dict ["s3_url" ] = s3_url
145+ if s3_role_arn is not UNSET :
146+ field_dict ["s3_role_arn" ] = s3_role_arn
147+ if s3_external_id is not UNSET :
148+ field_dict ["s3_external_id" ] = s3_external_id
65149 if hf_token_secret_id is not UNSET :
66150 field_dict ["hf_token_secret_id" ] = hf_token_secret_id
67151 if quantization is not UNSET :
@@ -70,6 +154,8 @@ def to_dict(self) -> dict[str, Any]:
70154 field_dict ["gpu_memory_utilization" ] = gpu_memory_utilization
71155 if model_size_gb is not UNSET :
72156 field_dict ["model_size_gb" ] = model_size_gb
157+ if base_model_id is not UNSET :
158+ field_dict ["base_model_id" ] = base_model_id
73159
74160 return field_dict
75161
@@ -78,6 +164,40 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
78164 d = dict (src_dict )
79165 huggingface_model_id = d .pop ("huggingface_model_id" )
80166
167+ _weight_source = d .pop ("weight_source" , UNSET )
168+ weight_source : ValidateModelRequestWeightSource | Unset
169+ if isinstance (_weight_source , Unset ):
170+ weight_source = UNSET
171+ else :
172+ weight_source = ValidateModelRequestWeightSource (_weight_source )
173+
174+ def _parse_s3_url (data : object ) -> None | str | Unset :
175+ if data is None :
176+ return data
177+ if isinstance (data , Unset ):
178+ return data
179+ return cast (None | str | Unset , data )
180+
181+ s3_url = _parse_s3_url (d .pop ("s3_url" , UNSET ))
182+
183+ def _parse_s3_role_arn (data : object ) -> None | str | Unset :
184+ if data is None :
185+ return data
186+ if isinstance (data , Unset ):
187+ return data
188+ return cast (None | str | Unset , data )
189+
190+ s3_role_arn = _parse_s3_role_arn (d .pop ("s3_role_arn" , UNSET ))
191+
192+ def _parse_s3_external_id (data : object ) -> None | str | Unset :
193+ if data is None :
194+ return data
195+ if isinstance (data , Unset ):
196+ return data
197+ return cast (None | str | Unset , data )
198+
199+ s3_external_id = _parse_s3_external_id (d .pop ("s3_external_id" , UNSET ))
200+
81201 def _parse_hf_token_secret_id (data : object ) -> None | str | Unset :
82202 if data is None :
83203 return data
@@ -107,12 +227,26 @@ def _parse_model_size_gb(data: object) -> int | None | Unset:
107227
108228 model_size_gb = _parse_model_size_gb (d .pop ("model_size_gb" , UNSET ))
109229
230+ def _parse_base_model_id (data : object ) -> None | str | Unset :
231+ if data is None :
232+ return data
233+ if isinstance (data , Unset ):
234+ return data
235+ return cast (None | str | Unset , data )
236+
237+ base_model_id = _parse_base_model_id (d .pop ("base_model_id" , UNSET ))
238+
110239 validate_model_request = cls (
111240 huggingface_model_id = huggingface_model_id ,
241+ weight_source = weight_source ,
242+ s3_url = s3_url ,
243+ s3_role_arn = s3_role_arn ,
244+ s3_external_id = s3_external_id ,
112245 hf_token_secret_id = hf_token_secret_id ,
113246 quantization = quantization ,
114247 gpu_memory_utilization = gpu_memory_utilization ,
115248 model_size_gb = model_size_gb ,
249+ base_model_id = base_model_id ,
116250 )
117251
118252 return validate_model_request
0 commit comments