1212from pathlib import Path # For path operations
1313from typing import Any , Dict
1414
15- import yaml # For saving config if save_config helper doesn't exist
16-
1715# TODO: Consider moving subprocess_manager functions to a more central location if used by core CLI
1816try :
1917 # Import functions with explicit names to match expected signatures
@@ -79,12 +77,6 @@ def start_ngrok_and_get_url(local_port, log_path):
7977
8078
8179from eval_protocol .auth import get_fireworks_account_id
82- from eval_protocol .config import (
83- GCPCloudRunConfig ,
84- RewardKitConfig ,
85- _config_file_path as global_loaded_config_path ,
86- get_config ,
87- )
8880from eval_protocol .evaluation import create_evaluation
8981from eval_protocol .gcp_tools import (
9082 build_and_push_docker_image ,
@@ -176,7 +168,7 @@ def _establish_local_server_and_tunnel(args):
176168 ) # URL, provider, server_pid, tunnel_pid
177169
178170
179- def _deploy_to_gcp_cloud_run (args , current_config , gcp_config_from_yaml ):
171+ def _deploy_to_gcp_cloud_run (args ):
180172 """Handles the logic for --target gcp-cloud-run up to service deployment."""
181173 print (f"Starting GCP Cloud Run deployment for evaluator '{ args .id } '..." )
182174
@@ -201,24 +193,18 @@ def _deploy_to_gcp_cloud_run(args, current_config, gcp_config_from_yaml):
201193
202194 # Resolve GCP project_id
203195 gcp_project_id = args .gcp_project
204- if not gcp_project_id and gcp_config_from_yaml :
205- gcp_project_id = gcp_config_from_yaml .project_id
206196 if not gcp_project_id :
207- print ("Error: GCP Project ID must be provided via --gcp-project argument or in rewardkit.yaml ." )
197+ print ("Error: GCP Project ID must be provided via --gcp-project argument." )
208198 return None
209199
210200 # Resolve GCP region
211201 gcp_region = args .gcp_region
212- if not gcp_region and gcp_config_from_yaml :
213- gcp_region = gcp_config_from_yaml .region
214202 if not gcp_region :
215- print ("Error: GCP Region must be provided via --gcp-region argument or in rewardkit.yaml ." )
203+ print ("Error: GCP Region must be provided via --gcp-region argument." )
216204 return None
217205
218206 # Resolve GCP AR repo name
219207 gcp_ar_repo_name = args .gcp_ar_repo
220- if not gcp_ar_repo_name and gcp_config_from_yaml :
221- gcp_ar_repo_name = gcp_config_from_yaml .artifact_registry_repository
222208 if not gcp_ar_repo_name :
223209 gcp_ar_repo_name = "eval-protocol-evaluators"
224210
@@ -264,32 +250,15 @@ def _deploy_to_gcp_cloud_run(args, current_config, gcp_config_from_yaml):
264250 parsed_gcp_secrets : Dict [str , Any ] = {}
265251 allow_unauthenticated_gcp = True
266252
267- resolved_auth_mode = "api-key"
268- if gcp_config_from_yaml and gcp_config_from_yaml .default_auth_mode :
269- resolved_auth_mode = gcp_config_from_yaml .default_auth_mode
270- if args .gcp_auth_mode is not None :
271- resolved_auth_mode = args .gcp_auth_mode
253+ resolved_auth_mode = args .gcp_auth_mode if args .gcp_auth_mode is not None else "api-key"
272254 print (f"Using GCP Auth Mode for service: { resolved_auth_mode } " )
273255
274256 if resolved_auth_mode == "api-key" :
275257 print ("Configuring GCP Cloud Run service for API key authentication (application layer)." )
276258 evaluator_id = args .id
277- api_key_for_service = None # This is the key the service itself will use
278- config_path = global_loaded_config_path
279-
280- if current_config .evaluator_endpoint_keys and evaluator_id in current_config .evaluator_endpoint_keys :
281- api_key_for_service = current_config .evaluator_endpoint_keys [evaluator_id ]
282- print (f"Using existing API key for '{ evaluator_id } ' from configuration for the service." )
283- else :
284- api_key_for_service = secrets .token_hex (32 )
285- print (f"Generated new API key for '{ evaluator_id } ' for the service." )
286- if not current_config .evaluator_endpoint_keys :
287- current_config .evaluator_endpoint_keys = {}
288- current_config .evaluator_endpoint_keys [evaluator_id ] = api_key_for_service
289- if config_path :
290- _save_config (current_config , config_path )
291- else :
292- print (f"Warning: No rewardkit.yaml found to save API key for '{ evaluator_id } '." )
259+ # Generate API key for the service
260+ api_key_for_service = secrets .token_hex (32 )
261+ print (f"Generated new API key for '{ evaluator_id } ' for the service." )
293262
294263 gcp_sanitized_eval_id = "" .join (filter (lambda char : char .isalnum () or char in ["-" , "_" ], args .id ))
295264 if not gcp_sanitized_eval_id :
@@ -349,17 +318,6 @@ def _deploy_to_gcp_cloud_run(args, current_config, gcp_config_from_yaml):
349318 return cloud_run_service_url
350319
351320
352- # Helper to save config (can be moved to config.py later)
353- def _save_config (config_data : RewardKitConfig , path : str ):
354- # Basic save, ideally config.py would provide a robust method
355- try :
356- with open (path , "w" ) as f :
357- yaml .dump (config_data .model_dump (exclude_none = True ), f , sort_keys = False )
358- print (f"Config updated and saved to { path } " )
359- except Exception as e :
360- print (f"Warning: Failed to save updated config to { path } : { e } " )
361-
362-
363321def deploy_command (args ):
364322 """Create and deploy an evaluator or register a remote one."""
365323
@@ -390,10 +348,7 @@ def deploy_command(args):
390348 local_tunnel_pid_to_clean = None # Initialize here
391349
392350 if args .target == "gcp-cloud-run" :
393- current_config = get_config () # Needed by the helper
394- gcp_config_from_yaml = current_config .gcp_cloud_run if current_config .gcp_cloud_run else None
395-
396- cloud_run_service_url = _deploy_to_gcp_cloud_run (args , current_config , gcp_config_from_yaml )
351+ cloud_run_service_url = _deploy_to_gcp_cloud_run (args )
397352 if not cloud_run_service_url :
398353 return 1 # Error already printed by helper
399354 service_url_to_register = cloud_run_service_url
0 commit comments