Skip to content

Commit 26f6962

Browse files
sWX1071736imhy
authored andcommitted
Ray OBS support
Signed-off-by: Sergei <sv.sokolov@gmail.com>
1 parent a8bac2d commit 26f6962

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

reps/2024-04-24-ray-obs-support.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
## Summary
2+
3+
### General Motivation
4+
5+
Ray users can use the submit_job Api to send jobs to the ray cluster.
6+
7+
At the same time, they can specify the location of the project's working directory in a remote file system, for example s3.
8+
9+
This document suggests expanding the list of supported file systems and adding support for OBS (Object Storage Service).
10+
11+
After the implementation of this improvement, the user will be able to run submit tasks specifying the location of the working directory in OBS.
12+
13+
14+
The UserCase of submiting ray job via obs is shown in Figure 1:
15+
16+
- First, the user startups the remote ray cluster, and then upload the codes to the obs;
17+
18+
- Second, the user submits ray job to OBS using the submit_job APIs, as well as setting the obs path in the submit_job API
19+
20+
- Third, after submitting the ray job, the ray cluster automatically downloads, uncompresses, and executes the codes from the OBS
21+
22+
![Figure 1](2024-04-24-ray-obs-support/fig1.png)
23+
24+
25+
### Should this change be within `ray` or outside?
26+
27+
main `ray` project. Changes are made to Ray core components.
28+
29+
## Stewardship
30+
31+
### Required Reviewers
32+
33+
- @jjyao
34+
- @ericl
35+
36+
37+
### Shepherd of the Proposal (should be a senior committer)
38+
39+
- @ericl
40+
41+
42+
### Design and Architecture
43+
44+
To submit a Ray job through OBS, perform the following steps:
45+
46+
1. Compress the code into a zip or jar package and put it in OBS
47+
48+
2. You can use environment variables or configuration files to access the AK, SK, and Endpoint of OBS
49+
50+
3. When you submit a ray job, specify the path of the OBS service
51+
52+
```python
53+
job_id = client.submit_job(
54+
entrypoint="python script.py",
55+
runtime_env={"working_dir": "obs://example_bucket/example_file.zip"}
56+
)
57+
```
58+
59+
4. The ray cluster automatically downloads the example_file.zip from the specified OBS bucket, decompresses it, and then runs the entry file script.py in the working path
60+
61+
62+
## Design Insights
63+
64+
Modify the source code of Ray so that it can download and run the OBS code as follows:
65+
66+
1. Parse the OBS path, for example, "obs://example_bucket/example_file.zip";
67+
68+
2. Read the AK, SK, and endpoint of OBS through environment variables and configuration files to access the remote OBS path.
69+
70+
3. Download the example_file.zip from the specified OBS bucket, decompress it, and execute the user's code
71+
72+
We can extend the ray project to support obs protocol, enabling the ray cluster to parse the obs URI and download the codes from obs:
73+
74+
1. parse obs URI, such as "obs://example_bucket/example_file.zip";
75+
76+
2. config the obs AK, SK, and Endpoint via environment variables and config files;
77+
78+
3. the ray cluster automatically downloads and execute the codes from obs.
79+
80+
## Implementation Analysis
81+
82+
To extend the ray project for obs, we first need to figure out the workflow of parsing and accessing remote URIs, which is shown in Figure 2.
83+
![Figure 2](2024-04-24-ray-obs-support/fig2.png)
84+
85+
86+
After the user submitting remote ray jobs, the ray cluster calls download_and_unpack_package function to download and uncrompress the remote files, as shown in Figure 2. To extend the ray project for OBS, we should extend the download_and_unpack_package function to support the OBS scheme, which is implemented via the following two steps.
87+
88+
**Step 1**: Extend the **parse_uri** function to parse the OBS URIs, which is implemented in the file [ray/_private/runtime_env/packaging](https://github.com/ray-project/ray/blob/master/python/ray/_private/runtime_env/packaging.py).
89+
90+
**Step 2**: Extend the third-party library [smart_open](https://github.com/piskvorky/smart_open) to read OBS objects, which is suggested to implement 3 interfaces, i.e., parse uri, open_uri, and open, as shown in Extending smart_open.
91+
92+
93+
94+
The 3 interfaces in smart_open have their own intents:
95+
96+
**parse_uri** : parse the remote URI "obs://bucketId/keyId" to obtain the following info: obs (scheme), bucketId, keyId.
97+
98+
**open_uri** : using the parsed URI info to open the remote objects and call the open API to return an IO stream
99+
100+
**open** : access the remote object and open it as an IO stream
101+
102+
103+
It is worth noting that we can extend the open API to access the OBS objects, which can be implemented to call the wrapper functions based on [obs SDK](https://pypi.org/project/esdk-obs-python/).
32.4 KB
Loading
58 KB
Loading

0 commit comments

Comments
 (0)