@@ -16,6 +16,8 @@ package attribute
1616import (
1717 "encoding/json"
1818 "fmt"
19+ "log"
20+ "os/exec"
1921 "reflect"
2022 "sort"
2123 "strings"
@@ -158,6 +160,18 @@ func NewDictionaryFromModelDefinition(estimator, prefix string) Dictionary {
158160// PremadeModelParamsDocs stores parameters and documents of all known models
159161var PremadeModelParamsDocs map [string ]map [string ]string
160162
163+ // ExtractDocString extracts parameter documents from python doc strings
164+ func ExtractDocString (module ... string ) {
165+ cmd := exec .Command ("python" , "-uc" , fmt .Sprintf ("__import__('extract_docstring').print_param_doc('%s')" , strings .Join (module , "', '" )))
166+ output , e := cmd .CombinedOutput ()
167+ if e != nil {
168+ log .Println ("ExtractDocString failed: " , e , string (output ))
169+ }
170+ if e := json .Unmarshal (output , & PremadeModelParamsDocs ); e != nil {
171+ log .Println ("ExtractDocString failed:" , e , string (output ))
172+ }
173+ }
174+
161175func removeUnnecessaryParams () {
162176 // The following parameters of canned estimators are already supported in the COLUMN clause.
163177 for _ , v := range PremadeModelParamsDocs {
@@ -171,5 +185,6 @@ func init() {
171185 if err := json .Unmarshal ([]byte (ModelParameterJSON ), & PremadeModelParamsDocs ); err != nil {
172186 panic (err ) // assertion
173187 }
188+ ExtractDocString ("sqlflow_models" )
174189 removeUnnecessaryParams ()
175190}
0 commit comments