Skip to content

Commit c576f4e

Browse files
committed
Updated ray python version id logic
1 parent 534488d commit c576f4e

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

ray_python_version.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
#!/usr/bin/env python
22

3-
import requests
3+
import pandas as pd
44
from packaging.version import Version
55

6-
classifiers = (
7-
requests.get("https://pypi.org/pypi/ray/json").json().get("info").get("classifiers")
8-
)
9-
10-
versions = []
11-
for c in classifiers:
12-
x = c.split()
13-
if "Python" in x:
14-
versions.append(x[-1])
6+
os_map = {"linux": 1, "macos": 2, "windows": 3}
7+
versions = None
8+
for os, table_num in os_map.items():
9+
df = pd.read_html("https://docs.ray.io/en/latest/ray-overview/installation.html")[
10+
table_num
11+
]
12+
mask = df.apply(lambda col: col.astype(str).str.contains("beta")).any(axis=1)
13+
df = df.loc[~mask]
14+
for col in df.columns:
15+
if versions is None:
16+
versions = set(
17+
df[col].astype(str).str.extract(r"(\d+\.\d+)").values.flatten().tolist()
18+
)
19+
else:
20+
versions.intersection(
21+
(
22+
set(
23+
df[col]
24+
.astype(str)
25+
.str.extract(r"(\d+\.\d+)")
26+
.values.flatten()
27+
.tolist()
28+
)
29+
)
30+
)
31+
versions = list(versions)
1532

1633
versions.sort(key=Version)
1734
print(versions[-1])

0 commit comments

Comments
 (0)