fcloud-sdk 0.1.0__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.
- fcloud/SKILL.md +1185 -0
- fcloud/__init__.py +85 -0
- fcloud/__main__.py +150 -0
- fcloud/_direct_bridge.py +1645 -0
- fcloud/_legacy_env.py +14 -0
- fcloud/cli/__init__.py +23 -0
- fcloud/cli/attach.py +180 -0
- fcloud/cli/common.py +382 -0
- fcloud/cli/console.py +227 -0
- fcloud/cli/context.py +161 -0
- fcloud/cli/exec_cmd.py +201 -0
- fcloud/cli/files.py +280 -0
- fcloud/cli/hardware.py +83 -0
- fcloud/cli/help.py +150 -0
- fcloud/cli/interactive.py +104 -0
- fcloud/cli/job.py +300 -0
- fcloud/cli/main.py +140 -0
- fcloud/cli/migration.py +276 -0
- fcloud/cli/mount.py +150 -0
- fcloud/cli/output.py +17 -0
- fcloud/cli/processes.py +360 -0
- fcloud/cli/registry.py +28 -0
- fcloud/cli/run.py +318 -0
- fcloud/cli/sessions.py +592 -0
- fcloud/cli/setup.py +44 -0
- fcloud/cli/ssh.py +255 -0
- fcloud/cli/sweep.py +578 -0
- fcloud/cli/sweep_harvest.py +187 -0
- fcloud/cli/sweep_watch.py +104 -0
- fcloud/cli/volume.py +317 -0
- fcloud/cli/wait.py +314 -0
- fcloud/cli_args.py +348 -0
- fcloud/client.py +632 -0
- fcloud/client_projects.py +52 -0
- fcloud/client_sessions.py +111 -0
- fcloud/client_volumes.py +80 -0
- fcloud/config.py +404 -0
- fcloud/direct.py +535 -0
- fcloud/errors.py +102 -0
- fcloud/fileset.py +155 -0
- fcloud/image.py +483 -0
- fcloud/job.py +249 -0
- fcloud/providers/__init__.py +5 -0
- fcloud/providers/requests_http.py +59 -0
- fcloud/py.typed +0 -0
- fcloud/session.py +442 -0
- fcloud/setup_cmd.py +213 -0
- fcloud/shell.py +558 -0
- fcloud/sweeps.py +557 -0
- fcloud/tunnel.py +251 -0
- fcloud/types.py +302 -0
- fcloud/v2_connect.py +928 -0
- fcloud/version.py +33 -0
- fcloud/volume_wait.py +131 -0
- fcloud/volumes.py +204 -0
- fcloud_sdk-0.1.0.dist-info/METADATA +234 -0
- fcloud_sdk-0.1.0.dist-info/RECORD +63 -0
- fcloud_sdk-0.1.0.dist-info/WHEEL +5 -0
- fcloud_sdk-0.1.0.dist-info/entry_points.txt +3 -0
- fcloud_sdk-0.1.0.dist-info/licenses/LICENSE +202 -0
- fcloud_sdk-0.1.0.dist-info/licenses/NOTICE +4 -0
- fcloud_sdk-0.1.0.dist-info/top_level.txt +2 -0
- foom/__init__.py +36 -0
fcloud/__init__.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""fcloud Python SDK — launch code on GPU and CPU hosts in seconds.
|
|
2
|
+
|
|
3
|
+
Setup (one time, from terminal):
|
|
4
|
+
$ pip install fcloud-sdk
|
|
5
|
+
$ fcloud set_token fcloud_sk_...
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
from fcloud import Client, Image
|
|
9
|
+
|
|
10
|
+
client = Client() # uses saved token + default URL
|
|
11
|
+
|
|
12
|
+
image = Image.debian_slim().pip_install(["torch"])
|
|
13
|
+
project = client.project("my-project", image=image)
|
|
14
|
+
with project.session(sku="gpu_1x_a100") as s:
|
|
15
|
+
s.run(["python", "train.py"])
|
|
16
|
+
proc = s.spawn(["python", "eval.py"])
|
|
17
|
+
proc.wait()
|
|
18
|
+
print(s.run(["cat", "results.json"]).stdout)
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import fcloud._legacy_env # noqa: F401 — must run before any env read below
|
|
22
|
+
from fcloud.client import (
|
|
23
|
+
Client,
|
|
24
|
+
FcloudError,
|
|
25
|
+
PaymentOverdueError,
|
|
26
|
+
SessionNotFoundError,
|
|
27
|
+
)
|
|
28
|
+
from fcloud.config import get_token, set_token
|
|
29
|
+
from fcloud.errors import (
|
|
30
|
+
ClientTooOldError,
|
|
31
|
+
FcloudRuntimeError,
|
|
32
|
+
FoomError,
|
|
33
|
+
RateLimitedError,
|
|
34
|
+
VolumeHydrationError,
|
|
35
|
+
)
|
|
36
|
+
from fcloud.image import Image
|
|
37
|
+
from fcloud.job import Job # noqa: F401
|
|
38
|
+
from fcloud.session import Project, Session
|
|
39
|
+
from fcloud.sweeps import MapSpecError, SweepHandle # noqa: F401
|
|
40
|
+
from fcloud.types import (
|
|
41
|
+
ExecResult,
|
|
42
|
+
Process,
|
|
43
|
+
ProcessLog,
|
|
44
|
+
ProcessStatus,
|
|
45
|
+
SessionInfo,
|
|
46
|
+
)
|
|
47
|
+
from fcloud.version import VERSION as __version__
|
|
48
|
+
from fcloud.volumes import (
|
|
49
|
+
VolumeConflictError,
|
|
50
|
+
VolumeIsDirectoryError,
|
|
51
|
+
VolumeNotFoundError,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
__all__ = [
|
|
55
|
+
"__version__",
|
|
56
|
+
# Entry points
|
|
57
|
+
"Client",
|
|
58
|
+
"FoomError",
|
|
59
|
+
"Image",
|
|
60
|
+
"set_token",
|
|
61
|
+
"get_token",
|
|
62
|
+
# Handles
|
|
63
|
+
"Project",
|
|
64
|
+
"Session",
|
|
65
|
+
"Job",
|
|
66
|
+
"SweepHandle",
|
|
67
|
+
# Result / record types
|
|
68
|
+
"ExecResult",
|
|
69
|
+
"Process",
|
|
70
|
+
"ProcessLog",
|
|
71
|
+
"ProcessStatus",
|
|
72
|
+
"SessionInfo",
|
|
73
|
+
# Errors
|
|
74
|
+
"ClientTooOldError",
|
|
75
|
+
"FcloudError",
|
|
76
|
+
"FcloudRuntimeError",
|
|
77
|
+
"MapSpecError",
|
|
78
|
+
"PaymentOverdueError",
|
|
79
|
+
"RateLimitedError",
|
|
80
|
+
"SessionNotFoundError",
|
|
81
|
+
"VolumeConflictError",
|
|
82
|
+
"VolumeHydrationError",
|
|
83
|
+
"VolumeIsDirectoryError",
|
|
84
|
+
"VolumeNotFoundError",
|
|
85
|
+
]
|
fcloud/__main__.py
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""fcloud CLI — GPU compute from the command line.
|
|
2
|
+
|
|
3
|
+
Compatibility shim. The CLI lives in the `fcloud.cli` package (one module per
|
|
4
|
+
`fcloud help` group); importing it registers every command. This module keeps
|
|
5
|
+
the historical `fcloud.__main__` import surface — the console script, the
|
|
6
|
+
command registry, every `cmd_*` handler and the helpers tests reach for —
|
|
7
|
+
and runs `main()` under `python -m fcloud`.
|
|
8
|
+
|
|
9
|
+
New code should import from the owning `fcloud.cli.*` module directly. Note
|
|
10
|
+
that `_JSON_OUTPUT` is NOT re-exported: it is a mutable flag, and a copy here
|
|
11
|
+
would silently diverge from the one the commands read. Patch and read
|
|
12
|
+
`fcloud.cli.output._JSON_OUTPUT` instead (see `__getattr__` below).
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from fcloud.cli.attach import ( # noqa: F401
|
|
16
|
+
_ATTACH_RETRY_DELAYS_S,
|
|
17
|
+
_ENDED_SESSION_STATES,
|
|
18
|
+
_RESUME_BUDGET_S,
|
|
19
|
+
_TERMINAL_SESSION_STATES,
|
|
20
|
+
_attach_with_retry,
|
|
21
|
+
_authoritative_session_status,
|
|
22
|
+
_exit_session_unreachable,
|
|
23
|
+
_get_session_handle,
|
|
24
|
+
)
|
|
25
|
+
from fcloud.cli.common import ( # noqa: F401
|
|
26
|
+
_consume_positional_session,
|
|
27
|
+
_extract_flag,
|
|
28
|
+
_extract_secrets,
|
|
29
|
+
_extract_upload_options,
|
|
30
|
+
_parse_duration_seconds,
|
|
31
|
+
_parse_keep_warm,
|
|
32
|
+
_parse_min_disk,
|
|
33
|
+
_parse_volume_mount,
|
|
34
|
+
_print_upload_summary,
|
|
35
|
+
_resolve_session_and_rest,
|
|
36
|
+
_shape_exec_command,
|
|
37
|
+
_split_trailing_args,
|
|
38
|
+
)
|
|
39
|
+
from fcloud.cli.console import ( # noqa: F401
|
|
40
|
+
_exec_result,
|
|
41
|
+
_live_console_sink,
|
|
42
|
+
_maybe_keepalive,
|
|
43
|
+
_pid_emitter,
|
|
44
|
+
)
|
|
45
|
+
from fcloud.cli.context import ( # noqa: F401
|
|
46
|
+
_api_base,
|
|
47
|
+
_api_key,
|
|
48
|
+
_resolve_min_disk_gb,
|
|
49
|
+
_resolve_project,
|
|
50
|
+
_resolve_volume_mounts,
|
|
51
|
+
)
|
|
52
|
+
from fcloud.cli.exec_cmd import _parse_exec_args, cmd_exec # noqa: F401
|
|
53
|
+
from fcloud.cli.files import ( # noqa: F401
|
|
54
|
+
_download_file,
|
|
55
|
+
_volume_path_hint,
|
|
56
|
+
cmd_download,
|
|
57
|
+
cmd_ls,
|
|
58
|
+
cmd_upload,
|
|
59
|
+
)
|
|
60
|
+
from fcloud.cli.hardware import cmd_health, cmd_skus # noqa: F401
|
|
61
|
+
from fcloud.cli.help import ( # noqa: F401
|
|
62
|
+
_HELP_GROUPS,
|
|
63
|
+
print_command_help,
|
|
64
|
+
print_help,
|
|
65
|
+
)
|
|
66
|
+
from fcloud.cli.interactive import _parse_shell_args, cmd_shell # noqa: F401
|
|
67
|
+
from fcloud.cli.job import cmd_job # noqa: F401
|
|
68
|
+
from fcloud.cli.main import _report_cli_error, _strip_precommand_json, main # noqa: F401
|
|
69
|
+
from fcloud.cli.migration import ( # noqa: F401
|
|
70
|
+
_drain_resumed_process,
|
|
71
|
+
_follow_reconnect,
|
|
72
|
+
_maybe_respawn_after_rebuild,
|
|
73
|
+
_migration_ui,
|
|
74
|
+
_ride_migration,
|
|
75
|
+
_tail_follow_delta,
|
|
76
|
+
)
|
|
77
|
+
from fcloud.cli.mount import cmd_mount # noqa: F401
|
|
78
|
+
from fcloud.cli.output import _out # noqa: F401
|
|
79
|
+
from fcloud.cli.processes import ( # noqa: F401
|
|
80
|
+
_emit_spawned,
|
|
81
|
+
_logs_follow,
|
|
82
|
+
_parse_logs_args,
|
|
83
|
+
_print_log_result,
|
|
84
|
+
cmd_kill,
|
|
85
|
+
cmd_logs,
|
|
86
|
+
cmd_spawn,
|
|
87
|
+
)
|
|
88
|
+
from fcloud.cli.registry import ( # noqa: F401
|
|
89
|
+
COMMANDS,
|
|
90
|
+
HIDDEN_COMMANDS,
|
|
91
|
+
LONG_HELP,
|
|
92
|
+
cmd,
|
|
93
|
+
)
|
|
94
|
+
from fcloud.cli.run import ( # noqa: F401
|
|
95
|
+
_infer_runner,
|
|
96
|
+
_parse_run_args,
|
|
97
|
+
_spawn_detached_run,
|
|
98
|
+
cmd_run,
|
|
99
|
+
)
|
|
100
|
+
from fcloud.cli.sessions import ( # noqa: F401
|
|
101
|
+
_parse_create_args,
|
|
102
|
+
_session_state,
|
|
103
|
+
cmd_create,
|
|
104
|
+
cmd_history,
|
|
105
|
+
cmd_sessions,
|
|
106
|
+
cmd_stop,
|
|
107
|
+
)
|
|
108
|
+
from fcloud.cli.setup import cmd_set_token, cmd_setup # noqa: F401
|
|
109
|
+
from fcloud.cli.ssh import ( # noqa: F401
|
|
110
|
+
_fcloud_command_prefix,
|
|
111
|
+
_validated_session_id,
|
|
112
|
+
cmd_ssh,
|
|
113
|
+
cmd_tunnel,
|
|
114
|
+
)
|
|
115
|
+
from fcloud.cli.sweep import ( # noqa: F401
|
|
116
|
+
_print_sweep_status,
|
|
117
|
+
cmd_map,
|
|
118
|
+
cmd_sweep,
|
|
119
|
+
cmd_sweeps,
|
|
120
|
+
)
|
|
121
|
+
from fcloud.cli.volume import ( # noqa: F401
|
|
122
|
+
_is_within,
|
|
123
|
+
_volume_cat,
|
|
124
|
+
_volume_create,
|
|
125
|
+
_volume_delete,
|
|
126
|
+
_volume_download,
|
|
127
|
+
_volume_files,
|
|
128
|
+
_volume_import,
|
|
129
|
+
_volume_list,
|
|
130
|
+
cmd_volume,
|
|
131
|
+
)
|
|
132
|
+
from fcloud.cli.wait import ( # noqa: F401
|
|
133
|
+
_emit_wait_result,
|
|
134
|
+
_parse_wait_args,
|
|
135
|
+
_wait_for_process,
|
|
136
|
+
cmd_wait,
|
|
137
|
+
)
|
|
138
|
+
from fcloud.cli_args import SPECS # noqa: F401
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def __getattr__(name: str):
|
|
142
|
+
if name == "_JSON_OUTPUT":
|
|
143
|
+
raise AttributeError(
|
|
144
|
+
"fcloud.__main__._JSON_OUTPUT moved: read/patch "
|
|
145
|
+
"fcloud.cli.output._JSON_OUTPUT (the binding every command uses)")
|
|
146
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
if __name__ == "__main__":
|
|
150
|
+
main()
|