fcloud-sdk 0.1.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 (125) hide show
  1. fcloud_sdk-0.1.0/CHANGELOG.md +90 -0
  2. fcloud_sdk-0.1.0/CONTRIBUTING.md +37 -0
  3. fcloud_sdk-0.1.0/LICENSE +202 -0
  4. fcloud_sdk-0.1.0/MANIFEST.in +8 -0
  5. fcloud_sdk-0.1.0/NOTICE +4 -0
  6. fcloud_sdk-0.1.0/PKG-INFO +234 -0
  7. fcloud_sdk-0.1.0/README.md +200 -0
  8. fcloud_sdk-0.1.0/SKILL.md +1185 -0
  9. fcloud_sdk-0.1.0/pyproject.toml +75 -0
  10. fcloud_sdk-0.1.0/setup.cfg +4 -0
  11. fcloud_sdk-0.1.0/src/fcloud/SKILL.md +1185 -0
  12. fcloud_sdk-0.1.0/src/fcloud/__init__.py +85 -0
  13. fcloud_sdk-0.1.0/src/fcloud/__main__.py +150 -0
  14. fcloud_sdk-0.1.0/src/fcloud/_direct_bridge.py +1645 -0
  15. fcloud_sdk-0.1.0/src/fcloud/_legacy_env.py +14 -0
  16. fcloud_sdk-0.1.0/src/fcloud/cli/__init__.py +23 -0
  17. fcloud_sdk-0.1.0/src/fcloud/cli/attach.py +180 -0
  18. fcloud_sdk-0.1.0/src/fcloud/cli/common.py +382 -0
  19. fcloud_sdk-0.1.0/src/fcloud/cli/console.py +227 -0
  20. fcloud_sdk-0.1.0/src/fcloud/cli/context.py +161 -0
  21. fcloud_sdk-0.1.0/src/fcloud/cli/exec_cmd.py +201 -0
  22. fcloud_sdk-0.1.0/src/fcloud/cli/files.py +280 -0
  23. fcloud_sdk-0.1.0/src/fcloud/cli/hardware.py +83 -0
  24. fcloud_sdk-0.1.0/src/fcloud/cli/help.py +150 -0
  25. fcloud_sdk-0.1.0/src/fcloud/cli/interactive.py +104 -0
  26. fcloud_sdk-0.1.0/src/fcloud/cli/job.py +300 -0
  27. fcloud_sdk-0.1.0/src/fcloud/cli/main.py +140 -0
  28. fcloud_sdk-0.1.0/src/fcloud/cli/migration.py +276 -0
  29. fcloud_sdk-0.1.0/src/fcloud/cli/mount.py +150 -0
  30. fcloud_sdk-0.1.0/src/fcloud/cli/output.py +17 -0
  31. fcloud_sdk-0.1.0/src/fcloud/cli/processes.py +360 -0
  32. fcloud_sdk-0.1.0/src/fcloud/cli/registry.py +28 -0
  33. fcloud_sdk-0.1.0/src/fcloud/cli/run.py +318 -0
  34. fcloud_sdk-0.1.0/src/fcloud/cli/sessions.py +592 -0
  35. fcloud_sdk-0.1.0/src/fcloud/cli/setup.py +44 -0
  36. fcloud_sdk-0.1.0/src/fcloud/cli/ssh.py +255 -0
  37. fcloud_sdk-0.1.0/src/fcloud/cli/sweep.py +578 -0
  38. fcloud_sdk-0.1.0/src/fcloud/cli/sweep_harvest.py +187 -0
  39. fcloud_sdk-0.1.0/src/fcloud/cli/sweep_watch.py +104 -0
  40. fcloud_sdk-0.1.0/src/fcloud/cli/volume.py +317 -0
  41. fcloud_sdk-0.1.0/src/fcloud/cli/wait.py +314 -0
  42. fcloud_sdk-0.1.0/src/fcloud/cli_args.py +348 -0
  43. fcloud_sdk-0.1.0/src/fcloud/client.py +632 -0
  44. fcloud_sdk-0.1.0/src/fcloud/client_projects.py +52 -0
  45. fcloud_sdk-0.1.0/src/fcloud/client_sessions.py +111 -0
  46. fcloud_sdk-0.1.0/src/fcloud/client_volumes.py +80 -0
  47. fcloud_sdk-0.1.0/src/fcloud/config.py +404 -0
  48. fcloud_sdk-0.1.0/src/fcloud/direct.py +535 -0
  49. fcloud_sdk-0.1.0/src/fcloud/errors.py +102 -0
  50. fcloud_sdk-0.1.0/src/fcloud/fileset.py +155 -0
  51. fcloud_sdk-0.1.0/src/fcloud/image.py +483 -0
  52. fcloud_sdk-0.1.0/src/fcloud/job.py +249 -0
  53. fcloud_sdk-0.1.0/src/fcloud/providers/__init__.py +5 -0
  54. fcloud_sdk-0.1.0/src/fcloud/providers/requests_http.py +59 -0
  55. fcloud_sdk-0.1.0/src/fcloud/py.typed +0 -0
  56. fcloud_sdk-0.1.0/src/fcloud/session.py +442 -0
  57. fcloud_sdk-0.1.0/src/fcloud/setup_cmd.py +213 -0
  58. fcloud_sdk-0.1.0/src/fcloud/shell.py +558 -0
  59. fcloud_sdk-0.1.0/src/fcloud/sweeps.py +557 -0
  60. fcloud_sdk-0.1.0/src/fcloud/tunnel.py +251 -0
  61. fcloud_sdk-0.1.0/src/fcloud/types.py +302 -0
  62. fcloud_sdk-0.1.0/src/fcloud/v2_connect.py +928 -0
  63. fcloud_sdk-0.1.0/src/fcloud/version.py +33 -0
  64. fcloud_sdk-0.1.0/src/fcloud/volume_wait.py +131 -0
  65. fcloud_sdk-0.1.0/src/fcloud/volumes.py +204 -0
  66. fcloud_sdk-0.1.0/src/fcloud_sdk.egg-info/PKG-INFO +234 -0
  67. fcloud_sdk-0.1.0/src/fcloud_sdk.egg-info/SOURCES.txt +123 -0
  68. fcloud_sdk-0.1.0/src/fcloud_sdk.egg-info/dependency_links.txt +1 -0
  69. fcloud_sdk-0.1.0/src/fcloud_sdk.egg-info/entry_points.txt +3 -0
  70. fcloud_sdk-0.1.0/src/fcloud_sdk.egg-info/requires.txt +9 -0
  71. fcloud_sdk-0.1.0/src/fcloud_sdk.egg-info/top_level.txt +2 -0
  72. fcloud_sdk-0.1.0/src/foom/__init__.py +36 -0
  73. fcloud_sdk-0.1.0/tests/conftest.py +86 -0
  74. fcloud_sdk-0.1.0/tests/test_cli_args.py +237 -0
  75. fcloud_sdk-0.1.0/tests/test_cli_dispatch.py +131 -0
  76. fcloud_sdk-0.1.0/tests/test_cli_guards.py +60 -0
  77. fcloud_sdk-0.1.0/tests/test_cli_help.py +149 -0
  78. fcloud_sdk-0.1.0/tests/test_client.py +805 -0
  79. fcloud_sdk-0.1.0/tests/test_client_contracts_c.py +289 -0
  80. fcloud_sdk-0.1.0/tests/test_client_host_frames_contract.py +46 -0
  81. fcloud_sdk-0.1.0/tests/test_client_http_contract.py +89 -0
  82. fcloud_sdk-0.1.0/tests/test_client_telemetry.py +150 -0
  83. fcloud_sdk-0.1.0/tests/test_config.py +192 -0
  84. fcloud_sdk-0.1.0/tests/test_default_image.py +260 -0
  85. fcloud_sdk-0.1.0/tests/test_direct_bridge.py +1104 -0
  86. fcloud_sdk-0.1.0/tests/test_direct_fake_host.py +332 -0
  87. fcloud_sdk-0.1.0/tests/test_dotenv_precedence.py +341 -0
  88. fcloud_sdk-0.1.0/tests/test_download_volume_hint.py +59 -0
  89. fcloud_sdk-0.1.0/tests/test_emit_pid.py +44 -0
  90. fcloud_sdk-0.1.0/tests/test_exec_attach_retry.py +160 -0
  91. fcloud_sdk-0.1.0/tests/test_fileset.py +109 -0
  92. fcloud_sdk-0.1.0/tests/test_job.py +247 -0
  93. fcloud_sdk-0.1.0/tests/test_legacy_shim.py +35 -0
  94. fcloud_sdk-0.1.0/tests/test_map_default_image.py +49 -0
  95. fcloud_sdk-0.1.0/tests/test_progress_narration.py +252 -0
  96. fcloud_sdk-0.1.0/tests/test_provider_env_default.py +116 -0
  97. fcloud_sdk-0.1.0/tests/test_queued_reason_render.py +146 -0
  98. fcloud_sdk-0.1.0/tests/test_rate_limit_ride.py +86 -0
  99. fcloud_sdk-0.1.0/tests/test_rebuild_respawn.py +75 -0
  100. fcloud_sdk-0.1.0/tests/test_ride_cap.py +94 -0
  101. fcloud_sdk-0.1.0/tests/test_run_migration.py +237 -0
  102. fcloud_sdk-0.1.0/tests/test_run_volume_collision.py +74 -0
  103. fcloud_sdk-0.1.0/tests/test_run_wait_flags.py +77 -0
  104. fcloud_sdk-0.1.0/tests/test_secret_resolution.py +99 -0
  105. fcloud_sdk-0.1.0/tests/test_session_truth.py +242 -0
  106. fcloud_sdk-0.1.0/tests/test_sessions_live_statuses.py +161 -0
  107. fcloud_sdk-0.1.0/tests/test_sessions_point_lookup.py +74 -0
  108. fcloud_sdk-0.1.0/tests/test_setup_cmd.py +57 -0
  109. fcloud_sdk-0.1.0/tests/test_shell_env.py +15 -0
  110. fcloud_sdk-0.1.0/tests/test_shell_interrupt.py +33 -0
  111. fcloud_sdk-0.1.0/tests/test_shell_volumes.py +147 -0
  112. fcloud_sdk-0.1.0/tests/test_skus.py +174 -0
  113. fcloud_sdk-0.1.0/tests/test_sweep_cost_optin.py +39 -0
  114. fcloud_sdk-0.1.0/tests/test_sweep_lifecycle_ux.py +145 -0
  115. fcloud_sdk-0.1.0/tests/test_sweep_status_view.py +70 -0
  116. fcloud_sdk-0.1.0/tests/test_sweeps_binding.py +133 -0
  117. fcloud_sdk-0.1.0/tests/test_tunnel.py +132 -0
  118. fcloud_sdk-0.1.0/tests/test_types.py +168 -0
  119. fcloud_sdk-0.1.0/tests/test_upload_s3_path.py +197 -0
  120. fcloud_sdk-0.1.0/tests/test_v2_connect.py +543 -0
  121. fcloud_sdk-0.1.0/tests/test_volume_cli_hardening.py +231 -0
  122. fcloud_sdk-0.1.0/tests/test_volume_download_delete.py +197 -0
  123. fcloud_sdk-0.1.0/tests/test_volume_resolution.py +51 -0
  124. fcloud_sdk-0.1.0/tests/test_volume_wait.py +138 -0
  125. fcloud_sdk-0.1.0/tests/test_wait.py +392 -0
