castform 0.2.4__tar.gz → 0.3.0__tar.gz

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.
Files changed (268) hide show
  1. castform-0.3.0/.gitignore +52 -0
  2. castform-0.3.0/PKG-INFO +92 -0
  3. castform-0.3.0/PYPI.md +76 -0
  4. castform-0.3.0/pyproject.toml +78 -0
  5. castform-0.3.0/src/castform/__init__.py +104 -0
  6. castform-0.3.0/src/castform/__main__.py +5 -0
  7. castform-0.3.0/src/castform/_build.py +82 -0
  8. castform-0.3.0/src/castform/_cli.py +1088 -0
  9. castform-0.3.0/src/castform/_config.py +100 -0
  10. castform-0.3.0/src/castform/_credentials.py +96 -0
  11. castform-0.3.0/src/castform/_device_auth.py +131 -0
  12. castform-0.3.0/src/castform/_file_snapshot.py +226 -0
  13. castform-0.3.0/src/castform/_file_uploads.py +120 -0
  14. castform-0.3.0/src/castform/_logs.py +98 -0
  15. castform-0.3.0/src/castform/_packaging.py +195 -0
  16. castform-0.2.4/src/castform/profile_config.py → castform-0.3.0/src/castform/_profiles.py +72 -21
  17. castform-0.3.0/src/castform/_ssh.py +240 -0
  18. castform-0.3.0/src/castform/_ssh_proxy.py +57 -0
  19. castform-0.3.0/src/castform/_transport.py +222 -0
  20. castform-0.3.0/src/castform/_uploads.py +207 -0
  21. castform-0.3.0/src/castform/_validation.py +69 -0
  22. castform-0.3.0/src/castform/_version.py +8 -0
  23. castform-0.3.0/src/castform/container.py +754 -0
  24. castform-0.3.0/src/castform/errors.py +116 -0
  25. castform-0.3.0/src/castform/image.py +189 -0
  26. castform-0.3.0/src/castform/models.py +234 -0
  27. castform-0.3.0/src/castform/mount.py +190 -0
  28. castform-0.3.0/src/castform/recovery/__init__.py +71 -0
  29. castform-0.3.0/src/castform/recovery/config.py +111 -0
  30. castform-0.3.0/src/castform/recovery/events.py +65 -0
  31. castform-0.3.0/src/castform/recovery/hooks/__init__.py +449 -0
  32. castform-0.3.0/src/castform/recovery/hooks/miles.py +390 -0
  33. castform-0.3.0/src/castform/recovery/hooks/ray_env.py +100 -0
  34. castform-0.3.0/src/castform/recovery/hooks/verl.py +360 -0
  35. castform-0.3.0/src/castform/recovery/providers/__init__.py +175 -0
  36. castform-0.3.0/src/castform/recovery/providers/_common.py +562 -0
  37. castform-0.3.0/src/castform/recovery/providers/daytona.py +619 -0
  38. castform-0.3.0/src/castform/recovery/providers/e2b.py +426 -0
  39. castform-0.3.0/src/castform/recovery/providers/modal.py +615 -0
  40. castform-0.3.0/src/castform/recovery/restore.py +468 -0
  41. castform-0.3.0/src/castform/recovery/rollouts.py +534 -0
  42. castform-0.3.0/src/castform/recovery/sweep.py +204 -0
  43. castform-0.3.0/src/castform/secret.py +60 -0
  44. castform-0.3.0/src/castform_recovery.pth +1 -0
  45. castform-0.3.0/src/castform_recovery_boot.py +90 -0
  46. castform-0.2.4/.gitignore +0 -81
  47. castform-0.2.4/PKG-INFO +0 -116
  48. castform-0.2.4/README.md +0 -87
  49. castform-0.2.4/pyproject.toml +0 -49
  50. castform-0.2.4/pytest.ini +0 -36
  51. castform-0.2.4/src/castform/__init__.py +0 -5
  52. castform-0.2.4/src/castform/cli/__init__.py +0 -84
  53. castform-0.2.4/src/castform/cli/_auth.py +0 -180
  54. castform-0.2.4/src/castform/cli/_client.py +0 -49
  55. castform-0.2.4/src/castform/cli/_output.py +0 -151
  56. castform-0.2.4/src/castform/cli/_preflight.py +0 -26
  57. castform-0.2.4/src/castform/cli/control.py +0 -28
  58. castform-0.2.4/src/castform/cli/doctor.py +0 -112
  59. castform-0.2.4/src/castform/cli/help.py +0 -254
  60. castform-0.2.4/src/castform/cli/runs.py +0 -384
  61. castform-0.2.4/src/castform/cli/scaffold/CLAUDE.md +0 -115
  62. castform-0.2.4/src/castform/cli/scaffold/HARBOR_STARTER.md +0 -50
  63. castform-0.2.4/src/castform/cli/scaffold/STARTER.md +0 -101
  64. castform-0.2.4/src/castform/cli/scaffold/generic_env_tests.py +0 -92
  65. castform-0.2.4/src/castform/cli/scaffold/generic_eval_dataset.jsonl +0 -2
  66. castform-0.2.4/src/castform/cli/scaffold/generic_main.py +0 -346
  67. castform-0.2.4/src/castform/cli/scaffold/generic_train_dataset.jsonl +0 -3
  68. castform-0.2.4/src/castform/cli/scaffold/harbor_env_tests.py +0 -64
  69. castform-0.2.4/src/castform/cli/scaffold/harbor_main.py +0 -283
  70. castform-0.2.4/src/castform/cli/scaffold/skills/design-environment/SKILL.md +0 -98
  71. castform-0.2.4/src/castform/cli/scaffold/skills/generate-data/SKILL.md +0 -92
  72. castform-0.2.4/src/castform/cli/scaffold/skills/launch-run/SKILL.md +0 -94
  73. castform-0.2.4/src/castform/cli/scaffold/skills/train-sft/SKILL.md +0 -141
  74. castform-0.2.4/src/castform/cli/scaffold/skills/verify-environment/SKILL.md +0 -71
  75. castform-0.2.4/src/castform/cli/scaffold/skills/view-progress/SKILL.md +0 -70
  76. castform-0.2.4/src/castform/cli/scaffold/tests_conftest.py +0 -5
  77. castform-0.2.4/src/castform/cli/setup.py +0 -409
  78. castform-0.2.4/src/castform/config.py +0 -82
  79. castform-0.2.4/src/castform/model_auth.py +0 -70
  80. castform-0.2.4/src/castform/platform/__init__.py +0 -28
  81. castform-0.2.4/src/castform/platform/browser.py +0 -32
  82. castform-0.2.4/src/castform/platform/client.py +0 -858
  83. castform-0.2.4/src/castform/platform/config.py +0 -18
  84. castform-0.2.4/src/castform/platform/credentials.py +0 -491
  85. castform-0.2.4/src/castform/platform/device_auth.py +0 -81
  86. castform-0.2.4/src/castform/platform/environment_assets.py +0 -218
  87. castform-0.2.4/src/castform/platform/exceptions.py +0 -40
  88. castform-0.2.4/src/castform/platform/login.py +0 -94
  89. castform-0.2.4/src/castform/platform/model_session.py +0 -119
  90. castform-0.2.4/src/castform/platform/sft.py +0 -363
  91. castform-0.2.4/src/castform/rag/chunkers/__init__.py +0 -1
  92. castform-0.2.4/src/castform/rag/chunkers/email.py +0 -798
  93. castform-0.2.4/src/castform/rag/chunkers/inspector.py +0 -230
  94. castform-0.2.4/src/castform/rag/chunkers/markdown.py +0 -346
  95. castform-0.2.4/src/castform/rag/chunkers/models.py +0 -253
  96. castform-0.2.4/src/castform/rag/chunkers/storage.py +0 -77
  97. castform-0.2.4/src/castform/rag/corpus/__init__.py +0 -1
  98. castform-0.2.4/src/castform/rag/corpus/chroma/__init__.py +0 -0
  99. castform-0.2.4/src/castform/rag/corpus/chroma/client.py +0 -533
  100. castform-0.2.4/src/castform/rag/corpus/chroma/files.py +0 -162
  101. castform-0.2.4/src/castform/rag/corpus/chroma/filter_mapper.py +0 -149
  102. castform-0.2.4/src/castform/rag/corpus/chroma/source.py +0 -789
  103. castform-0.2.4/src/castform/rag/corpus/pinecone/__init__.py +0 -0
  104. castform-0.2.4/src/castform/rag/corpus/pinecone/files.py +0 -159
  105. castform-0.2.4/src/castform/rag/corpus/pinecone/filter_mapper.py +0 -194
  106. castform-0.2.4/src/castform/rag/corpus/pinecone/index_client.py +0 -460
  107. castform-0.2.4/src/castform/rag/corpus/pinecone/source.py +0 -557
  108. castform-0.2.4/src/castform/rag/corpus/postgres/__init__.py +0 -0
  109. castform-0.2.4/src/castform/rag/corpus/postgres/client.py +0 -595
  110. castform-0.2.4/src/castform/rag/corpus/postgres/exceptions.py +0 -53
  111. castform-0.2.4/src/castform/rag/corpus/postgres/filter_mapper.py +0 -119
  112. castform-0.2.4/src/castform/rag/corpus/postgres/models.py +0 -63
  113. castform-0.2.4/src/castform/rag/corpus/postgres/source.py +0 -430
  114. castform-0.2.4/src/castform/rag/corpus/search_schema/__init__.py +0 -1
  115. castform-0.2.4/src/castform/rag/corpus/search_schema/builders.py +0 -58
  116. castform-0.2.4/src/castform/rag/corpus/search_schema/dsl_parser.py +0 -47
  117. castform-0.2.4/src/castform/rag/corpus/search_schema/search_exceptions.py +0 -63
  118. castform-0.2.4/src/castform/rag/corpus/search_schema/search_types.py +0 -178
  119. castform-0.2.4/src/castform/rag/corpus/source.py +0 -127
  120. castform-0.2.4/src/castform/rag/corpus/turbopuffer/__init__.py +0 -0
  121. castform-0.2.4/src/castform/rag/corpus/turbopuffer/files.py +0 -175
  122. castform-0.2.4/src/castform/rag/corpus/turbopuffer/filter_mapper.py +0 -139
  123. castform-0.2.4/src/castform/rag/corpus/turbopuffer/namespace.py +0 -343
  124. castform-0.2.4/src/castform/rag/corpus/turbopuffer/source.py +0 -722
  125. castform-0.2.4/src/castform/rag/example_data.py +0 -308
  126. castform-0.2.4/src/castform/rag/preprocess/__init__.py +0 -0
  127. castform-0.2.4/src/castform/rag/preprocess/email/__init__.py +0 -0
  128. castform-0.2.4/src/castform/rag/preprocess/email/clean_bodies.py +0 -513
  129. castform-0.2.4/src/castform/rag/preprocess/email/dedupe.py +0 -799
  130. castform-0.2.4/src/castform/rag/preprocess/email/filter_automated_email_qas.py +0 -320
  131. castform-0.2.4/src/castform/rag/preprocess/email/filter_automated_emails.py +0 -559
  132. castform-0.2.4/src/castform/rag/preprocess/email/mbox.py +0 -257
  133. castform-0.2.4/src/castform/rag/preprocess/email/schema.py +0 -181
  134. castform-0.2.4/src/castform/rag/qa_generation/__init__.py +0 -60
  135. castform-0.2.4/src/castform/rag/qa_generation/anchor_selector.py +0 -17
  136. castform-0.2.4/src/castform/rag/qa_generation/auto_tune.py +0 -255
  137. castform-0.2.4/src/castform/rag/qa_generation/batch_processor.py +0 -500
  138. castform-0.2.4/src/castform/rag/qa_generation/checkpoint.py +0 -294
  139. castform-0.2.4/src/castform/rag/qa_generation/corpus_capabilities.py +0 -94
  140. castform-0.2.4/src/castform/rag/qa_generation/corpus_profile.py +0 -1731
  141. castform-0.2.4/src/castform/rag/qa_generation/filters/__init__.py +0 -19
  142. castform-0.2.4/src/castform/rag/qa_generation/filters/deterministic_guards.py +0 -232
  143. castform-0.2.4/src/castform/rag/qa_generation/filters/grounding_llm.py +0 -561
  144. castform-0.2.4/src/castform/rag/qa_generation/filters/hop_count_validity.py +0 -1050
  145. castform-0.2.4/src/castform/rag/qa_generation/filters/quality_gate.py +0 -243
  146. castform-0.2.4/src/castform/rag/qa_generation/filters/retrieval_llm.py +0 -867
  147. castform-0.2.4/src/castform/rag/qa_generation/formatters/__init__.py +0 -5
  148. castform-0.2.4/src/castform/rag/qa_generation/formatters/train_eval.py +0 -123
  149. castform-0.2.4/src/castform/rag/qa_generation/generated_qa.py +0 -125
  150. castform-0.2.4/src/castform/rag/qa_generation/generators/__init__.py +0 -5
  151. castform-0.2.4/src/castform/rag/qa_generation/generators/direct_llm.py +0 -751
  152. castform-0.2.4/src/castform/rag/qa_generation/helpers.py +0 -133
  153. castform-0.2.4/src/castform/rag/qa_generation/metadata_linker.py +0 -914
  154. castform-0.2.4/src/castform/rag/qa_generation/metrics.py +0 -95
  155. castform-0.2.4/src/castform/rag/qa_generation/models.py +0 -36
  156. castform-0.2.4/src/castform/rag/qa_generation/pipeline.py +0 -2605
  157. castform-0.2.4/src/castform/rag/qa_generation/pipeline_config.py +0 -1117
  158. castform-0.2.4/src/castform/rag/qa_generation/protocols.py +0 -72
  159. castform-0.2.4/src/castform/rag/qa_generation/query_rewriter.py +0 -149
  160. castform-0.2.4/src/castform/rag/qa_generation/response_parsers.py +0 -63
  161. castform-0.2.4/src/castform/rag/qa_generation/retrieval_query.py +0 -77
  162. castform-0.2.4/src/castform/rag/qa_generation/scoring.py +0 -108
  163. castform-0.2.4/src/castform/rag/qa_generation/storage.py +0 -141
  164. castform-0.2.4/src/castform/rag/qa_generation/style_controls.py +0 -230
  165. castform-0.2.4/src/castform/rag/qa_generation/transformers/__init__.py +0 -7
  166. castform-0.2.4/src/castform/rag/qa_generation/transformers/base.py +0 -125
  167. castform-0.2.4/src/castform/rag/qa_generation/transformers/dedup.py +0 -195
  168. castform-0.2.4/src/castform/rag/qa_generation/wiki_builder.py +0 -533
  169. castform-0.2.4/src/castform/rag/qa_generation/wiki_chunk_linker.py +0 -323
  170. castform-0.2.4/src/castform/traces/__init__.py +0 -8
  171. castform-0.2.4/src/castform/traces/adapter.py +0 -397
  172. castform-0.2.4/src/castform/traces/braintrust/__init__.py +0 -0
  173. castform-0.2.4/src/castform/traces/braintrust/adapter.py +0 -322
  174. castform-0.2.4/src/castform/traces/braintrust/message_extraction.py +0 -245
  175. castform-0.2.4/src/castform/traces/http.py +0 -90
  176. castform-0.2.4/src/castform/traces/pipeline.py +0 -272
  177. castform-0.2.4/src/castform/traces/pivot.py +0 -662
  178. castform-0.2.4/src/castform/traces/processing.py +0 -776
  179. castform-0.2.4/src/castform/traces/registry.py +0 -32
  180. castform-0.2.4/src/castform/utils/__init__.py +0 -14
  181. castform-0.2.4/src/castform/utils/checkpoint.py +0 -87
  182. castform-0.2.4/src/castform/validation.py +0 -376
  183. castform-0.2.4/tests/conftest.py +0 -79
  184. castform-0.2.4/tests/integration/harbor/README.md +0 -28
  185. castform-0.2.4/tests/integration/harbor/test_harbor_modal_live.py +0 -166
  186. castform-0.2.4/tests/integration/platform/test_rollout_reads.py +0 -62
  187. castform-0.2.4/tests/integration/test_async_corpus_client.py +0 -95
  188. castform-0.2.4/tests/integration/test_diversity_llm.py +0 -153
  189. castform-0.2.4/tests/integration/test_rubric_auth_retry.py +0 -145
  190. castform-0.2.4/tests/integration/traces/test_braintrust_e2e.py +0 -172
  191. castform-0.2.4/tests/unit/_scaffold.py +0 -37
  192. castform-0.2.4/tests/unit/cli_help.golden +0 -22
  193. castform-0.2.4/tests/unit/platform/test_client.py +0 -490
  194. castform-0.2.4/tests/unit/platform/test_credentials.py +0 -478
  195. castform-0.2.4/tests/unit/platform/test_device_auth.py +0 -104
  196. castform-0.2.4/tests/unit/platform/test_environment_assets.py +0 -353
  197. castform-0.2.4/tests/unit/platform/test_keyless_public_api.py +0 -32
  198. castform-0.2.4/tests/unit/platform/test_model_session.py +0 -71
  199. castform-0.2.4/tests/unit/platform/test_sft.py +0 -581
  200. castform-0.2.4/tests/unit/rag/chunkers/test_builders.py +0 -75
  201. castform-0.2.4/tests/unit/rag/chunkers/test_chunk_models.py +0 -193
  202. castform-0.2.4/tests/unit/rag/conftest.py +0 -8
  203. castform-0.2.4/tests/unit/rag/corpus/chroma/test_configurations.py +0 -868
  204. castform-0.2.4/tests/unit/rag/corpus/chroma/test_filter_mapper.py +0 -170
  205. castform-0.2.4/tests/unit/rag/corpus/chroma/test_search_related.py +0 -288
  206. castform-0.2.4/tests/unit/rag/corpus/pinecone/test_configurations.py +0 -344
  207. castform-0.2.4/tests/unit/rag/corpus/pinecone/test_filter_mapper.py +0 -172
  208. castform-0.2.4/tests/unit/rag/corpus/pinecone/test_search_related.py +0 -210
  209. castform-0.2.4/tests/unit/rag/corpus/pinecone/test_sparse_and_sampling.py +0 -218
  210. castform-0.2.4/tests/unit/rag/corpus/postgres/test_async_client.py +0 -268
  211. castform-0.2.4/tests/unit/rag/corpus/postgres/test_filter_mapper.py +0 -144
  212. castform-0.2.4/tests/unit/rag/corpus/postgres/test_search_related.py +0 -155
  213. castform-0.2.4/tests/unit/rag/corpus/postgres/test_source.py +0 -31
  214. castform-0.2.4/tests/unit/rag/corpus/test_dsl_parser.py +0 -126
  215. castform-0.2.4/tests/unit/rag/corpus/test_protocol_conformance.py +0 -354
  216. castform-0.2.4/tests/unit/rag/corpus/test_search_types.py +0 -172
  217. castform-0.2.4/tests/unit/rag/corpus/tpuf/test_configurations.py +0 -304
  218. castform-0.2.4/tests/unit/rag/corpus/tpuf/test_content_field.py +0 -30
  219. castform-0.2.4/tests/unit/rag/corpus/tpuf/test_filter_mapper.py +0 -121
  220. castform-0.2.4/tests/unit/rag/corpus/tpuf/test_hybrid_search.py +0 -221
  221. castform-0.2.4/tests/unit/rag/corpus/tpuf/test_namespace.py +0 -125
  222. castform-0.2.4/tests/unit/rag/corpus/tpuf/test_search_related.py +0 -272
  223. castform-0.2.4/tests/unit/rag/fakes/chroma.py +0 -208
  224. castform-0.2.4/tests/unit/rag/fakes/pinecone.py +0 -234
  225. castform-0.2.4/tests/unit/rag/qa_generation/test_async_cleanup.py +0 -111
  226. castform-0.2.4/tests/unit/rag/qa_generation/test_batch_processor_async.py +0 -145
  227. castform-0.2.4/tests/unit/rag/qa_generation/test_filter_and_sample_seeds.py +0 -201
  228. castform-0.2.4/tests/unit/rag/qa_generation/test_grounding_batch_isolation.py +0 -74
  229. castform-0.2.4/tests/unit/rag/qa_generation/test_grounding_removed_chunks.py +0 -146
  230. castform-0.2.4/tests/unit/rag/test_auto_tune.py +0 -453
  231. castform-0.2.4/tests/unit/rag/test_checkpoint_base.py +0 -74
  232. castform-0.2.4/tests/unit/rag/test_chunkers.py +0 -129
  233. castform-0.2.4/tests/unit/rag/test_corpus_profile.py +0 -567
  234. castform-0.2.4/tests/unit/rag/test_dedup.py +0 -131
  235. castform-0.2.4/tests/unit/rag/test_deterministic_guards.py +0 -230
  236. castform-0.2.4/tests/unit/rag/test_entity_quality.py +0 -119
  237. castform-0.2.4/tests/unit/rag/test_example_data.py +0 -128
  238. castform-0.2.4/tests/unit/rag/test_hop_count_validity.py +0 -505
  239. castform-0.2.4/tests/unit/rag/test_keybert_extraction.py +0 -491
  240. castform-0.2.4/tests/unit/rag/test_metadata_linker.py +0 -1119
  241. castform-0.2.4/tests/unit/rag/test_micro_batch.py +0 -692
  242. castform-0.2.4/tests/unit/rag/test_relabel_qa_types.py +0 -113
  243. castform-0.2.4/tests/unit/rag/test_wiki_builder.py +0 -498
  244. castform-0.2.4/tests/unit/rag/test_wiki_chunk_linker.py +0 -235
  245. castform-0.2.4/tests/unit/test_cli.py +0 -204
  246. castform-0.2.4/tests/unit/test_cli_control.py +0 -52
  247. castform-0.2.4/tests/unit/test_cli_doctor.py +0 -66
  248. castform-0.2.4/tests/unit/test_cli_help.py +0 -33
  249. castform-0.2.4/tests/unit/test_cli_help_render.py +0 -64
  250. castform-0.2.4/tests/unit/test_cli_output.py +0 -66
  251. castform-0.2.4/tests/unit/test_cli_preflight.py +0 -12
  252. castform-0.2.4/tests/unit/test_cli_runs.py +0 -338
  253. castform-0.2.4/tests/unit/test_cli_setup.py +0 -324
  254. castform-0.2.4/tests/unit/test_config.py +0 -75
  255. castform-0.2.4/tests/unit/test_example_validation_contract.py +0 -33
  256. castform-0.2.4/tests/unit/test_harbor_scaffold_runner.py +0 -141
  257. castform-0.2.4/tests/unit/test_model_auth.py +0 -74
  258. castform-0.2.4/tests/unit/test_profile_config.py +0 -29
  259. castform-0.2.4/tests/unit/test_scaffold_runner.py +0 -411
  260. castform-0.2.4/tests/unit/test_validation.py +0 -790
  261. castform-0.2.4/tests/unit/traces/test_adapter.py +0 -181
  262. castform-0.2.4/tests/unit/traces/test_braintrust_adapter.py +0 -299
  263. castform-0.2.4/tests/unit/traces/test_braintrust_extraction.py +0 -443
  264. castform-0.2.4/tests/unit/traces/test_http.py +0 -141
  265. castform-0.2.4/tests/unit/traces/test_pivot.py +0 -660
  266. castform-0.2.4/tests/unit/traces/test_processing.py +0 -978
  267. castform-0.2.4/tests/unit/traces/test_registry.py +0 -26
  268. /castform-0.2.4/src/castform/cli/scaffold/__init__.py → /castform-0.3.0/src/castform/py.typed +0 -0
