@@ -43,7 +43,7 @@ def test_encoderfilebuilder_from_config_fails():
4343 """ ,
4444 }
4545 with pytest .raises (RuntimeError ) as exc_info :
46- EncoderfileBuilder . from_dict (** config )
46+ EncoderfileBuilder (** config )
4747 assert "Invalid model type" in str (exc_info .value )
4848
4949
@@ -70,7 +70,7 @@ def test_encoderfilebuilder_from_config_returns_builder():
7070 end
7171 """ ,
7272 }
73- builder = EncoderfileBuilder . from_dict (** config )
73+ builder = EncoderfileBuilder (** config )
7474 assert isinstance (builder , EncoderfileBuilder )
7575
7676
@@ -104,9 +104,10 @@ def test_encoderfilebuilder_build_from_dict(tmp_path):
104104 "path" : "models/token_classification" ,
105105 "model_type" : ModelType .TokenClassification ,
106106 "output_path" : str (tmp_path / f"{ name } .encoderfile" ),
107- "tokenizer" : TokenizerBuildConfig . new (
107+ "tokenizer" : TokenizerBuildConfig (
108108 pad_strategy = "batch_longest" ,
109109 ),
110+ "base_binary_path" : "./target/debug/encoderfile-runtime" ,
110111 "transform" : """
111112 --- No docs
112113 ---
@@ -125,7 +126,7 @@ def test_encoderfilebuilder_build_from_dict(tmp_path):
125126 }
126127 model_info = load_json (Path (config ["path" ]) / "config.json" )
127128 print (model_info )
128- builder = EncoderfileBuilder . from_dict (** config )
129+ builder = EncoderfileBuilder (** config )
129130 # Should not raise
130131 builder .build (workdir = None , version = None , no_download = True )
131132 result = inspect (config ["output_path" ])
@@ -172,7 +173,7 @@ def test_encoderfilebuilder_build_all_from_dict(tmp_path):
172173 end
173174 """ ,
174175 "lua_libs" : ["table" , "math" ],
175- "tokenizer" : TokenizerBuildConfig . new (
176+ "tokenizer" : TokenizerBuildConfig (
176177 pad_strategy = "batch_longest" ,
177178 truncation_side = "right" ,
178179 truncation_strategy = "longest_first" ,
@@ -182,7 +183,7 @@ def test_encoderfilebuilder_build_all_from_dict(tmp_path):
182183 "validate_transform" : False ,
183184 "target" : "x86_64-unknown-linux-musl" ,
184185 }
185- builder = EncoderfileBuilder . from_dict (** config )
186+ builder = EncoderfileBuilder (** config )
186187 builder .build (workdir = None , version = None , no_download = True )
187188 result = inspect (config ["output_path" ])
188189 assert isinstance (result , InspectInfo )
@@ -205,7 +206,7 @@ def test_encoderfilebuilder_with_target_spec_object(tmp_path):
205206 "path" : "models/token_classification" ,
206207 "model_type" : ModelType .TokenClassification ,
207208 "output_path" : str (tmp_path / f"{ name } .encoderfile" ),
208- "tokenizer" : TokenizerBuildConfig . new (
209+ "tokenizer" : TokenizerBuildConfig (
209210 pad_strategy = "batch_longest" ,
210211 ),
211212 "transform" : """
@@ -225,7 +226,7 @@ def test_encoderfilebuilder_with_target_spec_object(tmp_path):
225226 """ ,
226227 "target" : target_spec ,
227228 }
228- EncoderfileBuilder . from_dict (** config )
229+ EncoderfileBuilder (** config )
229230
230231
231232def test_encoderfilebuilder_wrong_arch (tmp_path ):
@@ -235,7 +236,7 @@ def test_encoderfilebuilder_wrong_arch(tmp_path):
235236 "path" : "models/token_classification" ,
236237 "model_type" : ModelType .TokenClassification ,
237238 "output_path" : str (tmp_path / f"{ name } .encoderfile" ),
238- "tokenizer" : TokenizerBuildConfig . new (
239+ "tokenizer" : TokenizerBuildConfig (
239240 pad_strategy = "batch_longest" ,
240241 ),
241242 "transform" : """
@@ -256,7 +257,7 @@ def test_encoderfilebuilder_wrong_arch(tmp_path):
256257 "target" : "nonsense!" ,
257258 }
258259 with pytest .raises (ValueError ) as exc_info :
259- EncoderfileBuilder . from_dict (** config )
260+ EncoderfileBuilder (** config )
260261 assert (
261262 f"Failed to parse target spec: invalid or unsupported target triple `{ config ['target' ]} `"
262263 in str (exc_info .value )
@@ -271,7 +272,7 @@ def test_tokenizer_build_config_from_dict():
271272 "max_length" : 512 ,
272273 "stride" : 0 ,
273274 }
274- tokenizer_config = TokenizerBuildConfig . new (** config )
275+ tokenizer_config = TokenizerBuildConfig (** config )
275276 assert tokenizer_config .pad_strategy == config ["pad_strategy" ]
276277 assert tokenizer_config .truncation_side == config ["truncation_side" ]
277278 assert tokenizer_config .truncation_strategy == config ["truncation_strategy" ]
@@ -288,7 +289,7 @@ def test_tokenizer_wrong_config_pad_strategy():
288289 "stride" : 0 ,
289290 }
290291 with pytest .raises (RuntimeError ) as exc_info :
291- TokenizerBuildConfig . new (** config )
292+ TokenizerBuildConfig (** config )
292293 assert f"Invalid pad strategy: { config ['pad_strategy' ]} " in str (exc_info .value )
293294
294295
@@ -301,7 +302,7 @@ def test_tokenizer_wrong_config_truncation_side():
301302 "stride" : 0 ,
302303 }
303304 with pytest .raises (RuntimeError ) as exc_info :
304- TokenizerBuildConfig . new (** config )
305+ TokenizerBuildConfig (** config )
305306 assert f"Invalid truncation side: { config ['truncation_side' ]} " in str (
306307 exc_info .value
307308 )
@@ -316,7 +317,7 @@ def test_tokenizer_wrong_config_truncation_strategy():
316317 "stride" : 0 ,
317318 }
318319 with pytest .raises (RuntimeError ) as exc_info :
319- TokenizerBuildConfig . new (** config )
320+ TokenizerBuildConfig (** config )
320321 assert f"Invalid truncation strategy: { config ['truncation_strategy' ]} " in str (
321322 exc_info .value
322323 )
@@ -331,7 +332,7 @@ def test_tokenizer_wrong_config_max_length():
331332 "stride" : 0 ,
332333 }
333334 with pytest .raises (OverflowError ):
334- TokenizerBuildConfig . new (** config )
335+ TokenizerBuildConfig (** config )
335336
336337
337338def test_tokenizer_wrong_type_max_length ():
@@ -343,7 +344,7 @@ def test_tokenizer_wrong_type_max_length():
343344 "stride" : 0 ,
344345 }
345346 with pytest .raises (TypeError ) as exc_info :
346- TokenizerBuildConfig . new (** config )
347+ TokenizerBuildConfig (** config )
347348 assert "'str' object cannot be interpreted as an integer" in str (exc_info .value )
348349
349350
@@ -356,7 +357,7 @@ def test_tokenizer_wrong_config_stride():
356357 "stride" : - 1 ,
357358 }
358359 with pytest .raises (OverflowError ):
359- TokenizerBuildConfig . new (** config )
360+ TokenizerBuildConfig (** config )
360361
361362
362363def test_tokenizer_wrong_type_stride ():
@@ -368,7 +369,7 @@ def test_tokenizer_wrong_type_stride():
368369 "stride" : "nonsense!" ,
369370 }
370371 with pytest .raises (TypeError ) as exc_info :
371- TokenizerBuildConfig . new (** config )
372+ TokenizerBuildConfig (** config )
372373 assert "'str' object cannot be interpreted as an integer" in str (exc_info .value )
373374
374375
@@ -380,7 +381,7 @@ def test_tokenizer_config_optional_fields():
380381 "max_length" : None ,
381382 "stride" : None ,
382383 }
383- tokenizer_config = TokenizerBuildConfig . new (** config )
384+ tokenizer_config = TokenizerBuildConfig (** config )
384385 assert tokenizer_config .pad_strategy is None
385386 assert tokenizer_config .truncation_side is None
386387 assert tokenizer_config .truncation_strategy is None
@@ -390,7 +391,7 @@ def test_tokenizer_config_optional_fields():
390391
391392def test_tokenizer_config_all_optional_fields ():
392393 config = {}
393- tokenizer_config = TokenizerBuildConfig . new (** config )
394+ tokenizer_config = TokenizerBuildConfig (** config )
394395 assert tokenizer_config .pad_strategy is None
395396 assert tokenizer_config .truncation_side is None
396397 assert tokenizer_config .truncation_strategy is None
@@ -403,7 +404,7 @@ def test_tokenizer_config_partial_optional_fields():
403404 "pad_strategy" : "batch_longest" ,
404405 "max_length" : 512 ,
405406 }
406- tokenizer_config = TokenizerBuildConfig . new (** config )
407+ tokenizer_config = TokenizerBuildConfig (** config )
407408 assert tokenizer_config .pad_strategy == config ["pad_strategy" ]
408409 assert tokenizer_config .truncation_side is None
409410 assert tokenizer_config .truncation_strategy is None
0 commit comments