synth-ai 0.2.9.dev4__py3-none-any.whl → 0.2.9.dev7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of synth-ai might be problematic. Click here for more details.

Files changed (157) hide show
  1. examples/common_old/backend.py +0 -1
  2. examples/crafter_debug_render.py +15 -6
  3. examples/evals_old/compare_models.py +1 -0
  4. examples/finetuning_old/_backup_synth_qwen/filter_traces_achievements.py +6 -2
  5. examples/finetuning_old/_backup_synth_qwen/react_agent_lm.py +4 -4
  6. examples/finetuning_old/_backup_synth_qwen/sft_kickoff.py +4 -3
  7. examples/finetuning_old/synth_qwen_v1/filter_traces_achievements.py +6 -2
  8. examples/finetuning_old/synth_qwen_v1/finetune.py +1 -1
  9. examples/finetuning_old/synth_qwen_v1/hello_ft_model.py +4 -4
  10. examples/finetuning_old/synth_qwen_v1/infer.py +1 -2
  11. examples/finetuning_old/synth_qwen_v1/poll.py +4 -2
  12. examples/finetuning_old/synth_qwen_v1/prepare_data.py +8 -8
  13. examples/finetuning_old/synth_qwen_v1/react_agent_lm.py +5 -4
  14. examples/finetuning_old/synth_qwen_v1/run_crafter_sft_job.py +11 -8
  15. examples/finetuning_old/synth_qwen_v1/run_ft_job.py +17 -12
  16. examples/finetuning_old/synth_qwen_v1/upload_data.py +1 -1
  17. examples/finetuning_old/synth_qwen_v1/util.py +7 -2
  18. examples/rl/configs/eval_base_qwen.toml +1 -1
  19. examples/rl/configs/rl_from_base_qwen17.toml +1 -1
  20. examples/rl/download_dataset.py +26 -10
  21. examples/rl/run_eval.py +17 -15
  22. examples/rl/run_rl_and_save.py +24 -7
  23. examples/rl/task_app/math_single_step.py +128 -11
  24. examples/rl/task_app/math_task_app.py +11 -3
  25. examples/rl_old/task_app.py +222 -53
  26. examples/warming_up_to_rl/analyze_trace_db.py +7 -5
  27. examples/warming_up_to_rl/export_trace_sft.py +141 -16
  28. examples/warming_up_to_rl/groq_test.py +11 -4
  29. examples/warming_up_to_rl/manage_secrets.py +15 -6
  30. examples/warming_up_to_rl/readme.md +9 -2
  31. examples/warming_up_to_rl/run_eval.py +108 -30
  32. examples/warming_up_to_rl/run_fft_and_save.py +128 -52
  33. examples/warming_up_to_rl/run_local_rollout.py +87 -36
  34. examples/warming_up_to_rl/run_local_rollout_modal.py +113 -25
  35. examples/warming_up_to_rl/run_local_rollout_parallel.py +80 -16
  36. examples/warming_up_to_rl/run_local_rollout_traced.py +125 -20
  37. examples/warming_up_to_rl/run_rl_and_save.py +31 -7
  38. examples/warming_up_to_rl/run_rollout_remote.py +37 -10
  39. examples/warming_up_to_rl/task_app/grpo_crafter.py +90 -27
  40. examples/warming_up_to_rl/task_app/grpo_crafter_task_app.py +9 -27
  41. examples/warming_up_to_rl/task_app/synth_envs_hosted/environment_routes.py +46 -108
  42. examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/__init__.py +1 -1
  43. examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/__init__.py +1 -1
  44. examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/app.py +1 -1
  45. examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/environment.py +50 -17
  46. examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/policy.py +35 -21
  47. examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/react_agent.py +8 -4
  48. examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/shared.py +29 -26
  49. examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/tools.py +1 -1
  50. examples/warming_up_to_rl/task_app/synth_envs_hosted/hosted_app.py +17 -13
  51. examples/warming_up_to_rl/task_app/synth_envs_hosted/inference/__init__.py +1 -1
  52. examples/warming_up_to_rl/task_app/synth_envs_hosted/inference/openai_client.py +106 -63
  53. examples/warming_up_to_rl/task_app/synth_envs_hosted/policy_routes.py +82 -84
  54. examples/warming_up_to_rl/task_app/synth_envs_hosted/rollout.py +76 -59
  55. examples/warming_up_to_rl/task_app/synth_envs_hosted/storage/__init__.py +1 -1
  56. examples/warming_up_to_rl/task_app/synth_envs_hosted/storage/volume.py +43 -49
  57. examples/warming_up_to_rl/task_app/synth_envs_hosted/test_service.py +5 -15
  58. synth_ai/__init__.py +1 -0
  59. synth_ai/api/train/builders.py +34 -10
  60. synth_ai/api/train/cli.py +172 -32
  61. synth_ai/api/train/config_finder.py +59 -4
  62. synth_ai/api/train/env_resolver.py +32 -14
  63. synth_ai/api/train/pollers.py +11 -3
  64. synth_ai/api/train/task_app.py +4 -1
  65. synth_ai/api/train/utils.py +20 -4
  66. synth_ai/cli/__init__.py +11 -4
  67. synth_ai/cli/balance.py +1 -1
  68. synth_ai/cli/demo.py +19 -5
  69. synth_ai/cli/rl_demo.py +75 -16
  70. synth_ai/cli/root.py +116 -37
  71. synth_ai/cli/task_apps.py +1286 -170
  72. synth_ai/cli/traces.py +1 -0
  73. synth_ai/cli/turso.py +73 -0
  74. synth_ai/core/experiment.py +0 -2
  75. synth_ai/demo_registry.py +67 -30
  76. synth_ai/demos/core/cli.py +493 -164
  77. synth_ai/demos/demo_task_apps/core.py +50 -6
  78. synth_ai/demos/demo_task_apps/crafter/configs/crafter_fft_4b.toml +2 -3
  79. synth_ai/demos/demo_task_apps/crafter/grpo_crafter_task_app.py +36 -28
  80. synth_ai/demos/demo_task_apps/math/_common.py +1 -2
  81. synth_ai/demos/demo_task_apps/math/deploy_modal.py +0 -2
  82. synth_ai/demos/demo_task_apps/math/modal_task_app.py +168 -65
  83. synth_ai/demos/demo_task_apps/math/task_app_entry.py +0 -1
  84. synth_ai/environments/examples/bandit/engine.py +12 -4
  85. synth_ai/environments/examples/bandit/taskset.py +4 -4
  86. synth_ai/environments/reproducibility/tree.py +3 -1
  87. synth_ai/environments/service/core_routes.py +6 -2
  88. synth_ai/evals/base.py +0 -2
  89. synth_ai/experimental/synth_oss.py +11 -12
  90. synth_ai/handshake.py +3 -1
  91. synth_ai/http_client.py +31 -7
  92. synth_ai/inference/__init__.py +0 -2
  93. synth_ai/inference/client.py +8 -4
  94. synth_ai/jobs/client.py +40 -10
  95. synth_ai/learning/client.py +33 -8
  96. synth_ai/learning/config.py +0 -2
  97. synth_ai/learning/constants.py +0 -2
  98. synth_ai/learning/ft_client.py +6 -3
  99. synth_ai/learning/health.py +9 -2
  100. synth_ai/learning/jobs.py +17 -5
  101. synth_ai/learning/prompts/hello_world_in_context_injection_ex.py +1 -3
  102. synth_ai/learning/prompts/random_search.py +4 -1
  103. synth_ai/learning/prompts/run_random_search_banking77.py +6 -1
  104. synth_ai/learning/rl_client.py +42 -14
  105. synth_ai/learning/sse.py +0 -2
  106. synth_ai/learning/validators.py +6 -2
  107. synth_ai/lm/caching/ephemeral.py +1 -3
  108. synth_ai/lm/core/exceptions.py +0 -2
  109. synth_ai/lm/core/main.py +13 -1
  110. synth_ai/lm/core/synth_models.py +0 -1
  111. synth_ai/lm/core/vendor_clients.py +4 -2
  112. synth_ai/lm/overrides.py +2 -2
  113. synth_ai/lm/vendors/core/anthropic_api.py +7 -7
  114. synth_ai/lm/vendors/core/openai_api.py +2 -0
  115. synth_ai/lm/vendors/openai_standard.py +3 -1
  116. synth_ai/lm/vendors/openai_standard_responses.py +6 -3
  117. synth_ai/lm/vendors/supported/custom_endpoint.py +1 -3
  118. synth_ai/lm/vendors/synth_client.py +37 -10
  119. synth_ai/rl/__init__.py +0 -1
  120. synth_ai/rl/contracts.py +0 -2
  121. synth_ai/rl/env_keys.py +6 -1
  122. synth_ai/task/__init__.py +1 -0
  123. synth_ai/task/apps/__init__.py +11 -11
  124. synth_ai/task/auth.py +29 -17
  125. synth_ai/task/client.py +3 -1
  126. synth_ai/task/contracts.py +1 -0
  127. synth_ai/task/datasets.py +3 -1
  128. synth_ai/task/errors.py +3 -2
  129. synth_ai/task/health.py +0 -2
  130. synth_ai/task/json.py +0 -1
  131. synth_ai/task/proxy.py +2 -5
  132. synth_ai/task/rubrics.py +9 -3
  133. synth_ai/task/server.py +31 -5
  134. synth_ai/task/tracing_utils.py +8 -3
  135. synth_ai/task/validators.py +0 -1
  136. synth_ai/task/vendors.py +0 -1
  137. synth_ai/tracing_v3/db_config.py +26 -1
  138. synth_ai/tracing_v3/decorators.py +1 -0
  139. synth_ai/tracing_v3/examples/basic_usage.py +3 -2
  140. synth_ai/tracing_v3/hooks.py +2 -0
  141. synth_ai/tracing_v3/replica_sync.py +1 -0
  142. synth_ai/tracing_v3/session_tracer.py +24 -3
  143. synth_ai/tracing_v3/storage/base.py +4 -1
  144. synth_ai/tracing_v3/storage/factory.py +0 -1
  145. synth_ai/tracing_v3/turso/manager.py +102 -38
  146. synth_ai/tracing_v3/turso/models.py +4 -1
  147. synth_ai/tracing_v3/utils.py +1 -0
  148. synth_ai/v0/tracing/upload.py +32 -135
  149. {synth_ai-0.2.9.dev4.dist-info → synth_ai-0.2.9.dev7.dist-info}/METADATA +1 -1
  150. {synth_ai-0.2.9.dev4.dist-info → synth_ai-0.2.9.dev7.dist-info}/RECORD +154 -156
  151. examples/warming_up_to_rl/task_app/synth_envs_hosted/test_stepwise_rewards.py +0 -58
  152. synth_ai/environments/examples/sokoban/units/astar_common.py +0 -95
  153. synth_ai/install_sqld.sh +0 -40
  154. {synth_ai-0.2.9.dev4.dist-info → synth_ai-0.2.9.dev7.dist-info}/WHEEL +0 -0
  155. {synth_ai-0.2.9.dev4.dist-info → synth_ai-0.2.9.dev7.dist-info}/entry_points.txt +0 -0
  156. {synth_ai-0.2.9.dev4.dist-info → synth_ai-0.2.9.dev7.dist-info}/licenses/LICENSE +0 -0
  157. {synth_ai-0.2.9.dev4.dist-info → synth_ai-0.2.9.dev7.dist-info}/top_level.txt +0 -0
