pitrou commented on a change in pull request #12604:
URL: https://github.com/apache/arrow/pull/12604#discussion_r825906405



##########
File path: dev/tasks/conda-recipes/clean.py
##########
@@ -40,41 +29,68 @@ def packages_to_delete(package_name: str, platform: str) -> 
List[str]:
             "-c",
             "arrow-nightlies",
             "--override-channels",
-            package_name,
+            "--subdir",
+            platform
         ],
-        env=env,
     )
-    pkgs = pd.DataFrame(json.loads(pkgs_json)[package_name])
-    pkgs["version"] = pkgs["version"].map(Version)
-    pkgs["py_version"] = pkgs["build"].str.slice(0, 4)
-
-    to_delete = []
-
-    for (subdir, python), group in pkgs.groupby(["subdir", "py_version"]):
-        group = group.sort_values(by="version", ascending=False)
-
-        if len(group) > VERSIONS_TO_KEEP:
-            del_candidates = group[VERSIONS_TO_KEEP:]
-            to_delete += (
-                f"arrow-nightlies/{package_name}/"
-                + del_candidates["version"].astype(str)
-                + del_candidates["url"].str.replace(
-                    "https://conda.anaconda.org/arrow-nightlies";, ""
+    pkgs = json.loads(pkgs_json)
+    num_builds = 0
+
+    for package_name, builds in pkgs.items():
+        num_builds += len(builds)
+        builds = pd.DataFrame(builds)
+        builds["version"] = builds["version"].map(Version)
+        # May be NaN if package doesn't depend on Python
+        builds["py_version"] = builds["build"].str.extract(r'(py\d+)')
+        builds["timestamp"] = pd.to_datetime(builds['timestamp'], unit='ms')
+        builds["stale"] = builds["timestamp"] < DELETE_BEFORE
+        # Some packages can be present in several "features" (e.g. CUDA),
+        # others miss that column in which case we set a default value.
+        if "track_features" not in builds.columns:
+            if package_name == "arrow-cpp-proc":
+                # XXX arrow-cpp-proc puts the features in the build field...
+                builds["track_features"] = builds["build"]

Review comment:
       @xhochy I'm not sure why that is. Is there a consistent way to extract 
the build configuration for a package (Python version + CPU/Cuda...)

##########
File path: dev/tasks/conda-recipes/clean.py
##########
@@ -40,41 +29,68 @@ def packages_to_delete(package_name: str, platform: str) -> 
List[str]:
             "-c",
             "arrow-nightlies",
             "--override-channels",
-            package_name,
+            "--subdir",
+            platform
         ],
-        env=env,
     )
-    pkgs = pd.DataFrame(json.loads(pkgs_json)[package_name])
-    pkgs["version"] = pkgs["version"].map(Version)
-    pkgs["py_version"] = pkgs["build"].str.slice(0, 4)
-
-    to_delete = []
-
-    for (subdir, python), group in pkgs.groupby(["subdir", "py_version"]):
-        group = group.sort_values(by="version", ascending=False)
-
-        if len(group) > VERSIONS_TO_KEEP:
-            del_candidates = group[VERSIONS_TO_KEEP:]
-            to_delete += (
-                f"arrow-nightlies/{package_name}/"
-                + del_candidates["version"].astype(str)
-                + del_candidates["url"].str.replace(
-                    "https://conda.anaconda.org/arrow-nightlies";, ""
+    pkgs = json.loads(pkgs_json)
+    num_builds = 0
+
+    for package_name, builds in pkgs.items():
+        num_builds += len(builds)
+        builds = pd.DataFrame(builds)
+        builds["version"] = builds["version"].map(Version)
+        # May be NaN if package doesn't depend on Python
+        builds["py_version"] = builds["build"].str.extract(r'(py\d+)')
+        builds["timestamp"] = pd.to_datetime(builds['timestamp'], unit='ms')
+        builds["stale"] = builds["timestamp"] < DELETE_BEFORE
+        # Some packages can be present in several "features" (e.g. CUDA),
+        # others miss that column in which case we set a default value.
+        if "track_features" not in builds.columns:
+            if package_name == "arrow-cpp-proc":
+                # XXX arrow-cpp-proc puts the features in the build field...
+                builds["track_features"] = builds["build"]

Review comment:
       @xhochy I'm not sure why that is. Is there a consistent way to extract 
the build configuration for a package (Python version + CPU/Cuda...)?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to