@@ -24,20 +24,50 @@ class BuildOptions(BaseModel):
2424 BUILD_SHARED_LIBS : Literal ["ON" , "OFF" ] = "ON"
2525
2626
27- class BuildConfig (BaseModel ):
28- """Build configuration."""
27+ class OpenVINOConfig (BaseModel ):
28+ """OpenVINO distribution configuration."""
2929
30- enabled : bool = Field (True , description = "Whether to build from source" )
31- openvino_repo : str = Field (..., description = "Path to OpenVINO repository" )
32- openvino_commit : str = Field ("HEAD" , description = "Git commit/tag to build" )
30+ mode : Literal ["build" , "install" , "link" ] = Field (
31+ "build" ,
32+ description = "How to obtain OpenVINO: build from source, use install dir, or download archive" ,
33+ )
34+
35+ # For 'build' mode
36+ source_dir : str | None = Field (
37+ None , description = "Path to OpenVINO source code (for build mode)"
38+ )
39+ commit : str = Field ("HEAD" , description = "Git commit/tag to build (for build mode)" )
3340 build_type : Literal ["Release" , "RelWithDebInfo" , "Debug" ] = "RelWithDebInfo"
41+
42+ # For 'install' mode
43+ install_dir : str | None = Field (
44+ None , description = "Path to OpenVINO install directory (for install mode)"
45+ )
46+
47+ # For 'link' mode
48+ archive_url : str | None = Field (
49+ None , description = "URL to OpenVINO archive (for link mode). Use 'latest' for auto-detection"
50+ )
51+
52+ # Common build options (for build mode)
3453 toolchain : Toolchain = Field (
3554 default_factory = lambda : Toolchain (
3655 android_ndk = None , abi = "arm64-v8a" , api_level = 24 , cmake = "cmake" , ninja = "ninja"
3756 )
3857 )
3958 options : BuildOptions = Field (default_factory = lambda : BuildOptions ())
4059
60+ @model_validator (mode = "after" )
61+ def validate_mode_config (self ):
62+ """Validate that required fields are set based on mode."""
63+ if self .mode == "build" and not self .source_dir :
64+ raise ValueError ("source_dir is required when mode is 'build'" )
65+ elif self .mode == "install" and not self .install_dir :
66+ raise ValueError ("install_dir is required when mode is 'install'" )
67+ elif self .mode == "link" and not self .archive_url :
68+ raise ValueError ("archive_url is required when mode is 'link'" )
69+ return self
70+
4171
4272class PackageConfig (BaseModel ):
4373 """Package configuration."""
@@ -187,7 +217,7 @@ class Experiment(BaseModel):
187217 """Complete experiment configuration."""
188218
189219 project : ProjectConfig
190- build : BuildConfig
220+ openvino : OpenVINOConfig
191221 package : PackageConfig = Field (default_factory = lambda : PackageConfig ())
192222 device : DeviceConfig
193223 models : ModelsConfig | list [ModelItem ]
0 commit comments