@@ -0,0 +1,90 @@
1
+ # Changelog
2
+
3
+ All notable changes to the `fcloud` Python SDK and CLI are recorded here.
4
+
5
+ ## Unreleased
6
+
7
+ - Renamed: the package is `fcloud-sdk`, the import is `fcloud`, the CLI is
8
+ `fcloud`, env vars are `FCLOUD_*`, config lives in `~/.fcloud`, project
9
+ files are `fcloud.json`, new keys are `fcloud_sk_…`, and the client sends
10
+ `X-Fcloud-Client*` headers. Everything old keeps working: `import foom`,
11
+ the `foom` command, `FOOM_*`, `~/.foom`, `foom.json`, `foom_sk_` keys and
12
+ `foom.FoomError`. Map tasks now receive `FCLOUD_TASK_ID` /
13
+ `FCLOUD_WORLD_SIZE` / `FCLOUD_JOB` (the `FOOM_*` names are gone).
14
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
15
+ versions follow [Semantic Versioning](https://semver.org/).
16
+
17
+ ## [Unreleased]
18
+
19
+ ### Added
20
+ - `foom sweep harvest <name> <remote-glob> <local-dir>` — download every
21
+ task's matching outputs in one command. Sessions are resolved from the
22
+ sweep and local paths are task-keyed (`<local-dir>/task-<index>/<path>`,
23
+ or `--flat`), replacing the per-sweep script that parsed status JSON for
24
+ session ids and ran N `foom download` calls. `--all-states` includes
25
+ failed and canceled tasks.
26
+ - `foom sweep status --watch [--interval S]` — the human live view,
27
+ repainted in place until the sweep is terminal. Appends instead of
28
+ repainting when stdout is not a terminal.
29
+ - `foom stop --wait [--timeout SECONDS]` — block until the workspace
30
+ manifest is durable, instead of polling `foom sessions` for `state=cold`.
31
+ `foom map --from <sid>` needs that manifest; the default timeout is 300s
32
+ and the command exits 1 if the wait expires (the stop itself stands).
33
+ - The `foom sweep status --json` document is now a documented, versioned
34
+ contract (`schema_version: 1`) — see `docs/sweep-status-schema.md`.
35
+ Additive changes keep the version; a removal or rename bumps it.
36
+ - Every request now carries `X-Foom-Client` / `X-Foom-Client-Version`, and a
37
+ client below the deployment's supported floor is rejected with HTTP 426 and
38
+ the new `foom.ClientTooOldError`, which names the upgrade command. This
39
+ replaces the previous failure mode for a stale client, an S3
40
+ `SignatureDoesNotMatch` on every >5 MiB upload that read as a credential
41
+ problem.
42
+
43
+ ### Changed
44
+ - `foom upload` now names the files that take the pre-signed cloud-storage
45
+ path (>5 MiB) rather than only the total, and names them again in the error
46
+ when that path fails — so a broken large-file upload is attributable to a
47
+ file, not to the command. `Session.upload()` returns them as `s3_files`
48
+ alongside `inline_files` and `s3_threshold_bytes`.
49
+
50
+ ## [0.1.0] — first public release
51
+
52
+ ### Added
53
+ - `foom` CLI: sessions, exec/run/shell/ssh/tunnel, background processes
54
+ (spawn/wait/logs/kill), file transfer (upload/download/ls/mount), volumes,
55
+ run-to-completion jobs, and `foom map` sweeps.
56
+ - Python SDK: `Client`, `Project`, `Session`, `Job`, `SweepHandle`, `Image`.
57
+ - `foom setup` installs the agent skill (`SKILL.md`) for Cursor, Claude Code
58
+ and Codex.
59
+ - `foom --version` and `foom.__version__`.
60
+ - Directory uploads skip hidden entries, dependency/cache directories and
61
+ symlinked files by default; `--include-hidden` / `--follow-symlinks` (CLI)
62
+ and `include_hidden=` / `follow_symlinks=` (SDK) opt back in.
63
+ - `FOOM_TELEMETRY=0` disables the best-effort CLI crash report.
64
+
65
+ ### Removed
66
+ Relative to the pre-release internal SDK (nothing here was ever on PyPI):
67
+ - Public names `MigrationInfo`, `MigrationStatus`, `SyncProgress`, the
68
+ `FcloudError` and `JobHandle` aliases (`FoomError` / `SweepHandle` remain),
69
+ and the `Session.migrate()` / `Client.watch()` / `Client.list_session_files()`
70
+ / `Client.download_file()` helpers — the operator-initiated migration
71
+ surface is not part of the public client.
72
+ - `Image.add_local_file()`, `Image.add_local_dir()`, `Image.copy()`,
73
+ `Image.workdir()` — use `Session.upload()` / `foom upload` for local files
74
+ and the `workdir=` argument on exec.
75
+ - Legacy `~/.fcloud/token`, `~/.fcloud/url` and `fcloud.json` lookups
76
+ (`~/.foom/*` and `foom.json` are the supported forms). `FCLOUD_API_KEY` /
77
+ `FCLOUD_URL` are still accepted as aliases of `FOOM_API_KEY` / `FOOM_URL`.
78
+ - Internal modules `foom.upload`, `foom.stream`, `foom.jobs`, `foom.client_ext`
79
+ and the `s3_uploader` / `websockets_transport` providers, with the
80
+ `websockets` dependency they pulled in.
81
+ - `DirectClient.run_streaming()` (no callers). `DirectClient.execute()` is
82
+ kept — internal harnesses use it.
83
+
84
+ ### Security
85
+ - Only `FOOM_*` keys from a project `.env` are imported into the process
86
+ environment; other keys stay reachable by name via `--secret KEY`.
87
+ - A plaintext (`ws://`) host address is refused when the API was reached over
88
+ `https://`; a plaintext API URL to a non-local host warns.
89
+ - `foom ssh` quotes its ProxyCommand and validates the session id before using
90
+ it in filesystem paths.
@@ -0,0 +1,37 @@
1
+ # Contributing
2
+
3
+ Thanks for your interest in `fcloud`.
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ cd packages/fcloud-sdk
9
+ python3 -m venv .venv && source .venv/bin/activate
10
+ pip install -e ".[dev]"
11
+ ```
12
+
13
+ ## Before you open a pull request
14
+
15
+ ```bash
16
+ ruff check src tests # lint (rule set in pyproject.toml)
17
+ mypy # type-check src/fcloud (config in pyproject.toml)
18
+ pytest # ~640 hermetic tests, no network or credentials needed
19
+ ```
20
+
21
+ - Keep changes focused; one topic per PR.
22
+ - New behaviour comes with a test — the tests are the spec.
23
+ - Comments explain *why*, not *what*. Please don't reference internal ticket
24
+ numbers, incidents or environments in code comments.
25
+ - Public functions and classes have docstrings.
26
+ - Line length is 100.
27
+
28
+ ## Reporting bugs
29
+
30
+ Open a GitHub issue with the `fcloud --version` output, the command or code you
31
+ ran, and what you expected. For anything security-related, see
32
+ [SECURITY.md](SECURITY.md) instead.
33
+
34
+ ## License
35
+
36
+ By contributing you agree that your contributions are licensed under the
37
+ Apache License 2.0 (see [LICENSE](LICENSE)).
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ include README.md
2
+ include LICENSE
3
+ include NOTICE
4
+ include CHANGELOG.md
5
+ include CONTRIBUTING.md
6
+ include SKILL.md
7
+ graft tests
8
+ global-exclude __pycache__ *.py[cod] .DS_Store
@@ -0,0 +1,4 @@
1
+ fcloud
2
+ Copyright 2026 fcloud
3
+
4
+ This product includes software developed for the fcloud compute platform.
@@ -0,0 +1,234 @@
1
+ Metadata-Version: 2.4
2
+ Name: fcloud-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK and CLI for the fcloud GPU compute platform
5
+ Author: fcloud
6
+ License-Expression: Apache-2.0
7
+ Keywords: gpu,cloud,compute,ml,training,cli
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: System :: Distributed Computing
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ License-File: NOTICE
25
+ Requires-Dist: aiohttp>=3.9
26
+ Requires-Dist: requests>=2.31
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=8.0; extra == "dev"
29
+ Requires-Dist: pytest-xdist>=3.5; extra == "dev"
30
+ Requires-Dist: ruff>=0.8; extra == "dev"
31
+ Requires-Dist: mypy>=1.10; extra == "dev"
32
+ Requires-Dist: types-requests; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # fcloud
36
+
37
+ Python SDK and CLI for the fcloud GPU compute platform: provision GPU or CPU
38
+ hosts, run commands and scripts on them, keep a persistent workspace between
39
+ runs, move files in and out, and drive long-running or batch jobs — from a
40
+ terminal, from Python, or from an AI coding agent.
41
+
42
+ Requires Python 3.10+.
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install fcloud-sdk
48
+ ```
49
+
50
+ Or from a checkout of this repository:
51
+
52
+ ```bash
53
+ cd packages/fcloud-sdk
54
+ pip install -e . # editable: `git pull` picks up SDK updates
55
+ ```
56
+
57
+ ## Setup
58
+
59
+ You need a fcloud API key. Save it once (it is written to `~/.fcloud/token` with
60
+ mode 0600 and never printed):
61
+
62
+ ```bash
63
+ fcloud setup # prompts for the key; optionally installs the agent skill
64
+ fcloud health # verify connectivity
65
+ ```
66
+
67
+ `fcloud setup --agents all` also installs the fcloud skill file for supported
68
+ coding agents (Cursor, Claude Code, Codex) so an agent can drive fcloud for you.
69
+ Use `--agents none` to skip that.
70
+
71
+ ## Quick start
72
+
73
+ ```bash
74
+ # Run a one-off command on a GPU
75
+ fcloud exec --sku gpu_1x_l4 nvidia-smi -L
76
+
77
+ # Upload a script and run it
78
+ fcloud run train.py --sku gpu_1x_l4
79
+
80
+ # Upload a project directory, run one script in it, pass arguments through
81
+ fcloud run . --script train.py --sku gpu_1x_l4 -- --epochs 50
82
+
83
+ # See what hardware is available
84
+ fcloud skus
85
+ ```
86
+
87
+ `fcloud run <dir>` uploads the whole directory. Keep secrets, virtualenvs and
88
+ large data out of the tree you point it at.
89
+
90
+ ## How the pieces fit
91
+
92
+ - **session** — a persistent `/workspace` filesystem, not a held GPU. It costs
93
+ nothing until used; `exec`/`run`/`shell`/`upload` bring it online with its
94
+ files intact, and `fcloud stop` halts spend but keeps the files. Address an
95
+ existing one with `--on <SID>`.
96
+ - **volume** — a named folder you mount into a session with `--volume`; this is
97
+ how data moves between sessions. Writes commit back as a new version when the
98
+ session detaches or closes.
99
+ - **process** — work running inside a session. `exec`/`run` wait in the
100
+ foreground; `spawn` returns a process id you then `wait`/`logs`/`kill`.
101
+ - **job** — a run-to-completion session with no saved filesystem; its durable
102
+ outputs are its volumes and its logs.
103
+ - **sweep** — `fcloud map` fans one command out over many argument bindings as a
104
+ durable batch you inspect with `fcloud sweep`.
105
+
106
+ ## CLI
107
+
108
+ `fcloud help` prints the full grouped list; `fcloud help <command>` prints details.
109
+
110
+ ```
111
+ Find hardware
112
+ fcloud skus List SKUs and prices
113
+ fcloud health Check API connectivity
114
+
115
+ Run code
116
+ fcloud exec [--sku SKU] [--on SID] <cmd...> Run a command on a host
117
+ fcloud run <file|dir> [--sku SKU] [--on SID] Upload and run a script
118
+ fcloud shell [--sku SKU] [--on SID] [--volume NAME] Interactive shell
119
+ fcloud ssh <SID> SSH into a session
120
+ fcloud tunnel <SID> [--port PORT] SSH ProxyCommand tunnel
121
+
122
+ Background processes (inside a session)
123
+ fcloud spawn --on SID <cmd...> Start a background process
124
+ fcloud wait <SID> <PID> [--timeout DUR] Wait for it; exit with its code
125
+ fcloud logs <SID> [PID] [--follow] Show process output
126
+ fcloud kill <SID> <PID> Kill it
127
+
128
+ Sessions (the persistent filesystem)
129
+ fcloud create [--sku SKU] [--min-disk-gb N] Create a session ($0 until used)
130
+ fcloud sessions [SID] [--all] [--limit N] List sessions
131
+ fcloud history <SID> [--limit N] Session event history
132
+ fcloud stop <SID> Stop now (files kept)
133
+
134
+ Files
135
+ fcloud upload [--on SID] <local> [remote] Upload files
136
+ fcloud download [--on SID] <remote> [local] Download a file
137
+ fcloud ls <SID> [path] List a session's files
138
+ fcloud mount <SID> <mountpoint> Mount session files read-only (needs rclone)
139
+
140
+ Volumes (data that outlives a session)
141
+ fcloud volume <create|list|files|download|cat|import|delete> ...
142
+
143
+ Batch
144
+ fcloud job <run|ls|logs|wait|kill> ... Run-to-completion jobs
145
+ fcloud map [--sku SKU] -- <cmd {}> ::: v1,v2... Fan a command out over bindings
146
+ fcloud sweeps / fcloud sweep <status|logs|retry|cancel|wait> <name>
147
+
148
+ Setup
149
+ fcloud setup [--token KEY] [--agents all|cursor|claude|codex|none]
150
+ fcloud set_token <api-key>
151
+ fcloud --version
152
+ ```
153
+
154
+ All commands accept `--json` for machine-readable output.
155
+
156
+ `fcloud exec` returns bounded stdout by default. If `--json` reports
157
+ `stdout_truncated: true`, fetch the full log instead of rerunning:
158
+
159
+ ```bash
160
+ fcloud logs <session-id> <process-id> --output all
161
+ fcloud logs <session-id> <process-id> --stream stderr --output all
162
+ ```
163
+
164
+ ## Python SDK
165
+
166
+ ```python
167
+ import fcloud
168
+
169
+ client = fcloud.Client()
170
+
171
+ image = fcloud.Image.debian_slim().pip_install(["torch", "numpy"])
172
+ project = client.project("my-run", image=image)
173
+
174
+ with project.session(sku="gpu_1x_l4") as s:
175
+ s.upload("./data", "data/")
176
+ result = s.run(["python3", "/workspace/data/train.py"])
177
+ print(result.stdout)
178
+ if result.stdout_truncated:
179
+ print(s.logs(result.process_id, output_range="all").output)
180
+ weights = s.download("model.pt")
181
+ ```
182
+
183
+ Errors raise `fcloud.FcloudError` (or a subclass such as `PaymentOverdueError`).
184
+
185
+ ## Configuration
186
+
187
+ API key, in order of precedence:
188
+
189
+ 1. `api_key=` passed to `Client()`
190
+ 2. `FCLOUD_API_KEY` exported in the shell
191
+ 3. Saved token in `~/.fcloud/token` (from `fcloud setup` / `fcloud set_token`)
192
+ 4. `FCLOUD_API_KEY` in the nearest `.env` file (searched upward from the cwd)
193
+
194
+ API URL, in order of precedence:
195
+
196
+ 1. `url=` passed to `Client()`
197
+ 2. `FCLOUD_URL` exported in the shell
198
+ 3. Saved URL in `~/.fcloud/url`
199
+ 4. `FCLOUD_URL` in the nearest `.env` — only honoured when that same `.env` is
200
+ also supplying the API key, so a checked-out repo can't redirect a saved
201
+ token elsewhere
202
+ 5. `https://fcloud-dispatcher.fly.dev`
203
+
204
+ Other environment switches:
205
+
206
+ | Variable | Effect |
207
+ |---|---|
208
+ | `FCLOUD_QUIET=1` | Suppress "still waiting" progress lines while a host is provisioned |
209
+ | `FCLOUD_QUEUE_TIMEOUT=<seconds>` | How long to wait for capacity before giving up (default 1200) |
210
+ | `FCLOUD_MIGRATE_RESTART=never` | Don't automatically re-run a command after a host rebuild (default `auto`) |
211
+ | `FCLOUD_INSECURE_HTTP=1` | Allow a plaintext `http://` API URL to a non-loopback host (refused by default — the API key would travel unencrypted). Loopback URLs never need this |
212
+ | `FCLOUD_TELEMETRY=0` | Disable all client telemetry. When enabled (the default), the client reports failures the backend cannot otherwise see — an uncaught CLI error, a queue-wait timeout, exhausted connect retries — as a fixed-allowlist payload (session id, event type, error class, truncated message, SKU/timing fields); never file contents, paths from OS errors, or credentials |
213
+
214
+ A `fcloud.json` at the project root can set defaults (image build steps, default
215
+ volumes). Note that fcloud will run the build steps it finds there, so treat a
216
+ cloned repo's `fcloud.json` the way you would its Dockerfile.
217
+
218
+ ## Agent skill
219
+
220
+ `fcloud setup --agents all` installs `SKILL.md` for supported coding agents. It
221
+ is the long-form, agent-oriented guide: workflow patterns, monitoring loops,
222
+ and anti-patterns.
223
+
224
+ ## Development
225
+
226
+ ```bash
227
+ pip install -e ".[dev]"
228
+ pytest
229
+ ruff check src tests
230
+ ```
231
+
232
+ ## License
233
+
234
+ Apache License 2.0 — see [LICENSE](LICENSE).