Skip to content

Commit

Permalink
Upgrade from python3.9 to python3.10 (rlberry-py#335)
Browse files Browse the repository at this point in the history
* update python version 3.9 -> 3.10 for Azure CI

* update python version 3.9 -> 3.10 for Azure CI

* update changelog for python version 3.9 -> 3.10

* add shield about python version

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [Apptainer/Singularity scipts] add scripts to test current version of python, and specific version of python,.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
JulienT01 and pre-commit-ci[bot] authored Jul 13, 2023
1 parent 0b0e3ea commit e5b39fa
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

<!-- The badges -->
<p align="center">
<a href="https://pypi.org/project/rlberry/">
<img alt="Python Version" src="https://img.shields.io/badge/python-3.10-blue">
</a>
<a href="https://github.com/rlberry-py/rlberry/workflows/test/badge.svg">
<img alt="pytest" src="https://github.com/rlberry-py/rlberry/workflows/test/badge.svg">
</a>
Expand Down
24 changes: 12 additions & 12 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
vmImage: ubuntu-latest
strategy:
matrix:
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
variables:
NUMBA_DISABLE_JIT: "1"

Expand Down Expand Up @@ -84,8 +84,8 @@ jobs:
vmImage: 'macOS-12'
strategy:
matrix:
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'

steps:
- task: UsePythonVersion@0
Expand Down Expand Up @@ -119,8 +119,8 @@ jobs:
vmImage: 'windows-2022'
strategy:
matrix:
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'

steps:
- task: UsePythonVersion@0
Expand Down Expand Up @@ -156,8 +156,8 @@ jobs:
vmImage: ubuntu-latest
strategy:
matrix:
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
variables:
NUMBA_DISABLE_JIT: "1"

Expand Down Expand Up @@ -189,8 +189,8 @@ jobs:
vmImage: 'macOS-12'
strategy:
matrix:
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'

steps:
- task: UsePythonVersion@0
Expand Down Expand Up @@ -219,8 +219,8 @@ jobs:
vmImage: 'windows-2022'
strategy:
matrix:
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'

steps:
- task: UsePythonVersion@0
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Changelog

Dev version
-----------
*PR #335*

* Upgrade from Python3.9 -> python3.10


Version 0.5.0
-------------
Expand Down
17 changes: 17 additions & 0 deletions scripts/apptainer_for_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

To test rlberry, you can use this script to create a container that install the latest version, run the tests, and send the result by email.
(or you can check inside the .sh file to only get the part you need)

:warning: **WARNING** :warning: : In both files, you have to update the paths and names

## .def
Scripts to build your apptainer.
2 scripts :
- 1 with the "current" version of python (from ubuntu:last)
- 1 with a specific version of python to choose

## .sh
Script to run your apptainer and send the report
use chmod +x [name].sh to make it executable

To run this script you need to install "mailutils" first (to send the report by email)
28 changes: 28 additions & 0 deletions scripts/apptainer_for_tests/monthly_test_base.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Set the email recipient and subject
recipient="[email protected],[email protected]"
attachment="test_report.txt"

# Build, then run, the Apptainer container and capture the test results
cd [Path_to_your_apptainer_folder]
#build the apptainer from the .def file into an .sif image
apptainer build --fakeroot --force rlberry_apptainer_base.sif rlberry_apptainer_base.def
#Run the "runscript" section, and export the result inside a file (named previously)
apptainer run --fakeroot --overlay my_overlay/ rlberry_apptainer.sif > "$attachment"


# Send the test results by email
exit_code=$(cat [path]/exit_code.txt) # Read the exit code from the file

if [ $exit_code -eq 0 ]; then
# Initialization when the exit code is 0 (success)
subject="Rlberry : Succes Monthly Test Report"
core_message="Success. Please find attached the monthly test report."
else
# Initialization when the exit code is not 0 (failed)
subject="Rlberry : Failed Monthly Test Report"
core_message="Failed. Please find attached the monthly test report."
fi

echo "$core_message" | mail -s "$subject" -A "$attachment" "$recipient" -aFrom:"Rlberry_Monthly_tests"
37 changes: 37 additions & 0 deletions scripts/apptainer_for_tests/rlberry_apptainer__specific_python.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Bootstrap: docker
From: ubuntu:latest

#script for the build
%post -c /bin/bash

#get the last Ubuntu Update, and add the desdsnakes ppa to acces other python version
apt-get update \
&& apt-get upgrade -y
apt-get install -y software-properties-common
add-apt-repository ppa:deadsnakes/ppa -y
apt-get update

# Install python, and graphic and basic libs. Don't forget to change [version] by the python you want (python[version] > python3.11), then set the new python as "main" python
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y python[version] python[version]-dev python[version]-venv python3-pip git ffmpeg libsm6 libxext6 libsdl2-dev xvfb x11-xkb-utils --no-install-recommends
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python[version] 1
pip3 install --upgrade pip


#Remove the old tmp folder if it exist, then install rlberry
if [ -d /tmp/rlberry_test_dir[version] ]; then /bin/rm -r /tmp/rlberry_test_dir[version]; fi
git clone https://github.com/rlberry-py/rlberry.git /tmp/rlberry_test_dir[version]

#Install all the lib we need to run rlberry and its tests
pip3 install rlberry[torch_agents] opencv-python pytest pytest-xvfb pytest-xprocess tensorboard #--break-system-packages
pip3 install gymnasium[other]

#Environmment variable, Don't forget to change [version]
%environment
export LC_ALL=C
export PATH="/usr/bin/python[version]:$PATH"

#script that will be executed with the "run" command : run the tests in rlberry, then export the exit code inside a text file
%runscript
cd /tmp/rlberry_test_dir[version] && \
pytest rlberry
echo $? > [path]/exit_code.txt
35 changes: 35 additions & 0 deletions scripts/apptainer_for_tests/rlberry_apptainer_base.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Bootstrap: docker
From: ubuntu:latest

#script for the build
%post -c /bin/bash

#get the last Ubuntu Update,
apt-get update \
&& apt-get upgrade -y

# Install python, and graphic and basic libs.
apt-get install -y software-properties-common python3-pip git ffmpeg libsm6 libxext6 libsdl2-dev xvfb x11-xkb-utils

#Remove the old tmp folder if it exist, then download rlberry
if [ -d /tmp/rlberry_test_dir ]; then /bin/rm -r /tmp/rlberry_test_dir; fi
git clone https://github.com/rlberry-py/rlberry.git /tmp/rlberry_test_dir

#Install all the lib we need to run rlberry and its tests
pip3 install rlberry[torch_agents] opencv-python pytest pytest-xvfb pytest-xprocess tensorboard #--break-system-packages
pip3 install gymnasium[other]

%environment
export LC_ALL=C

#script that will be executed with the "run" command : run the tests in rlberry, the longtests, and then export the exit code inside a text file
%runscript
pip list
cd /tmp/rlberry_test_dir && \
pytest rlberry && \
pytest long_tests/rl_agent/ltest_mbqvi_applegold.py long_tests/torch_agent/ltest_a2c_cartpole.py long_tests/torch_agent/ltest_ctn_ppo_a2c_pendulum.py long_tests/torch_agent/ltest_dqn_montaincar.py

echo $? > [path]/exit_code.txt

#Run all the long test
#pytest long_tests/**/*.py
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"Intended Audience :: Science/Research",
"Intended Audience :: Education",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
Expand Down

0 comments on commit e5b39fa

Please sign in to comment.