From 728fc179c6e2c6bc6ef0dc357670e490c9d4a24a Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 11 Feb 2025 10:53:54 +0100 Subject: [PATCH 1/2] Test on Python 3.12 --- .github/workflows/main.yml | 4 ++-- Pipfile | 7 ++++--- compiler_opt/rl/compilation_runner.py | 7 +++++++ pyproject.toml | 5 +---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f7c5ef5..cc02bc79 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,11 +28,11 @@ jobs: run: | if [ -z $ACT ] then - _ver="['3.10','3.11']" + _ver="['3.10','3.11','3.12']" _cache="1" else # 3.10 instead of '3.10' to make github act work. - _ver="[3.10,3.11]" + _ver="[3.10,3.11,3.12]" _cache="0" fi echo "version_matrix=$_ver" >> $GITHUB_OUTPUT diff --git a/Pipfile b/Pipfile index db2e9bf8..ba03e378 100644 --- a/Pipfile +++ b/Pipfile @@ -5,18 +5,19 @@ name = "pypi" [packages] absl-py = "==2.1.0" +dm-reverb = "==0.14.0" gin-config = "==0.5.0" psutil = "==6.1.0" -tf-agents = "==0.19.0" +setuptools = {version = "75.8.0", markers="python_version >= '3.12'"} tensorflow = "==2.15.0" -dm-reverb = "==0.14.0" +tf-agents = "==0.19.0" [dev-packages] pylint = "==3.3.2" pytest = "==8.3.4" pytype = "==2024.10.11" +ruff = "==0.9.6" yapf = "==0.43.0" -ruff = "==0.9.3" [ci] joblib = "==1.4.2" diff --git a/compiler_opt/rl/compilation_runner.py b/compiler_opt/rl/compilation_runner.py index ef022f8c..6dac760d 100644 --- a/compiler_opt/rl/compilation_runner.py +++ b/compiler_opt/rl/compilation_runner.py @@ -20,6 +20,7 @@ import shlex import signal import subprocess +import sys import tempfile import threading from typing import Callable, Dict, List, Optional, Tuple @@ -80,6 +81,12 @@ def __exit__(self, exc, value, tb): pass +if sys.version_info >= (3, 12): + from functools import partial + + NonTemporaryDirectory = partial(tempfile.TemporaryDirectory, delete=False) + + def get_workdir_context(explicit_temps_dir: Optional[str] = None): """Return a context which manages how the temperory directories are handled. diff --git a/pyproject.toml b/pyproject.toml index 2ff17d88..e9d13365 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,10 +21,7 @@ filterwarnings = [ "ignore:Using or importing the ABCs from 'collections':DeprecationWarning", # Issue #119 "ignore:Encoding a StructuredValue with type tfp.distributions.Deterministic_ACTTypeSpec:UserWarning", - # This warning stems from tensorflow and tf-agents and will presumably - # be fixed by them before v3.12 - "ignore:The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives:DeprecationWarning", - # Also an issue internal to tensorflow + # An issue internal to tensorflow "ignore:Call to deprecated create function .*Descriptor.*:DeprecationWarning", # Also internal to tensorflow "ignore:non-integer arguments to randrange.*:DeprecationWarning", From c6044939c3f68368aa3536fb0234c885087d5120 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 11 Feb 2025 11:12:44 +0100 Subject: [PATCH 2/2] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cc02bc79..2f7c5ef5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,11 +28,11 @@ jobs: run: | if [ -z $ACT ] then - _ver="['3.10','3.11','3.12']" + _ver="['3.10','3.11']" _cache="1" else # 3.10 instead of '3.10' to make github act work. - _ver="[3.10,3.11,3.12]" + _ver="[3.10,3.11]" _cache="0" fi echo "version_matrix=$_ver" >> $GITHUB_OUTPUT