@@ -373,140 +373,37 @@ def upload_helper(
373
373
  raise ValueError("SYNTH_API_KEY environment variable not set")
374
374
  base_url = os.getenv("SYNTH_ENDPOINT_OVERRIDE", PROD_BASE_URL_DEFAULT)
375
375
 
376
- """Legacy block below retained for reference and disabled for linting/parsing.
377
- Start disabled block.
378
- """
379
- """
380
- from .decorators import _local, active_events_var
381
- from .trackers import synth_tracker_async, synth_tracker_sync
382
-
383
- # First close any tracker events
384
- if hasattr(synth_tracker_async, "active_events"):
385
- for event_type, event in list(synth_tracker_async.active_events.items()):
386
- if event and event.closed is None:
387
- event.closed = time.time()
388
- try:
389
- event_store.add_event(
390
- event.system_name,
391
- event.system_id,
392
- event.system_instance_id,
393
- event,
394
- )
395
- if verbose:
396
- print(f"Closed and stored tracker async event: {event_type}")
397
- except Exception as e:
398
- logging.error(f"Failed to store tracker event {event_type}: {str(e)}")
399
- synth_tracker_async.active_events.clear()
400
-
401
- # End all active events before uploading
402
- if hasattr(_local, "active_events"):
403
- for event_type, event in _local.active_events.items():
404
- if event and event.closed is None:
405
- event.closed = time.time()
406
- if hasattr(_local, "system_instance_id"):
407
- try:
408
- event_store.add_event(
409
- _local.system_name,
410
- _local.system_id,
411
- _local.system_instance_id,
412
- event,
413
- )
414
- if verbose:
415
- print(f"Closed and stored active event: {event_type}")
416
- except Exception as e:
417
- logging.error(f"Failed to store event {event_type}: {str(e)}")
418
- _local.active_events.clear()
419
-
420
- # NEW: Close all open asynchronous events
421
- active_events_async = active_events_var.get()
422
- if active_events_async:
423
- current_time = time.time()
424
- for event_type, event in list(active_events_async.items()):
425
- if event and event.closed is None:
426
- event.closed = current_time
427
- try:
428
- event_store.add_event(
429
- event.system_name,
430
- event.system_id,
431
- event.system_instance_id,
432
- event,
433
- )
434
- if verbose:
435
- print(f"Closed and stored async event: {event_type}")
436
- except Exception as e:
437
- logging.error(f"Failed to store async event {event_type}: {str(e)}")
438
- active_events_var.set({})
439
-
440
- # Also close any unclosed events in existing traces
441
376
  logged_traces = event_store.get_system_traces()
442
- traces = logged_traces + traces
443
- # traces = event_store.get_system_traces() if len(traces) == 0 else traces
444
- current_time = time.time()
445
- for trace in traces:
446
- for partition in trace.partition:
447
- for event in partition.events:
448
- if event.closed is None:
449
- event.closed = current_time
450
- event_store.add_event(
451
- trace.system_name,
452
- trace.system_id,
453
- trace.system_instance_id,
454
- event,
455
- )
456
- if verbose:
457
- print(f"Closed existing unclosed event: {event.event_type}")
458
-
459
- try:
460
- # Get traces and convert to dict format
461
- if len(traces) == 0:
462
- raise ValueError("No system traces found")
463
- traces_dict = [trace.to_dict() for trace in traces]
464
- dataset_dict = dataset.to_dict()
465
-
466
- # Validate upload format
467
- if verbose:
468
- print("Validating upload format...")
469
- validate_upload(traces_dict, dataset_dict)
470
- if verbose:
471
- print("Upload format validation successful")
472
-
473
- # Send to server
474
- upload_id, signed_url = send_system_traces_s3(
475
- dataset=dataset,
476
- traces=traces,
477
- base_url=base_url,
478
- api_key=api_key,
479
- system_id=traces[0].system_id,
480
- system_name=traces[0].system_name,
481
- verbose=verbose,
482
- )
483
-
484
- questions_json, reward_signals_json, traces_json = format_upload_output(dataset, traces)
485
- return (
486
- {
487
- "status": "success",
488
- "upload_id": upload_id,
489
- "signed_url": signed_url,
490
- },
491
- questions_json,
492
- reward_signals_json,
493
- traces_json,
494
- )
377
+ combined_traces: List[SystemTrace] = list(logged_traces) + list(traces)
378
+
379
+ if not combined_traces:
380
+ raise ValueError("No system traces found")
381
+
382
+ traces_dict = [trace.to_dict() for trace in combined_traces]
383
+ dataset_dict = dataset.to_dict()
384
+
385
+ if verbose:
386
+ print("Validating upload format...")
387
+ validate_upload(traces_dict, dataset_dict)
388
+
389
+ upload_id, signed_url = send_system_traces_s3(
390
+ dataset=dataset,
391
+ traces=combined_traces,
392
+ base_url=base_url,
393
+ api_key=api_key,
394
+ system_id=combined_traces[0].system_id,
395
+ system_name=combined_traces[0].system_name,
396
+ verbose=verbose,
397
+ )
495
398
 
496
- except ValueError as e:
497
- if verbose:
498
- print("Validation error:", str(e))
499
- print("\nTraces:")
500
- print(json.dumps(traces_dict, indent=2))
501
- print("\nDataset:")
502
- print(json.dumps(dataset_dict, indent=2))
503
- raise
504
- except requests.exceptions.HTTPError as e:
505
- if verbose:
506
- print("HTTP error occurred:", e)
507
- print("\nTraces:")
508
- print(json.dumps(traces_dict, indent=2))
509
- print("\nDataset:")
510
- print(json.dumps(dataset_dict, indent=2))
511
- raise
512
- """
399
+ questions_json, reward_signals_json, traces_json = format_upload_output(dataset, combined_traces)
400
+ return (
401
+ {
402
+ "status": "success",
403
+ "upload_id": upload_id,
404
+ "signed_url": signed_url,
405
+ },
406
+ questions_json,
407
+ reward_signals_json,
408
+ traces_json,
409
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synth-ai
3
- Version: 0.2.9.dev4
3
+ Version: 0.2.9.dev7
4
4
  Summary: RL as a service SDK - Core AI functionality and tracing
5
5
  Author-email: Synth AI <josh@usesynth.ai>
6
6
  License-Expression: MIT