Skip to content

Commit e428ff8

Browse files
committed
pyyaml removal step 1
1 parent 1d681bf commit e428ff8

File tree

8 files changed

+20
-504
lines changed

8 files changed

+20
-504
lines changed

eval_protocol/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from .auth import get_fireworks_account_id, get_fireworks_api_key
1414
from .common_utils import load_jsonl
15-
from .config import RewardKitConfig, get_config, load_config
1615
from .mcp_env import (
1716
AnthropicPolicy,
1817
FireworksPolicy,
@@ -90,10 +89,6 @@
9089
# Authentication
9190
"get_fireworks_api_key",
9291
"get_fireworks_account_id",
93-
# Configuration
94-
"load_config",
95-
"get_config",
96-
"RewardKitConfig",
9792
# Utilities
9893
"load_jsonl",
9994
# MCP Environment API

eval_protocol/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,17 @@ def parse_args(args=None):
169169
gcp_group.add_argument(
170170
"--gcp-project",
171171
required=False,
172-
help="Google Cloud Project ID. Must be provided via CLI or rewardkit.yaml.",
172+
help="Google Cloud Project ID. Required for GCP deployments.",
173173
)
174174
gcp_group.add_argument(
175175
"--gcp-region",
176176
required=False,
177-
help="Google Cloud Region for deployment (e.g., 'us-central1'). Must be provided via CLI or rewardkit.yaml.",
177+
help="Google Cloud Region for deployment (e.g., 'us-central1'). Required for GCP deployments.",
178178
)
179179
gcp_group.add_argument(
180180
"--gcp-ar-repo",
181181
required=False,
182-
help="Google Artifact Registry repository name. Optional, defaults to value in rewardkit.yaml or 'eval-protocol-evaluators' if not specified.",
182+
help="Google Artifact Registry repository name. Optional, defaults to 'eval-protocol-evaluators' if not specified.",
183183
)
184184
gcp_group.add_argument(
185185
"--service-account",
@@ -202,7 +202,7 @@ def parse_args(args=None):
202202
help="Authentication mode for the deployed GCP Cloud Run service. "
203203
"'open': Publicly accessible. "
204204
"'api-key': Service is publicly accessible but requires an API key in requests (handled by the application). "
205-
"If not specified, defaults to value in rewardkit.yaml or 'api-key'. Optional.",
205+
"If not specified, defaults to 'api-key'. Optional.",
206206
)
207207

208208
# Deploy MCP command
@@ -218,11 +218,11 @@ def parse_args(args=None):
218218
)
219219
deploy_mcp_parser.add_argument(
220220
"--gcp-project",
221-
help="Google Cloud Project ID. Can also be set in rewardkit.yaml",
221+
help="Google Cloud Project ID. Required for GCP deployments.",
222222
)
223223
deploy_mcp_parser.add_argument(
224224
"--gcp-region",
225-
help="Google Cloud Region (e.g., 'us-central1'). Can also be set in rewardkit.yaml",
225+
help="Google Cloud Region (e.g., 'us-central1'). Required for GCP deployments.",
226226
)
227227
deploy_mcp_parser.add_argument(
228228
"--gcp-ar-repo",

eval_protocol/cli_commands/deploy.py

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from pathlib import Path # For path operations
1313
from 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
1816
try:
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

8179
from 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-
)
8880
from eval_protocol.evaluation import create_evaluation
8981
from 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-
363321
def 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

eval_protocol/cli_commands/deploy_mcp.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
from pathlib import Path
1010
from typing import Dict, Optional
1111

12-
from eval_protocol.config import (
13-
GCPCloudRunConfig,
14-
RewardKitConfig,
15-
_config_file_path as global_loaded_config_path,
16-
get_config,
17-
)
1812
from eval_protocol.gcp_tools import (
1913
build_and_push_docker_image,
2014
deploy_to_cloud_run,
@@ -129,7 +123,7 @@ def _generate_mcp_dockerfile_content(
129123
return dockerfile_content
130124

131125

132-
def _deploy_mcp_to_gcp_cloud_run(args, current_config, gcp_config_from_yaml):
126+
def _deploy_mcp_to_gcp_cloud_run(args):
133127
"""Deploy MCP server to GCP Cloud Run."""
134128
print(f"Starting MCP server deployment to GCP Cloud Run for '{args.id}'...")
135129

@@ -140,22 +134,16 @@ def _deploy_mcp_to_gcp_cloud_run(args, current_config, gcp_config_from_yaml):
140134

141135
# Resolve GCP configuration
142136
gcp_project_id = args.gcp_project
143-
if not gcp_project_id and gcp_config_from_yaml:
144-
gcp_project_id = gcp_config_from_yaml.project_id
145137
if not gcp_project_id:
146-
print("Error: GCP Project ID must be provided via --gcp-project or rewardkit.yaml.")
138+
print("Error: GCP Project ID must be provided via --gcp-project argument.")
147139
return None
148140

149141
gcp_region = args.gcp_region
150-
if not gcp_region and gcp_config_from_yaml:
151-
gcp_region = gcp_config_from_yaml.region
152142
if not gcp_region:
153-
print("Error: GCP Region must be provided via --gcp-region or rewardkit.yaml.")
143+
print("Error: GCP Region must be provided via --gcp-region argument.")
154144
return None
155145

156146
gcp_ar_repo_name = args.gcp_ar_repo
157-
if not gcp_ar_repo_name and gcp_config_from_yaml:
158-
gcp_ar_repo_name = gcp_config_from_yaml.artifact_registry_repository
159147
if not gcp_ar_repo_name:
160148
gcp_ar_repo_name = "eval-protocol-mcp-servers"
161149

@@ -266,14 +254,8 @@ def deploy_mcp_command(args):
266254
return False
267255

268256
try:
269-
# Load configuration
270-
current_config = get_config()
271-
gcp_config_from_yaml: Optional[GCPCloudRunConfig] = None
272-
if current_config and current_config.gcp_cloud_run:
273-
gcp_config_from_yaml = current_config.gcp_cloud_run
274-
275257
# Deploy to GCP Cloud Run
276-
service_url = _deploy_mcp_to_gcp_cloud_run(args, current_config, gcp_config_from_yaml)
258+
service_url = _deploy_mcp_to_gcp_cloud_run(args)
277259

278260
if service_url:
279261
print(f"✅ MCP server '{args.id}' successfully deployed!")

0 commit comments

Comments
 (0)