@@ -0,0 +1,52 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ core/landing-app/dist-production/
7
+ wheels/
8
+ *.egg-info
9
+
10
+ # Virtual environments
11
+ .venv/
12
+
13
+ # direnv
14
+ .direnv/
15
+
16
+ # rust targets
17
+ target/
18
+
19
+ # Node
20
+ node_modules/
21
+ dist-server/
22
+ .pnpm-store/
23
+
24
+ .wrangler
25
+
26
+ # Secret files - NEVER commit these!
27
+ .env*
28
+ !.env*.example
29
+ .cloudflare.env
30
+ .dev.vars*
31
+ .mcp.json
32
+
33
+ # Nested project artifacts
34
+ **/.venv/
35
+ **/.pytest_cache/
36
+ **/.ruff_cache/
37
+ **/__pycache__/
38
+
39
+ # macOS Finder metadata
40
+ **/.DS_Store
41
+
42
+ # Local-only operator files
43
+ output.logs
44
+ hf_token.env
45
+ feedback.txt
46
+ /tmp/
47
+
48
+ # Per-cluster kubeconfigs generated by the root Makefile
49
+ .kube/
50
+
51
+ # expkit output beside an experiment: the preview page, its look (screenshots) and the version last published
52
+ .expkit/
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.5
2
+ Name: castform
3
+ Version: 0.3.0
4
+ Summary: Castform Python SDK
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: httpx<1,>=0.27
7
+ Requires-Dist: tomli>=1.1; python_version < '3.11'
8
+ Requires-Dist: websockets<16,>=15
9
+ Provides-Extra: daytona
10
+ Requires-Dist: daytona<1,>=0.184; extra == 'daytona'
11
+ Provides-Extra: e2b
12
+ Requires-Dist: e2b<3,>=2.61; (python_version >= '3.11') and extra == 'e2b'
13
+ Provides-Extra: modal
14
+ Requires-Dist: modal<1.7,>=1.5; extra == 'modal'
15
+ Description-Content-Type: text/markdown
16
+
17
+ # castform
18
+
19
+ The Python SDK (`import castform`) and the `castform` command for Castform compute.
20
+ A script describes an image and a container. Castform runs the container on a GPU
21
+ machine it finds for you. All calls are synchronous.
22
+
23
+ Requires Python 3.10 or later.
24
+
25
+ ```sh
26
+ pip install castform
27
+ ```
28
+
29
+ Versions 0.3.0 and later are the compute SDK. Earlier versions of this project are an
30
+ older, unrelated SDK that installs the same `import castform` and `castform` command, so
31
+ don't install the two side by side.
32
+
33
+ ## Log in and run a script
34
+
35
+ ```sh
36
+ castform login
37
+ castform run testfile.py
38
+ ```
39
+
40
+ Login opens browser approval and selects your workspace automatically when you belong
41
+ to one. Use `castform login --workspace WORKSPACE_ID` to choose among several. It always
42
+ prints an approval URL you can open on another machine.
43
+
44
+ `testfile.py` is a local Python script that uses the SDK to launch remote work:
45
+
46
+ ```python
47
+ import castform
48
+
49
+ container = castform.Container(
50
+ name="hello",
51
+ image=castform.Image.from_registry("python:3.12-slim"),
52
+ )
53
+ container.run(["python", "-c", "print('Hello from the container!', flush=True)"])
54
+ print(f"Launched in {container.id}")
55
+ ```
56
+
57
+ `run()` builds and starts the container as needed. The CLI runs your script locally;
58
+ the command passed to `container.run()` runs remotely. The container stays available
59
+ after the script exits. Reconnect with `castform.Container.get("hello")` to read logs,
60
+ or call `.down()` to clean up.
61
+
62
+ The CLI can do the same without a script:
63
+
64
+ ```sh
65
+ castform list # running containers; --all includes stopped ones
66
+ castform status hello
67
+ castform logs hello -f
68
+ castform exec hello -- python -c "print('again')"
69
+ castform down hello -y
70
+ ```
71
+
72
+ ## Images, GPUs and lifecycle
73
+
74
+ ```python
75
+ import castform
76
+
77
+ image = (
78
+ castform.Image.from_registry("python:3.12")
79
+ .pip_install("PyYAML==6.0.2")
80
+ .add_local_file("./train.py", "/workspace/train.py")
81
+ )
82
+ container = castform.Container(name="training", image=image, gpu="H100:8")
83
+ container.start()
84
+ container.run(["python", "/workspace/train.py"])
85
+ for text in container.logs():
86
+ print(text, end="")
87
+ container.stop()
88
+ container.start()
89
+ container.down()
90
+ ```
91
+
92
+ GPU requests use the `MODEL:COUNT` form, for example `gpu="H200:4"`.
castform-0.3.0/PYPI.md ADDED
@@ -0,0 +1,76 @@
1
+ # castform
2
+
3
+ The Python SDK (`import castform`) and the `castform` command for Castform compute.
4
+ A script describes an image and a container. Castform runs the container on a GPU
5
+ machine it finds for you. All calls are synchronous.
6
+
7
+ Requires Python 3.10 or later.
8
+
9
+ ```sh
10
+ pip install castform
11
+ ```
12
+
13
+ Versions 0.3.0 and later are the compute SDK. Earlier versions of this project are an
14
+ older, unrelated SDK that installs the same `import castform` and `castform` command, so
15
+ don't install the two side by side.
16
+
17
+ ## Log in and run a script
18
+
19
+ ```sh
20
+ castform login
21
+ castform run testfile.py
22
+ ```
23
+
24
+ Login opens browser approval and selects your workspace automatically when you belong
25
+ to one. Use `castform login --workspace WORKSPACE_ID` to choose among several. It always
26
+ prints an approval URL you can open on another machine.
27
+
28
+ `testfile.py` is a local Python script that uses the SDK to launch remote work:
29
+
30
+ ```python
31
+ import castform
32
+
33
+ container = castform.Container(
34
+ name="hello",
35
+ image=castform.Image.from_registry("python:3.12-slim"),
36
+ )
37
+ container.run(["python", "-c", "print('Hello from the container!', flush=True)"])
38
+ print(f"Launched in {container.id}")
39
+ ```
40
+
41
+ `run()` builds and starts the container as needed. The CLI runs your script locally;
42
+ the command passed to `container.run()` runs remotely. The container stays available
43
+ after the script exits. Reconnect with `castform.Container.get("hello")` to read logs,
44
+ or call `.down()` to clean up.
45
+
46
+ The CLI can do the same without a script:
47
+
48
+ ```sh
49
+ castform list # running containers; --all includes stopped ones
50
+ castform status hello
51
+ castform logs hello -f
52
+ castform exec hello -- python -c "print('again')"
53
+ castform down hello -y
54
+ ```
55
+
56
+ ## Images, GPUs and lifecycle
57
+
58
+ ```python
59
+ import castform
60
+
61
+ image = (
62
+ castform.Image.from_registry("python:3.12")
63
+ .pip_install("PyYAML==6.0.2")
64
+ .add_local_file("./train.py", "/workspace/train.py")
65
+ )
66
+ container = castform.Container(name="training", image=image, gpu="H100:8")
67
+ container.start()
68
+ container.run(["python", "/workspace/train.py"])
69
+ for text in container.logs():
70
+ print(text, end="")
71
+ container.stop()
72
+ container.start()
73
+ container.down()
74
+ ```
75
+
76
+ GPU requests use the `MODEL:COUNT` form, for example `gpu="H200:4"`.
@@ -0,0 +1,78 @@
1
+ [project]
2
+ name = "castform"
3
+ version = "0.3.0"
4
+ description = "Castform Python SDK"
5
+ readme = "PYPI.md"
6
+ # 3.10 and up: castform.recovery runs in the customer's training environment (miles and verl run
7
+ # on 3.10 to 3.12).
8
+ requires-python = ">=3.10"
9
+ dependencies = [
10
+ "httpx>=0.27,<1",
11
+ "websockets>=15,<16",
12
+ "tomli>=1.1; python_version < '3.11'",
13
+ ]
14
+
15
+ # The provider SDK versions castform.recovery's adapters support, as pins (RECOVERY.md): a
16
+ # customer's job brings its own SDK, so the docs don't use these, and the library needs none.
17
+ [project.optional-dependencies]
18
+ modal = ["modal>=1.5,<1.7"]
19
+ # e2b 2.61 needs Python 3.11 or later; on 3.10 the extra installs nothing (Modal works there).
20
+ e2b = ["e2b>=2.61,<3; python_version >= '3.11'"]
21
+ # Harbor asks for daytona>=0.184.0; the adapter takes any later 0.x (providers/daytona.py).
22
+ daytona = ["daytona>=0.184,<1"]
23
+
24
+ [project.scripts]
25
+ castform = "castform._cli:main"
26
+
27
+ [build-system]
28
+ requires = ["hatchling>=1.27"]
29
+ build-backend = "hatchling.build"
30
+
31
+ # verl v0.9.1 imports every verl.plugins entry point on `import verl` (castform_recovery_boot.py).
32
+ [project.entry-points."verl.plugins"]
33
+ castform_recovery = "castform_recovery_boot"
34
+
35
+ # The source archive PyPI serves: the package and what building it needs. Tests, the
36
+ # development README, RECOVERY.md and the lockfile stay in the repository.
37
+ [tool.hatch.build.targets.sdist]
38
+ include = ["src/", "PYPI.md", "pyproject.toml"]
39
+
40
+ [tool.hatch.build.targets.wheel]
41
+ packages = ["src/castform"]
42
+
43
+ # At the root of site-packages: the .pth loads castform.recovery in every process at startup when
44
+ # CASTFORM_RECOVERY is on (castform_recovery_boot.py); off, it reads one variable and stops.
45
+ [tool.hatch.build.targets.wheel.force-include]
46
+ "src/castform_recovery_boot.py" = "castform_recovery_boot.py"
47
+ "src/castform_recovery.pth" = "castform_recovery.pth"
48
+
49
+ [dependency-groups]
50
+ dev = [
51
+ "pyright>=1.1.408",
52
+ "pytest>=8,<10",
53
+ "pytest-asyncio>=0.24,<2",
54
+ "ruff>=0.15,<1",
55
+ # castform.recovery's adapter tests run against the real SDKs (no network: `provider` is off).
56
+ "modal>=1.5,<1.7",
57
+ "e2b>=2.61,<3; python_version >= '3.11'",
58
+ "daytona>=0.184,<1",
59
+ ]
60
+
61
+ [tool.ruff]
62
+ line-length = 100
63
+ target-version = "py310"
64
+ src = ["src", "tests", "tests/recovery"]
65
+
66
+ [tool.ruff.lint]
67
+ select = ["B", "E", "F", "I", "UP"]
68
+
69
+ [tool.pytest.ini_options]
70
+ testpaths = ["tests"]
71
+ # The source, not an installed copy (an editable install copies castform_recovery_boot.py), and
72
+ # castform.recovery's test helpers (core_helpers, verl_stubs), imported by name.
73
+ pythonpath = ["src", "tests/recovery"]
74
+ asyncio_mode = "auto"
75
+ markers = ["provider: calls a real provider's API (needs credentials; costs money)"]
76
+ # Real provider calls (Modal, E2B, Daytona) only when asked for (-m provider): a developer's
77
+ # machine may hold credentials.
78
+ addopts = ["-m", "not provider"]
@@ -0,0 +1,104 @@
1
+ """Castform Python SDK.
2
+
3
+ Every public name is looked up at first use (module `__getattr__`), so `import castform` loads
4
+ none of the SDK's modules: training code that only uses castform.recovery (`import
5
+ castform.recovery as cr`, `@cr.rollout`; RECOVERY.md) doesn't load the client (httpx, ssl), and
6
+ a launcher loads what it uses. Keep it that way: tests/recovery/test_public_api.py checks it.
7
+ """
8
+
9
+ from importlib import import_module
10
+ from typing import TYPE_CHECKING
11
+
12
+ # Public name -> the module that defines it.
13
+ _NAMES = {
14
+ "__version__": "castform._version",
15
+ "Container": "castform.container",
16
+ **dict.fromkeys(
17
+ (
18
+ "AlreadyExistsError",
19
+ "APIError",
20
+ "AuthenticationError",
21
+ "BuildFailedError",
22
+ "CastformError",
23
+ "ConflictError",
24
+ "ContainerStartError",
25
+ "NotFoundError",
26
+ "PermissionDeniedError",
27
+ "QuotaExceededError",
28
+ "RateLimitError",
29
+ "UnsupportedFeatureError",
30
+ "ValidationError",
31
+ "WaitTimeout",
32
+ ),
33
+ "castform.errors",
34
+ ),
35
+ "Image": "castform.image",
36
+ "HostConnection": "castform.models",
37
+ "LogEvent": "castform.models",
38
+ "CloudBucketMount": "castform.mount",
39
+ "HuggingFaceMount": "castform.mount",
40
+ "Secret": "castform.secret",
41
+ }
42
+
43
+ if TYPE_CHECKING:
44
+ from ._version import __version__
45
+ from .container import Container
46
+ from .errors import (
47
+ AlreadyExistsError,
48
+ APIError,
49
+ AuthenticationError,
50
+ BuildFailedError,
51
+ CastformError,
52
+ ConflictError,
53
+ ContainerStartError,
54
+ NotFoundError,
55
+ PermissionDeniedError,
56
+ QuotaExceededError,
57
+ RateLimitError,
58
+ UnsupportedFeatureError,
59
+ ValidationError,
60
+ WaitTimeout,
61
+ )
62
+ from .image import Image
63
+ from .models import HostConnection, LogEvent
64
+ from .mount import CloudBucketMount, HuggingFaceMount
65
+ from .secret import Secret
66
+
67
+
68
+ def __getattr__(name: str):
69
+ module = _NAMES.get(name)
70
+ if module is None:
71
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
72
+ value = getattr(import_module(module), name)
73
+ globals()[name] = value # later lookups find it without coming here
74
+ return value
75
+
76
+
77
+ def __dir__():
78
+ return sorted({*globals(), *_NAMES})
79
+
80
+
81
+ __all__ = [
82
+ "__version__",
83
+ "APIError",
84
+ "AlreadyExistsError",
85
+ "AuthenticationError",
86
+ "BuildFailedError",
87
+ "CastformError",
88
+ "CloudBucketMount",
89
+ "ConflictError",
90
+ "Container",
91
+ "ContainerStartError",
92
+ "HostConnection",
93
+ "HuggingFaceMount",
94
+ "Image",
95
+ "LogEvent",
96
+ "NotFoundError",
97
+ "PermissionDeniedError",
98
+ "QuotaExceededError",
99
+ "RateLimitError",
100
+ "Secret",
101
+ "UnsupportedFeatureError",
102
+ "ValidationError",
103
+ "WaitTimeout",
104
+ ]
@@ -0,0 +1,5 @@
1
+ """Support `python -m castform` alongside the installed `castform` command."""
2
+
3
+ from ._cli import main
4
+
5
+ raise SystemExit(main())
@@ -0,0 +1,82 @@
1
+ """Internal standalone build support; not part of the MVP customer API."""
2
+
3
+ import time
4
+ from collections.abc import Iterator, Sequence
5
+
6
+ from ._logs import logs
7
+ from ._transport import Deadline, Transport, get_transport, request_key, segment
8
+ from ._uploads import prepare_image
9
+ from .errors import BuildFailedError, UnsupportedFeatureError
10
+ from .image import Image
11
+ from .models import LogEvent, _BuildResult, _BuildStatus, object_response, required
12
+
13
+
14
+ class _Build:
15
+ def __init__(self, transport: Transport, build_id: str) -> None:
16
+ self._transport = transport
17
+ self._id = build_id
18
+
19
+ @property
20
+ def id(self) -> str:
21
+ return self._id
22
+
23
+ @classmethod
24
+ def _submit(cls, image: Image, *, idempotency_key: str | None = None) -> "_Build":
25
+ key = request_key(idempotency_key)
26
+ deadline = Deadline(idempotency_key=key)
27
+ transport = get_transport()
28
+ data = transport.request(
29
+ "POST",
30
+ "/v1/builds",
31
+ body={"schema_version": 1, "image": prepare_image(image, transport, deadline)},
32
+ key=key,
33
+ deadline=deadline,
34
+ )
35
+ return cls(transport, required(object_response(required(data, "build", dict)), "id"))
36
+
37
+ @classmethod
38
+ def get(cls, build_id: str) -> "_Build":
39
+ transport = get_transport()
40
+ data = transport.request("GET", f"/v1/builds/{segment(build_id)}")
41
+ return cls(transport, required(data, "id"))
42
+
43
+ def status(self) -> _BuildStatus:
44
+ return _BuildStatus._parse(self._transport.request("GET", f"/v1/builds/{segment(self.id)}"))
45
+
46
+ def wait(self, timeout: float | None = None) -> _BuildResult:
47
+ deadline = Deadline(timeout, details={"build_id": self.id})
48
+ started = time.monotonic()
49
+ while True:
50
+ status = _BuildStatus._parse(
51
+ self._transport.request("GET", f"/v1/builds/{segment(self.id)}", deadline=deadline)
52
+ )
53
+ if status.done:
54
+ if status.error or not status.result:
55
+ error = dict(status.error or {})
56
+ raise BuildFailedError(
57
+ error.get("message", "the build produced no image"),
58
+ code=error.get("code", "build_failed"),
59
+ details={**(error.get("details") or {}), "build_id": self.id},
60
+ )
61
+ return status.result
62
+ if status.state not in {"queued", "building"}:
63
+ raise UnsupportedFeatureError(
64
+ f"unrecognized build state {status.state!r}; this castform sdk may be out "
65
+ "of date",
66
+ code="unsupported_state",
67
+ )
68
+ deadline.pause_status(started, self._transport.settings.status_poll_interval)
69
+
70
+ def logs(
71
+ self,
72
+ follow: bool = False,
73
+ cursor: str | None = None,
74
+ sources: str | Sequence[str] = "all",
75
+ ) -> Iterator[LogEvent]:
76
+ return logs(
77
+ self._transport,
78
+ f"/v1/builds/{segment(self.id)}/logs",
79
+ follow=follow,
80
+ cursor=cursor,
81
+ sources=sources,
82
+ )