raylings 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.
- raylings-0.1.0/.gitignore +52 -0
- raylings-0.1.0/LICENSE +190 -0
- raylings-0.1.0/PKG-INFO +159 -0
- raylings-0.1.0/README.md +113 -0
- raylings-0.1.0/exercises/01_basics/basics01.py +48 -0
- raylings-0.1.0/exercises/01_basics/basics02.py +49 -0
- raylings-0.1.0/exercises/01_basics/basics03.py +86 -0
- raylings-0.1.0/exercises/01_basics/basics04.py +84 -0
- raylings-0.1.0/exercises/01_basics/basics05.py +80 -0
- raylings-0.1.0/exercises/01_basics/basics06.py +63 -0
- raylings-0.1.0/exercises/02_actors/actors01.py +75 -0
- raylings-0.1.0/exercises/02_actors/actors02.py +74 -0
- raylings-0.1.0/exercises/02_actors/actors03.py +96 -0
- raylings-0.1.0/exercises/02_actors/actors04.py +74 -0
- raylings-0.1.0/exercises/02_actors/actors05.py +75 -0
- raylings-0.1.0/exercises/02_actors/actors06.py +67 -0
- raylings-0.1.0/exercises/02_actors/actors07.py +63 -0
- raylings-0.1.0/exercises/03_object_store/object_store01.py +68 -0
- raylings-0.1.0/exercises/03_object_store/object_store02.py +66 -0
- raylings-0.1.0/exercises/03_object_store/object_store03.py +73 -0
- raylings-0.1.0/exercises/03_object_store/object_store04.py +66 -0
- raylings-0.1.0/exercises/03_object_store/object_store05.py +77 -0
- raylings-0.1.0/exercises/03_object_store/object_store06.py +80 -0
- raylings-0.1.0/exercises/04_scheduling_resources/scheduling01.py +67 -0
- raylings-0.1.0/exercises/04_scheduling_resources/scheduling02.py +59 -0
- raylings-0.1.0/exercises/04_scheduling_resources/scheduling03.py +74 -0
- raylings-0.1.0/exercises/04_scheduling_resources/scheduling04.py +67 -0
- raylings-0.1.0/exercises/04_scheduling_resources/scheduling05.py +54 -0
- raylings-0.1.0/exercises/04_scheduling_resources/scheduling06.py +58 -0
- raylings-0.1.0/exercises/05_fault_tolerance/fault01.py +70 -0
- raylings-0.1.0/exercises/05_fault_tolerance/fault02.py +82 -0
- raylings-0.1.0/exercises/05_fault_tolerance/fault03.py +61 -0
- raylings-0.1.0/exercises/05_fault_tolerance/fault04.py +114 -0
- raylings-0.1.0/exercises/06_cluster_architecture/cluster01.py +63 -0
- raylings-0.1.0/exercises/06_cluster_architecture/cluster02.py +73 -0
- raylings-0.1.0/exercises/06_cluster_architecture/cluster03.py +64 -0
- raylings-0.1.0/exercises/06_cluster_architecture/cluster04.py +67 -0
- raylings-0.1.0/exercises/07_patterns_and_antipatterns/antipattern01.py +70 -0
- raylings-0.1.0/exercises/07_patterns_and_antipatterns/antipattern02.py +64 -0
- raylings-0.1.0/exercises/07_patterns_and_antipatterns/antipattern03.py +65 -0
- raylings-0.1.0/exercises/07_patterns_and_antipatterns/antipattern04.py +87 -0
- raylings-0.1.0/exercises/08_ray_data/data01.py +47 -0
- raylings-0.1.0/exercises/08_ray_data/data02.py +63 -0
- raylings-0.1.0/exercises/08_ray_data/data03.py +79 -0
- raylings-0.1.0/exercises/08_ray_data/data04.py +51 -0
- raylings-0.1.0/exercises/08_ray_data/data05.py +54 -0
- raylings-0.1.0/exercises/09_ml_from_scratch/ml_scratch01.py +88 -0
- raylings-0.1.0/exercises/09_ml_from_scratch/ml_scratch02.py +79 -0
- raylings-0.1.0/exercises/09_ml_from_scratch/ml_scratch03.py +87 -0
- raylings-0.1.0/exercises/09_ml_from_scratch/ml_scratch04.py +85 -0
- raylings-0.1.0/exercises/10_ray_train_and_tune/train01.py +51 -0
- raylings-0.1.0/exercises/10_ray_train_and_tune/train02.py +49 -0
- raylings-0.1.0/exercises/10_ray_train_and_tune/train03.py +47 -0
- raylings-0.1.0/exercises/10_ray_train_and_tune/train04.py +55 -0
- raylings-0.1.0/exercises/11_ray_tune/tune01.py +59 -0
- raylings-0.1.0/exercises/11_ray_tune/tune02.py +51 -0
- raylings-0.1.0/exercises/11_ray_tune/tune03.py +52 -0
- raylings-0.1.0/exercises/12_ray_serve/serve01.py +51 -0
- raylings-0.1.0/exercises/12_ray_serve/serve02.py +50 -0
- raylings-0.1.0/exercises/12_ray_serve/serve03.py +69 -0
- raylings-0.1.0/exercises/12_ray_serve/serve04.py +53 -0
- raylings-0.1.0/exercises/12_ray_serve/serve05.py +56 -0
- raylings-0.1.0/exercises/13_observability_and_debugging/perf01.py +63 -0
- raylings-0.1.0/exercises/13_observability_and_debugging/perf02.py +47 -0
- raylings-0.1.0/exercises/13_observability_and_debugging/perf03.py +55 -0
- raylings-0.1.0/exercises/14_kuberay/kuberay01.py +59 -0
- raylings-0.1.0/exercises/14_kuberay/kuberay02.py +45 -0
- raylings-0.1.0/exercises/14_kuberay/kuberay03.py +51 -0
- raylings-0.1.0/exercises/14_kuberay/kuberay04.py +69 -0
- raylings-0.1.0/exercises/14_kuberay/kuberay05.py +55 -0
- raylings-0.1.0/pyproject.toml +106 -0
- raylings-0.1.0/solutions/01_basics/basics01.py +26 -0
- raylings-0.1.0/solutions/01_basics/basics02.py +28 -0
- raylings-0.1.0/solutions/01_basics/basics03.py +56 -0
- raylings-0.1.0/solutions/01_basics/basics04.py +51 -0
- raylings-0.1.0/solutions/01_basics/basics05.py +55 -0
- raylings-0.1.0/solutions/01_basics/basics06.py +30 -0
- raylings-0.1.0/solutions/02_actors/actors01.py +41 -0
- raylings-0.1.0/solutions/02_actors/actors02.py +56 -0
- raylings-0.1.0/solutions/02_actors/actors03.py +57 -0
- raylings-0.1.0/solutions/02_actors/actors04.py +45 -0
- raylings-0.1.0/solutions/02_actors/actors05.py +50 -0
- raylings-0.1.0/solutions/02_actors/actors06.py +43 -0
- raylings-0.1.0/solutions/02_actors/actors07.py +32 -0
- raylings-0.1.0/solutions/03_object_store/object_store01.py +40 -0
- raylings-0.1.0/solutions/03_object_store/object_store02.py +35 -0
- raylings-0.1.0/solutions/03_object_store/object_store03.py +46 -0
- raylings-0.1.0/solutions/03_object_store/object_store04.py +40 -0
- raylings-0.1.0/solutions/03_object_store/object_store05.py +40 -0
- raylings-0.1.0/solutions/03_object_store/object_store06.py +54 -0
- raylings-0.1.0/solutions/04_scheduling_resources/scheduling01.py +36 -0
- raylings-0.1.0/solutions/04_scheduling_resources/scheduling02.py +33 -0
- raylings-0.1.0/solutions/04_scheduling_resources/scheduling03.py +38 -0
- raylings-0.1.0/solutions/04_scheduling_resources/scheduling04.py +45 -0
- raylings-0.1.0/solutions/04_scheduling_resources/scheduling05.py +34 -0
- raylings-0.1.0/solutions/04_scheduling_resources/scheduling06.py +32 -0
- raylings-0.1.0/solutions/05_fault_tolerance/fault01.py +45 -0
- raylings-0.1.0/solutions/05_fault_tolerance/fault02.py +50 -0
- raylings-0.1.0/solutions/05_fault_tolerance/fault03.py +34 -0
- raylings-0.1.0/solutions/05_fault_tolerance/fault04.py +73 -0
- raylings-0.1.0/solutions/06_cluster_architecture/cluster01.py +37 -0
- raylings-0.1.0/solutions/06_cluster_architecture/cluster02.py +37 -0
- raylings-0.1.0/solutions/06_cluster_architecture/cluster03.py +38 -0
- raylings-0.1.0/solutions/06_cluster_architecture/cluster04.py +40 -0
- raylings-0.1.0/solutions/07_patterns_and_antipatterns/antipattern01.py +33 -0
- raylings-0.1.0/solutions/07_patterns_and_antipatterns/antipattern02.py +33 -0
- raylings-0.1.0/solutions/07_patterns_and_antipatterns/antipattern03.py +34 -0
- raylings-0.1.0/solutions/07_patterns_and_antipatterns/antipattern04.py +47 -0
- raylings-0.1.0/solutions/08_ray_data/data01.py +28 -0
- raylings-0.1.0/solutions/08_ray_data/data02.py +32 -0
- raylings-0.1.0/solutions/08_ray_data/data03.py +42 -0
- raylings-0.1.0/solutions/08_ray_data/data04.py +27 -0
- raylings-0.1.0/solutions/08_ray_data/data05.py +29 -0
- raylings-0.1.0/solutions/09_ml_from_scratch/ml_scratch01.py +49 -0
- raylings-0.1.0/solutions/09_ml_from_scratch/ml_scratch02.py +42 -0
- raylings-0.1.0/solutions/09_ml_from_scratch/ml_scratch03.py +90 -0
- raylings-0.1.0/solutions/09_ml_from_scratch/ml_scratch04.py +60 -0
- raylings-0.1.0/solutions/10_ray_train_and_tune/train01.py +56 -0
- raylings-0.1.0/solutions/10_ray_train_and_tune/train02.py +49 -0
- raylings-0.1.0/solutions/10_ray_train_and_tune/train03.py +59 -0
- raylings-0.1.0/solutions/10_ray_train_and_tune/train04.py +63 -0
- raylings-0.1.0/solutions/11_ray_tune/tune01.py +40 -0
- raylings-0.1.0/solutions/11_ray_tune/tune02.py +42 -0
- raylings-0.1.0/solutions/11_ray_tune/tune03.py +50 -0
- raylings-0.1.0/solutions/12_ray_serve/serve01.py +34 -0
- raylings-0.1.0/solutions/12_ray_serve/serve02.py +38 -0
- raylings-0.1.0/solutions/12_ray_serve/serve03.py +53 -0
- raylings-0.1.0/solutions/12_ray_serve/serve04.py +40 -0
- raylings-0.1.0/solutions/12_ray_serve/serve05.py +43 -0
- raylings-0.1.0/solutions/13_observability_and_debugging/perf01.py +50 -0
- raylings-0.1.0/solutions/13_observability_and_debugging/perf02.py +39 -0
- raylings-0.1.0/solutions/13_observability_and_debugging/perf03.py +44 -0
- raylings-0.1.0/solutions/14_kuberay/kuberay01.py +89 -0
- raylings-0.1.0/solutions/14_kuberay/kuberay02.py +64 -0
- raylings-0.1.0/solutions/14_kuberay/kuberay03.py +77 -0
- raylings-0.1.0/solutions/14_kuberay/kuberay04.py +58 -0
- raylings-0.1.0/solutions/14_kuberay/kuberay05.py +48 -0
- raylings-0.1.0/src/raylings/__init__.py +3 -0
- raylings-0.1.0/src/raylings/cli.py +331 -0
- raylings-0.1.0/src/raylings/daemon.py +112 -0
- raylings-0.1.0/src/raylings/manifest.py +849 -0
- raylings-0.1.0/src/raylings/models.py +62 -0
- raylings-0.1.0/src/raylings/runner.py +180 -0
- raylings-0.1.0/src/raylings/ui.py +265 -0
- raylings-0.1.0/src/raylings/watcher.py +166 -0
- raylings-0.1.0/tests/test_chapters_10_12.py +56 -0
- raylings-0.1.0/tests/test_chapters_13_14.py +56 -0
- raylings-0.1.0/tests/test_chapters_1_3.py +54 -0
- raylings-0.1.0/tests/test_chapters_4_6.py +54 -0
- raylings-0.1.0/tests/test_chapters_7_9.py +59 -0
- raylings-0.1.0/tests/test_cli.py +273 -0
- raylings-0.1.0/tests/test_daemon.py +91 -0
- raylings-0.1.0/tests/test_infra.py +32 -0
- raylings-0.1.0/tests/test_manifest.py +137 -0
- raylings-0.1.0/tests/test_runner.py +268 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Python artifacts
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
env/
|
|
26
|
+
venv/
|
|
27
|
+
ENV/
|
|
28
|
+
.env
|
|
29
|
+
*.env
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Testing & Linters
|
|
33
|
+
.pytest_cache/
|
|
34
|
+
.ruff_cache/
|
|
35
|
+
.mypy_cache/
|
|
36
|
+
.coverage
|
|
37
|
+
htmlcov/
|
|
38
|
+
|
|
39
|
+
# Ray temp files
|
|
40
|
+
/tmp/ray/
|
|
41
|
+
*.flamegraph.*
|
|
42
|
+
|
|
43
|
+
# Agent rules, caches, & AI tooling (DO NOT COMMIT)
|
|
44
|
+
.agents/
|
|
45
|
+
.agent-state/
|
|
46
|
+
.superpowers/
|
|
47
|
+
.roborev/
|
|
48
|
+
.claude/
|
|
49
|
+
.gemini/
|
|
50
|
+
.cursor/
|
|
51
|
+
graphify-out/
|
|
52
|
+
.smellcheck-cache/
|
raylings-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Daniel Fisher
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
raylings-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: raylings
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An interactive, hands-on CLI learning environment for Python Ray
|
|
5
|
+
Project-URL: Homepage, https://github.com/dnf0/raylings
|
|
6
|
+
Project-URL: Repository, https://github.com/dnf0/raylings
|
|
7
|
+
Project-URL: Issues, https://github.com/dnf0/raylings/issues
|
|
8
|
+
Author: Daniel Fisher
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: cli,deep-learning,distributed-computing,education,interactive-learning,machine-learning,ray,rustlings
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Education
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Education
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: fastapi>=0.100.0
|
|
28
|
+
Requires-Dist: numpy>=1.24.0
|
|
29
|
+
Requires-Dist: pandas>=2.0.0
|
|
30
|
+
Requires-Dist: pyarrow>=14.0.0
|
|
31
|
+
Requires-Dist: ray[default]>=2.30.0
|
|
32
|
+
Requires-Dist: rich>=13.7.0
|
|
33
|
+
Requires-Dist: starlette>=0.28.0
|
|
34
|
+
Requires-Dist: torch>=2.2.0
|
|
35
|
+
Requires-Dist: typer>=0.12.0
|
|
36
|
+
Requires-Dist: uvicorn>=0.20.0
|
|
37
|
+
Requires-Dist: watchfiles>=0.21.0
|
|
38
|
+
Provides-Extra: dev
|
|
39
|
+
Requires-Dist: pre-commit>=3.7.0; extra == 'dev'
|
|
40
|
+
Requires-Dist: pyright>=1.1.350; extra == 'dev'
|
|
41
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
43
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: tomli>=2.0.0; (python_version < '3.11') and extra == 'dev'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# Raylings ⚡
|
|
48
|
+
|
|
49
|
+
> An interactive, hands-on CLI learning environment for mastering Python Ray from scratch.
|
|
50
|
+
|
|
51
|
+
Inspired by the pedagogy of [Rustlings](https://github.com/rust-lang/rustlings) and [Ziglings](https://github.com/ziglings/exercises), **Raylings** guides you through progressively challenging distributed computing exercises in Python. You will fix broken code, fill in missing distributed patterns, resolve performance bottlenecks, eliminate memory leaks, and build real-world distributed systems.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## What is Raylings?
|
|
56
|
+
|
|
57
|
+
Ray is a unified framework for scaling AI and Python applications from single laptops to massive multi-node clusters. While powerful, mastering Ray's mental models—futures, stateful actors, Plasma zero-copy memory, dynamic placement groups, and lineage-based fault tolerance—requires hands-on practice.
|
|
58
|
+
|
|
59
|
+
Raylings provides:
|
|
60
|
+
- **Interactive File Watcher**: Edit exercises in your favorite editor; Raylings automatically re-runs and validates your changes on file save.
|
|
61
|
+
- **Fast Execution**: Background Ray daemon re-uses a warm local cluster session for sub-50ms exercise turnaround.
|
|
62
|
+
- **14 Chapters & 55+ Exercises**: From first remote tasks to distributed parameter servers, PyTorch DDP pipelines, Ray Serve DAGs, and KubeRay on Kubernetes.
|
|
63
|
+
- **Progressive Hints & Solutions**: Stuck on an exercise? Get layered hints without spoiling the answer, or inspect canonical solutions when finished.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Quickstart
|
|
68
|
+
|
|
69
|
+
### Prerequisites
|
|
70
|
+
- Python 3.10, 3.11, or 3.12
|
|
71
|
+
- [uv](https://github.com/astral-sh/uv) (recommended) or `pipx` / `pip`
|
|
72
|
+
|
|
73
|
+
### 1. Instant Run with `uvx` (No installation needed)
|
|
74
|
+
|
|
75
|
+
Initialize a workspace in any directory and jump right in:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
uvx raylings init
|
|
79
|
+
uvx raylings watch
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or with `pipx`:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pipx run raylings init
|
|
86
|
+
pipx run raylings watch
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 2. Standard Installation
|
|
90
|
+
|
|
91
|
+
Install globally or in your virtual environment:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pip install raylings
|
|
95
|
+
raylings init
|
|
96
|
+
raylings watch
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 3. From Source
|
|
100
|
+
|
|
101
|
+
Clone the repository and install in editable mode:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
git clone https://github.com/dnf0/raylings.git
|
|
105
|
+
cd raylings
|
|
106
|
+
pip install -e ".[dev]"
|
|
107
|
+
raylings watch
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Interactive Learning Workflow
|
|
111
|
+
|
|
112
|
+
Raylings will start on the first exercise in `exercises/01_basics/basics01.py`. When you remove the `# I AM NOT DONE` marker and implement the solution, Raylings automatically tests your changes on save and advances you to the next challenge.
|
|
113
|
+
|
|
114
|
+
### CLI Commands
|
|
115
|
+
|
|
116
|
+
- `raylings init` — Extract bundled exercises into the current directory.
|
|
117
|
+
- `raylings watch` — Start continuous watching mode (recommended).
|
|
118
|
+
- `raylings run <exercise_name>` — Run and verify a specific exercise.
|
|
119
|
+
- `raylings test` — Run automated verification across all exercises.
|
|
120
|
+
- `raylings hint <exercise_name>` — Show progressive hints for an exercise.
|
|
121
|
+
- `raylings list` — View all chapters, exercises, and completion progress.
|
|
122
|
+
- `raylings verify` — Verify full curriculum progress and validate solutions.
|
|
123
|
+
- `raylings daemon [status|start|stop|restart]` — Manage the warm background Ray session.
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Curriculum Map
|
|
129
|
+
|
|
130
|
+
Raylings covers 14 comprehensive chapters spanning core foundations to production ML engineering:
|
|
131
|
+
|
|
132
|
+
| Chapter | Title | Topics Covered |
|
|
133
|
+
| :--- | :--- | :--- |
|
|
134
|
+
| **01** | **Ray Core Foundations** | `ray.init()` mechanics, `@ray.remote` tasks, `ObjectRef` futures, parallel pipelines, `ray.wait()`, multiple return values |
|
|
135
|
+
| **02** | **Distributed State & Actors** | Stateful actor classes, method serialization, actor handles, async actors, threaded actors, detached named actors, actor pools |
|
|
136
|
+
| **03** | **Plasma Object Store & Zero-Copy** | Plasma in-memory architecture, zero-copy NumPy/PyArrow, `ray.put()`, object pinning, disk spilling, serialization closures |
|
|
137
|
+
| **04** | **Scheduling & Placement Groups** | Fractional CPU/GPU resources, node affinity, `STRICT_SPREAD`, `STRICT_PACK`, multi-bundle gang scheduling, runtime environments |
|
|
138
|
+
| **05** | **Fault Tolerance & Recovery** | Automatic task retries, actor restart policies, lineage reconstruction, spot instance & preemption handling |
|
|
139
|
+
| **06** | **Cluster Architecture & Simulation** | Head vs worker nodes, GCS, Raylets, multi-node testing with `ray.cluster_utils.Cluster`, Ray Job Submission API |
|
|
140
|
+
| **07** | **Patterns & Anti-Patterns** | Fixing nested `ray.get()`, task chunking/batching, actor bottleneck elimination, tree-structured aggregation |
|
|
141
|
+
| **08** | **Ray Data (ETL & Batch)** | Ray Datasets, block partitioning, `map_batches` with PyArrow/NumPy, `ActorPoolStrategy`, streaming backpressure, PyTorch interop |
|
|
142
|
+
| **09** | **ML Primitives from Scratch** | Distributed parameter servers, async vs sync parameter updates, ring all-reduce communication, distributed trainers |
|
|
143
|
+
| **10** | **Ray Train (PyTorch DDP)** | `TorchTrainer`, `ScalingConfig`, distributed dataloaders, multi-GPU gradient sync, distributed checkpointing |
|
|
144
|
+
| **11** | **Ray Tune (Hyperparameter Optimization)** | Search spaces, distributed trial execution, ASHA / HyperBand early stopping, Population-Based Training (PBT) |
|
|
145
|
+
| **12** | **Ray Serve (Model Deployment)** | `@serve.deployment`, HTTP ingress, dynamic request batching (`@serve.batch`), multi-model DAGs, streaming LLMs, autoscaling |
|
|
146
|
+
| **13** | **Observability & Debugging** | Chrome execution timelines (`ray timeline`), memory profiling (`ray memory`), Prometheus metrics, GCS dumps |
|
|
147
|
+
| **14** | **KubeRay on Kubernetes** | RayCluster CRD, RayJob batch lifecycles, RayService rolling zero-downtime serving, KEDA autoscaling, pod eviction recovery |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Contributing
|
|
152
|
+
|
|
153
|
+
Contributions are warmly welcome! Whether you are adding new exercises, improving explanations, or fixing bugs, please check out [CONTRIBUTING.md](CONTRIBUTING.md) for local development setup and guidelines.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
This project is licensed under the [Apache License, Version 2.0](LICENSE).
|
raylings-0.1.0/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Raylings ⚡
|
|
2
|
+
|
|
3
|
+
> An interactive, hands-on CLI learning environment for mastering Python Ray from scratch.
|
|
4
|
+
|
|
5
|
+
Inspired by the pedagogy of [Rustlings](https://github.com/rust-lang/rustlings) and [Ziglings](https://github.com/ziglings/exercises), **Raylings** guides you through progressively challenging distributed computing exercises in Python. You will fix broken code, fill in missing distributed patterns, resolve performance bottlenecks, eliminate memory leaks, and build real-world distributed systems.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What is Raylings?
|
|
10
|
+
|
|
11
|
+
Ray is a unified framework for scaling AI and Python applications from single laptops to massive multi-node clusters. While powerful, mastering Ray's mental models—futures, stateful actors, Plasma zero-copy memory, dynamic placement groups, and lineage-based fault tolerance—requires hands-on practice.
|
|
12
|
+
|
|
13
|
+
Raylings provides:
|
|
14
|
+
- **Interactive File Watcher**: Edit exercises in your favorite editor; Raylings automatically re-runs and validates your changes on file save.
|
|
15
|
+
- **Fast Execution**: Background Ray daemon re-uses a warm local cluster session for sub-50ms exercise turnaround.
|
|
16
|
+
- **14 Chapters & 55+ Exercises**: From first remote tasks to distributed parameter servers, PyTorch DDP pipelines, Ray Serve DAGs, and KubeRay on Kubernetes.
|
|
17
|
+
- **Progressive Hints & Solutions**: Stuck on an exercise? Get layered hints without spoiling the answer, or inspect canonical solutions when finished.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Quickstart
|
|
22
|
+
|
|
23
|
+
### Prerequisites
|
|
24
|
+
- Python 3.10, 3.11, or 3.12
|
|
25
|
+
- [uv](https://github.com/astral-sh/uv) (recommended) or `pipx` / `pip`
|
|
26
|
+
|
|
27
|
+
### 1. Instant Run with `uvx` (No installation needed)
|
|
28
|
+
|
|
29
|
+
Initialize a workspace in any directory and jump right in:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uvx raylings init
|
|
33
|
+
uvx raylings watch
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or with `pipx`:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pipx run raylings init
|
|
40
|
+
pipx run raylings watch
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Standard Installation
|
|
44
|
+
|
|
45
|
+
Install globally or in your virtual environment:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install raylings
|
|
49
|
+
raylings init
|
|
50
|
+
raylings watch
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. From Source
|
|
54
|
+
|
|
55
|
+
Clone the repository and install in editable mode:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
git clone https://github.com/dnf0/raylings.git
|
|
59
|
+
cd raylings
|
|
60
|
+
pip install -e ".[dev]"
|
|
61
|
+
raylings watch
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Interactive Learning Workflow
|
|
65
|
+
|
|
66
|
+
Raylings will start on the first exercise in `exercises/01_basics/basics01.py`. When you remove the `# I AM NOT DONE` marker and implement the solution, Raylings automatically tests your changes on save and advances you to the next challenge.
|
|
67
|
+
|
|
68
|
+
### CLI Commands
|
|
69
|
+
|
|
70
|
+
- `raylings init` — Extract bundled exercises into the current directory.
|
|
71
|
+
- `raylings watch` — Start continuous watching mode (recommended).
|
|
72
|
+
- `raylings run <exercise_name>` — Run and verify a specific exercise.
|
|
73
|
+
- `raylings test` — Run automated verification across all exercises.
|
|
74
|
+
- `raylings hint <exercise_name>` — Show progressive hints for an exercise.
|
|
75
|
+
- `raylings list` — View all chapters, exercises, and completion progress.
|
|
76
|
+
- `raylings verify` — Verify full curriculum progress and validate solutions.
|
|
77
|
+
- `raylings daemon [status|start|stop|restart]` — Manage the warm background Ray session.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Curriculum Map
|
|
83
|
+
|
|
84
|
+
Raylings covers 14 comprehensive chapters spanning core foundations to production ML engineering:
|
|
85
|
+
|
|
86
|
+
| Chapter | Title | Topics Covered |
|
|
87
|
+
| :--- | :--- | :--- |
|
|
88
|
+
| **01** | **Ray Core Foundations** | `ray.init()` mechanics, `@ray.remote` tasks, `ObjectRef` futures, parallel pipelines, `ray.wait()`, multiple return values |
|
|
89
|
+
| **02** | **Distributed State & Actors** | Stateful actor classes, method serialization, actor handles, async actors, threaded actors, detached named actors, actor pools |
|
|
90
|
+
| **03** | **Plasma Object Store & Zero-Copy** | Plasma in-memory architecture, zero-copy NumPy/PyArrow, `ray.put()`, object pinning, disk spilling, serialization closures |
|
|
91
|
+
| **04** | **Scheduling & Placement Groups** | Fractional CPU/GPU resources, node affinity, `STRICT_SPREAD`, `STRICT_PACK`, multi-bundle gang scheduling, runtime environments |
|
|
92
|
+
| **05** | **Fault Tolerance & Recovery** | Automatic task retries, actor restart policies, lineage reconstruction, spot instance & preemption handling |
|
|
93
|
+
| **06** | **Cluster Architecture & Simulation** | Head vs worker nodes, GCS, Raylets, multi-node testing with `ray.cluster_utils.Cluster`, Ray Job Submission API |
|
|
94
|
+
| **07** | **Patterns & Anti-Patterns** | Fixing nested `ray.get()`, task chunking/batching, actor bottleneck elimination, tree-structured aggregation |
|
|
95
|
+
| **08** | **Ray Data (ETL & Batch)** | Ray Datasets, block partitioning, `map_batches` with PyArrow/NumPy, `ActorPoolStrategy`, streaming backpressure, PyTorch interop |
|
|
96
|
+
| **09** | **ML Primitives from Scratch** | Distributed parameter servers, async vs sync parameter updates, ring all-reduce communication, distributed trainers |
|
|
97
|
+
| **10** | **Ray Train (PyTorch DDP)** | `TorchTrainer`, `ScalingConfig`, distributed dataloaders, multi-GPU gradient sync, distributed checkpointing |
|
|
98
|
+
| **11** | **Ray Tune (Hyperparameter Optimization)** | Search spaces, distributed trial execution, ASHA / HyperBand early stopping, Population-Based Training (PBT) |
|
|
99
|
+
| **12** | **Ray Serve (Model Deployment)** | `@serve.deployment`, HTTP ingress, dynamic request batching (`@serve.batch`), multi-model DAGs, streaming LLMs, autoscaling |
|
|
100
|
+
| **13** | **Observability & Debugging** | Chrome execution timelines (`ray timeline`), memory profiling (`ray memory`), Prometheus metrics, GCS dumps |
|
|
101
|
+
| **14** | **KubeRay on Kubernetes** | RayCluster CRD, RayJob batch lifecycles, RayService rolling zero-downtime serving, KEDA autoscaling, pod eviction recovery |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Contributing
|
|
106
|
+
|
|
107
|
+
Contributions are warmly welcome! Whether you are adding new exercises, improving explanations, or fixing bugs, please check out [CONTRIBUTING.md](CONTRIBUTING.md) for local development setup and guidelines.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
This project is licensed under the [Apache License, Version 2.0](LICENSE).
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# I AM NOT DONE
|
|
2
|
+
"""Chapter 1: Ray Core Foundations - Exercise 1: Ray Init & First Remote Task.
|
|
3
|
+
|
|
4
|
+
Welcome to Raylings!
|
|
5
|
+
|
|
6
|
+
Ray is an open-source unified framework for scaling AI and Python applications.
|
|
7
|
+
At its core, Ray turns standard Python functions into asynchronous, distributed
|
|
8
|
+
tasks executed across worker processes.
|
|
9
|
+
|
|
10
|
+
Key Concepts:
|
|
11
|
+
1. `ray.init(ignore_reinit_error=True)`: Connects your Python script to a local
|
|
12
|
+
Ray cluster or starts one automatically if not already running.
|
|
13
|
+
2. `@ray.remote`: A decorator that designates a Python function as a distributed
|
|
14
|
+
remote task.
|
|
15
|
+
3. `func.remote(*args)`: Invoking a remote function returns an `ObjectRef` (a future),
|
|
16
|
+
submitting the task to the Ray scheduler without blocking.
|
|
17
|
+
4. `ray.get(object_ref)`: Blocks until the task completes and retrieves the computed result.
|
|
18
|
+
|
|
19
|
+
Your Task:
|
|
20
|
+
- Initialize Ray using `ray.init(ignore_reinit_error=True)`.
|
|
21
|
+
- Decorate the `square` function with `@ray.remote`.
|
|
22
|
+
- Call `square.remote(7)` and retrieve the result using `ray.get()`.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
import ray
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# TODO: Decorate this function with @ray.remote
|
|
29
|
+
def square(x: int) -> int:
|
|
30
|
+
return x * x
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def verify() -> None:
|
|
34
|
+
# TODO: Initialize Ray
|
|
35
|
+
# ray.init(ignore_reinit_error=True)
|
|
36
|
+
|
|
37
|
+
# TODO: Invoke the remote task and get the ObjectRef
|
|
38
|
+
# result_ref = square.remote(7)
|
|
39
|
+
# result = ray.get(result_ref)
|
|
40
|
+
result = None
|
|
41
|
+
|
|
42
|
+
assert ray.is_initialized(), "Ray should be initialized"
|
|
43
|
+
assert result == 49, f"Expected 49, but got {result}"
|
|
44
|
+
print("✓ basics01 verified: Ray initialized and remote task executed successfully!")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
verify()
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# I AM NOT DONE
|
|
2
|
+
"""Chapter 1: Ray Core Foundations - Exercise 2: ObjectRefs and ray.get().
|
|
3
|
+
|
|
4
|
+
In Ray, calling a remote function does NOT return the computed value directly.
|
|
5
|
+
Instead, it immediately returns an `ObjectRef`—a lightweight identifier representing
|
|
6
|
+
a future value that will be computed asynchronously on a cluster worker.
|
|
7
|
+
|
|
8
|
+
Key Concepts:
|
|
9
|
+
1. `ObjectRef`: A 28-byte unique identifier representing an object residing in Ray's
|
|
10
|
+
distributed object store.
|
|
11
|
+
2. `ray.get(object_ref)`: Blocks until the object is available and deserializes it.
|
|
12
|
+
3. Batch `ray.get([ref1, ref2, ...])`: Ray can wait on and retrieve an entire list of
|
|
13
|
+
`ObjectRef`s in parallel with a single call, which is much more efficient than calling
|
|
14
|
+
`ray.get()` one by one.
|
|
15
|
+
|
|
16
|
+
Your Task:
|
|
17
|
+
- Define a remote function `multiply(a: int, b: int) -> int`.
|
|
18
|
+
- Launch 5 parallel tasks calculating `i * 10` for `i` in `range(5)`.
|
|
19
|
+
- Store the list of `ObjectRef`s.
|
|
20
|
+
- Retrieve all 5 results in a single `ray.get(refs)` call.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
import ray
|
|
24
|
+
from ray import ObjectRef
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# TODO: Define a remote function named `multiply` that takes two integers and returns their product.
|
|
28
|
+
def multiply(a: int, b: int) -> int:
|
|
29
|
+
return a * b
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def verify() -> None:
|
|
33
|
+
ray.init(ignore_reinit_error=True)
|
|
34
|
+
|
|
35
|
+
# TODO: Launch 5 remote tasks to compute [0*10, 1*10, 2*10, 3*10, 4*10]
|
|
36
|
+
# and collect their ObjectRefs in `refs`.
|
|
37
|
+
refs: list[ObjectRef] = []
|
|
38
|
+
|
|
39
|
+
# TODO: Use a single ray.get() call to retrieve all results into `results`.
|
|
40
|
+
results: list[int] = []
|
|
41
|
+
|
|
42
|
+
expected = [0, 10, 20, 30, 40]
|
|
43
|
+
assert len(refs) == 5, f"Expected 5 ObjectRefs, got {len(refs)}"
|
|
44
|
+
assert results == expected, f"Expected {expected}, but got {results}"
|
|
45
|
+
print("✓ basics02 verified: ObjectRefs collected and fetched in batch successfully!")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
verify()
|