1+ using System . Reflection ;
12using StabilityMatrix . Core . Helper ;
3+ using StabilityMatrix . Core . Models ;
24
35namespace StabilityMatrix . Tests . Core ;
46
@@ -15,12 +17,27 @@ public void ExecutableHuggingFaceModelsUsePinnedRevisions()
1517 ".pth" ,
1618 } ;
1719
18- var unpinnedModels = RemoteModels
19- . UltralyticsModelFiles
20- . Where ( model => model . DownloadableResource ? . Url . Host == "huggingface.co" )
21- . Where ( model => executableExtensions . Contains ( Path . GetExtension ( model . DownloadableResource ! . Value . Url . AbsolutePath ) ) )
22- . Where ( model => model . DownloadableResource ! . Value . Url . AbsolutePath . Contains ( "/resolve/main/" , StringComparison . Ordinal ) )
23- . Select ( model => model . DownloadableResource ! . Value . Url )
20+ var resources = typeof ( RemoteModels )
21+ . GetProperties ( BindingFlags . Public | BindingFlags . Static )
22+ . Select ( property => property . GetValue ( null ) )
23+ . SelectMany (
24+ value =>
25+ value switch
26+ {
27+ IEnumerable < RemoteResource > remoteResources => remoteResources ,
28+ IEnumerable < HybridModelFile > hybridModels => hybridModels
29+ . Where ( model => model . DownloadableResource . HasValue )
30+ . Select ( model => model . DownloadableResource ! . Value ) ,
31+ HybridModelFile { DownloadableResource : { } resource } => [ resource ] ,
32+ _ => [ ] ,
33+ }
34+ ) ;
35+
36+ var unpinnedModels = resources
37+ . Where ( resource => resource . Url . Host == "huggingface.co" )
38+ . Where ( resource => executableExtensions . Contains ( Path . GetExtension ( resource . Url . AbsolutePath ) ) )
39+ . Where ( resource => resource . Url . AbsolutePath . Contains ( "/resolve/main/" , StringComparison . Ordinal ) )
40+ . Select ( resource => resource . Url )
2441 . ToArray ( ) ;
2542
2643 Assert . Empty ( unpinnedModels ) ;
0 commit comments