File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed 
.github/actions/validator_pypi_publish Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 11name : Publish Validator PyPi 
22description : Re-Usable action to publish a Validator to Guardrails PyPi 
33inputs :
4+   validator :
5+     description : ' Validator Name ex. guardrails/detect_pii' 
6+     required : true 
47  guardrails_token :
58    description : ' Guardrails Token' 
69    required : true 
5962      shell : bash 
6063      run : | 
6164        cd validator 
62-         python __shared_ci_script__.py  ./pyproject.toml 
63-         echo "===== pyproject.toml file after edits ====" 
64-         cat ./pyproject.toml 
65-         echo "==========================================" 
65+         python __shared_ci_script__.py ./pyproject.toml ${{ inputs.validator }} 
6666
6767     - name : Build & Upload 
6868      shell : bash 
Original file line number Diff line number Diff line change 33import  sys 
44
55
6- def  add_package_name_prefix (pyproject_path ):
6+ def  add_package_name_prefix (pyproject_path ,  validator_name ):
77    with  open (pyproject_path , "r" ) as  f :
88        content  =  f .read ()
99
@@ -15,10 +15,11 @@ def add_package_name_prefix(pyproject_path):
1515
1616    existing_name  =  toml_data .get ("project" , {}).get ("name" )
1717    if  not  existing_name :
18-         print ("Could not find the 'project.name' in pyproject.toml ." )
18+         print (f "Could not find the 'project.name' in { pyproject_path }  ." )
1919        sys .exit (1 )
2020
21-     new_name  =  f"guardrails-ai-validator-{ existing_name }  " 
21+     validator_name  =  validator_name .split ("/" )
22+     new_name  =  f"{ validator_name [0 ]}  -grhub-{ validator_name [1 ]}  " 
2223
2324    updated_content  =  re .sub (
2425        rf'(^name\s*=\s*")({ re .escape (existing_name )}  )(")' ,
@@ -34,4 +35,11 @@ def add_package_name_prefix(pyproject_path):
3435
3536
3637if  __name__  ==  "__main__" :
37-     add_package_name_prefix ("pyproject.toml" )
38+     if  len (sys .argv ) <  3 :
39+         print ("Usage: python script.py <pyproject_path> <validator-name>" )
40+         sys .exit (1 )
41+ 
42+     pyproject_path  =  sys .argv [1 ]
43+     validator_name  =  sys .argv [2 ]
44+ 
45+     add_package_name_prefix (pyproject_path , validator_name )
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments