Skip to content

Commit

Permalink
Add python 3.11 base image (#240)
Browse files Browse the repository at this point in the history
* Add python 3.11 base image.

* Update circleCI image.

* Add support for 3.11 skelebot base.

* Add deprecation warnings for R and python <3.9

* Add missing test.
  • Loading branch information
jagmoreira authored May 29, 2024
1 parent c429970 commit 48ca30b
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1
jobs:
build:
docker:
- image: circleci/python:3.6.1
- image: circleci/python:3.6.15
working_directory: ~/skelebot
steps:
- checkout
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ Documenting All Changes to the Skelebot Project

---

## v1.37.0
#### Changed
- **Python versions** | Support for python versions 3.6, 3.7, and 3.8, including base docker images, is **deprecated** and will be removed in skelebot 2.0
- **R support** | All support for `R` and `R+Python` projects, including base docker images, is **deprecated** and will be removed in skelebot 2.0
- **Python 3.11** | Adding support for Python 3.11

---

## v1.36.1
#### Merged: 2023-06-21
#### Released: 2023-06-21
#### Changed
- **Artifactory** | Using the default aws profile should pass `None` to boto3 Session.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.36.1
1.37.0
13 changes: 13 additions & 0 deletions base-images/python-base/3.11/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.11-slim
MAINTAINER Sean Shookman <sshookman@cars.com>

# Install basic compilers and libraries commonly needed for downstream packages
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y -q build-essential libgomp1 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN pip --no-cache-dir install -U pip
RUN pip --no-cache-dir install jupyter
RUN pip --no-cache-dir install jupyterlab
1 change: 1 addition & 0 deletions jobs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ docker build -t skelebot/python-base:3.7 base-images/python-base/3.7/
docker build -t skelebot/python-base:3.8 base-images/python-base/3.8/
docker build -t skelebot/python-base:3.9 base-images/python-base/3.9/
docker build -t skelebot/python-base:3.10 base-images/python-base/3.10/
docker build -t skelebot/python-base:3.11 base-images/python-base/3.11/

# Build python-krb
docker build -t skelebot/python-krb base-images/python-krb/
1 change: 1 addition & 0 deletions jobs/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ docker build -t skelebot/python-base:3.7 base-images/python-base/3.7/
docker build -t skelebot/python-base:3.8 base-images/python-base/3.8/
docker build -t skelebot/python-base:3.9 base-images/python-base/3.9/
docker build -t skelebot/python-base:3.10 base-images/python-base/3.10/
docker build -t skelebot/python-base:3.11 base-images/python-base/3.11/
# Newer Docker clients will push latest by default and will need to do `docker push skelebot/python-base --all-tags`
docker push skelebot/python-base

Expand Down
5 changes: 4 additions & 1 deletion skelebot/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
"R": _all_deps["R"],
"R+Python": _all_deps,
}
PYTHON_VERSIONS = ['3.6', '3.7', '3.8', '3.9', '3.10']
DEPRECATED_LANGUAGES = ["R", "R+Python"]

PYTHON_VERSIONS = ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
DEPRECATED_VERSIONS = ['3.6', '3.7', '3.8']

TEMPLATE_PATH = "templates/{name}"
TEMPLATES = {
Expand Down
9 changes: 8 additions & 1 deletion skelebot/objects/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .param import Param
from .skeleYaml import SkeleYaml
from .component import Activation
from ..common import LANGUAGE_IMAGE, PYTHON_VERSIONS
from ..common import LANGUAGE_IMAGE, PYTHON_VERSIONS, DEPRECATED_VERSIONS, DEPRECATION_WARNING
from ..components.componentFactory import ComponentFactory

class Config(SkeleYaml):
Expand Down Expand Up @@ -93,6 +93,13 @@ def __init__(self, name=None, env=None, description=None, version=None, maintain
self.pythonVersion = pythonVersion
self.gpu = gpu

if self.pythonVersion in DEPRECATED_VERSIONS:
print(DEPRECATION_WARNING.format(
code=f"support for Python version {self.pythonVersion}",
version="1.37.0",
msg="Please use a higher version."
))

def toDict(self):
"""
Extends the parent function in order to logic for handling the conversion of
Expand Down
9 changes: 7 additions & 2 deletions skelebot/systems/scaffolding/prompt.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
"""Prompt Function"""

def promptUser(message, options=None, boolean=False):
def promptUser(message, options=None, boolean=False, deprecated_options=None):
"""Construct dynamic prompts for user input and return the user-entered value"""

inp = None
if deprecated_options is None:
deprecated_options = []

if (options):
options = list(map(str, options))
p_options = []
for o in options:
p_options.append(o + " (DEPRECATED)" if o in deprecated_options else o)
if (len(options) == 1):
inp = options[0]
while inp not in options:
inp = input("{msg} [{options}]: ".format(msg=message, options=', '.join(options)))
inp = input("{msg} [{options}]: ".format(msg=message, options=', '.join(p_options)))
elif (boolean):
inp = input("{msg} [Y/N]: ".format(msg=message)) in ["Y", "y"]
else:
Expand Down
14 changes: 12 additions & 2 deletions skelebot/systems/scaffolding/scaffolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from ...objects.config import Config
from ...components.componentFactory import ComponentFactory
from ...systems.generators import dockerfile, dockerignore, readme, yaml
from ...common import LANGUAGE_DEPENDENCIES, TEMPLATES, TEMPLATE_PATH, GITHUB_RAW
from ...common import (LANGUAGE_DEPENDENCIES, TEMPLATES, TEMPLATE_PATH, GITHUB_RAW,
DEPRECATED_LANGUAGES, DEPRECATION_WARNING)
from .prompt import promptUser

class Scaffolder:
Expand Down Expand Up @@ -74,7 +75,16 @@ def scaffold(self):
description = promptUser("Enter a PROJECT DESCRIPTION")
maintainer = promptUser("Enter a MAINTAINER NAME")
contact = promptUser("Enter a CONTACT EMAIL")
language = promptUser("Select a LANGUAGE", options=list(LANGUAGE_DEPENDENCIES.keys()))
language = promptUser("Select a LANGUAGE",
options=list(LANGUAGE_DEPENDENCIES.keys()),
deprecated_options=DEPRECATED_LANGUAGES)

if language in DEPRECATED_LANGUAGES:
print(DEPRECATION_WARNING.format(
code=f"support for {language} language",
version="1.37.0",
msg="Please use a different language."
))

# Configure Template Variables
self.variables["name"] = name
Expand Down
12 changes: 12 additions & 0 deletions test/test_objects_config_validate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import copy
import unittest
from unittest import mock

from colorama import Fore, Style

from schema import SchemaError

Expand Down Expand Up @@ -45,6 +48,15 @@ def test_valid(self):
except:
self.fail("Validation Raised Exception Unexpectedly")

@mock.patch('skelebot.objects.config.print')
def test_valid_deprecated(self, mock_print):
_ = sb.objects.config.Config(pythonVersion='3.6')
mock_print.assert_called_once_with(
Fore.YELLOW + "WARN" + Style.RESET_ALL
+ " | The support for Python version 3.6 has been deprecated as of v1.37.0."
+ " Please use a higher version."
)

def test_invalid_mising(self):
config = copy.deepcopy(self.config)
del config['name']
Expand Down
52 changes: 47 additions & 5 deletions test/test_systems_scaffolding_scaffolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import unittest
from unittest import mock

from colorama import Fore, Style

import skelebot as sb
from skelebot.components.bump import Bump

Expand Down Expand Up @@ -62,10 +64,42 @@ def test_execute_scaffold_abort(self, mock_prompt, mock_cFactory, mock_getcwd, m
mock_prompt.assert_any_call("Enter a PROJECT DESCRIPTION")
mock_prompt.assert_any_call("Enter a MAINTAINER NAME")
mock_prompt.assert_any_call("Enter a CONTACT EMAIL")
mock_prompt.assert_any_call("Select a LANGUAGE", options=["Python", "R", "R+Python"])
mock_prompt.assert_any_call("Select a LANGUAGE",
options=["Python", "R", "R+Python"],
deprecated_options=["R", "R+Python"])
mock_prompt.assert_any_call("Select a TEMPLATE", options=["Default", "Dash", "Git"])
mock_prompt.assert_any_call("Confirm Skelebot Setup", boolean=True)

@mock.patch('os.path.expanduser')
@mock.patch('os.getcwd')
@mock.patch('skelebot.systems.scaffolding.scaffolder.ComponentFactory')
@mock.patch('skelebot.systems.scaffolding.scaffolder.promptUser')
@mock.patch('skelebot.systems.scaffolding.scaffolder.print')
def test_execute_scaffold_deprecated(self, mock_print, mock_prompt, mock_cFactory,
mock_getcwd, mock_expanduser):
mock_expanduser.return_value = "test/plugins"
mock_prompt.side_effect = ["test", "test proj", "sean", "email", "R", "Default", False]
try:
scaffolder = sb.systems.scaffolding.scaffolder.Scaffolder(existing=False)
scaffolder.scaffold()
self.fail("Exception Expected")
except Exception as exc:
self.assertEqual(str(exc), "Aborting Scaffolding Process")

mock_prompt.assert_any_call("Enter a PROJECT NAME")
mock_prompt.assert_any_call("Enter a PROJECT DESCRIPTION")
mock_prompt.assert_any_call("Enter a MAINTAINER NAME")
mock_prompt.assert_any_call("Enter a CONTACT EMAIL")
mock_prompt.assert_any_call("Select a LANGUAGE",
options=["Python", "R", "R+Python"],
deprecated_options=["R", "R+Python"])
mock_prompt.assert_any_call("Select a TEMPLATE", options=["Default", "Git"])
mock_prompt.assert_any_call("Confirm Skelebot Setup", boolean=True)

mock_print.assert_any_call(Fore.YELLOW + "WARN" + Style.RESET_ALL
+ " | The support for R language has been deprecated as of v1.37.0."
+ " Please use a different language.")

@mock.patch('os.path.expanduser')
@mock.patch('os.getcwd')
@mock.patch('os.makedirs')
Expand All @@ -85,7 +119,9 @@ def test_execute_scaffold_existing_init(self, mock_prompt, mock_yaml, #mock_cFac
mock_prompt.assert_any_call("Enter a PROJECT DESCRIPTION")
mock_prompt.assert_any_call("Enter a MAINTAINER NAME")
mock_prompt.assert_any_call("Enter a CONTACT EMAIL")
mock_prompt.assert_any_call("Select a LANGUAGE", options=["Python", "R", "R+Python"])
mock_prompt.assert_any_call("Select a LANGUAGE",
options=["Python", "R", "R+Python"],
deprecated_options=["R", "R+Python"])
mock_prompt.assert_any_call("Select a TEMPLATE", options=["Default", "Dash", "Git"])
mock_prompt.assert_any_call("Confirm Skelebot Setup", boolean=True)

Expand Down Expand Up @@ -137,7 +173,9 @@ def test_execute_scaffold_git_pull(self, mock_prompt, mock_yaml, mock_readme, mo
mock_prompt.assert_any_call("Enter a PROJECT DESCRIPTION")
mock_prompt.assert_any_call("Enter a MAINTAINER NAME")
mock_prompt.assert_any_call("Enter a CONTACT EMAIL")
mock_prompt.assert_any_call("Select a LANGUAGE", options=["Python", "R", "R+Python"])
mock_prompt.assert_any_call("Select a LANGUAGE",
options=["Python", "R", "R+Python"],
deprecated_options=["R", "R+Python"])
mock_prompt.assert_any_call("Select a TEMPLATE", options=["Default", "Dash", "Git"])
mock_prompt.assert_any_call("Enter AWS-PROD PROFILE")
mock_prompt.assert_any_call("Confirm Skelebot Setup", boolean=True)
Expand Down Expand Up @@ -207,7 +245,9 @@ def test_execute_scaffold_git_clone(self, mock_prompt, mock_yaml, mock_readme, m
mock_prompt.assert_any_call("Enter a PROJECT DESCRIPTION")
mock_prompt.assert_any_call("Enter a MAINTAINER NAME")
mock_prompt.assert_any_call("Enter a CONTACT EMAIL")
mock_prompt.assert_any_call("Select a LANGUAGE", options=["Python", "R", "R+Python"])
mock_prompt.assert_any_call("Select a LANGUAGE",
options=["Python", "R", "R+Python"],
deprecated_options=["R", "R+Python"])
mock_prompt.assert_any_call("Select a TEMPLATE", options=["Default", "Dash", "Git"])
mock_prompt.assert_any_call("Enter AWS-PROD PROFILE")
mock_prompt.assert_any_call("Confirm Skelebot Setup", boolean=True)
Expand Down Expand Up @@ -267,7 +307,9 @@ def test_execute_scaffold_dash(self, mock_prompt, mock_yaml, mock_readme, mock_p
mock_prompt.assert_any_call("Enter a PROJECT DESCRIPTION")
mock_prompt.assert_any_call("Enter a MAINTAINER NAME")
mock_prompt.assert_any_call("Enter a CONTACT EMAIL")
mock_prompt.assert_any_call("Select a LANGUAGE", options=["Python", "R", "R+Python"])
mock_prompt.assert_any_call("Select a LANGUAGE",
options=["Python", "R", "R+Python"],
deprecated_options=["R", "R+Python"])
mock_prompt.assert_any_call("Select a TEMPLATE", options=["Default", "Dash", "Git"])
mock_prompt.assert_any_call("Enter AWS-PROD PROFILE")
mock_prompt.assert_any_call("Confirm Skelebot Setup", boolean=True)
Expand Down

0 comments on commit 48ca30b

Please sign in to comment.