Skip to content

Commit

Permalink
[CIVIS-2313] MAINT update dependencies, prep for v2.1.0 release (#55)
Browse files Browse the repository at this point in the history
* MAINT switch from TravisCI to CircleCI; update dependency versions

* MAINT use Python 3.10.4

* MAINT Python 3.10 images need to install git

* MAINT pin tornado for Python 3.10

* MAINT update changelog

* MAINT update changelog

* MAINT update changelog
  • Loading branch information
jacksonlee-civis committed Apr 20, 2022
1 parent 16e3fb8 commit c83aeac
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 61 deletions.
98 changes: 98 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
version: 2.1

jobs:
pre-build:
description: A check that doesn't need every supported Python version (e.g., code style checks)
parameters:
command-run:
type: string
docker:
# Pick the highest Python 3.x version that this project is known to support
- image: cimg/python:3.10
steps:
- checkout
- run:
working_directory: ~/project/
command: << parameters.command-run >>

build-python:
parameters:
python-version:
type: string
docker:
- image: cimg/python:<< parameters.python-version >>
steps:
- checkout
- run:
# Test that we can build a source distribution that can correctly
# install from clean slate.
name: Build source distribution and install package from it
working_directory: ~/project/
command: |
pip install --progress-bar off --upgrade pip setuptools build && \
python -m build && \
pip install dist/`ls dist/ | grep .whl`
- run:
name: Install the full development requirements
working_directory: ~/project/
command: pip install --progress-bar off -r dev-requirements.txt
- run:
name: Show installed Python packages
command: pip list -v
- run:
name: Run python tests
working_directory: ~/
# Avoid being able to import the package by relative import.
# Test code by importing the *installed* package in site-packages.
command: |
pytest -vv --durations=0 --junitxml=/tmp/testxml/report.xml project/civis_jupyter_notebooks
- store_test_results:
path: /tmp/testxml/
- setup_remote_docker
- run:
name: Test Docker image build
working_directory: ~/project/
command: |
if [ << parameters.python-version >> = 3.10 ]
then
./tests/run_docker_tests.sh tests/Dockerfile
fi
workflows:
version: 2
build-and-test:
jobs:
- pre-build:
name: flake8
command-run: |
pip install -r dev-requirements.txt && \
flake8 civis_jupyter_notebooks
- pre-build:
name: twine
command-run: |
pip install --upgrade twine build && \
python -m build && \
twine check dist/`ls dist/ | grep .tar.gz` && \
twine check dist/`ls dist/ | grep .whl`
- pre-build:
name: safety
command-run: |
pip install -e . && \
pip install --upgrade safety && \
safety --version && \
safety check
- pre-build:
name: bandit
command-run: |
pip install --upgrade bandit && \
bandit --version && \
bandit -r civis_jupyter_notebooks -x civis_jupyter_notebooks/tests
- build-python:
requires:
- flake8
- twine
- safety
- bandit
matrix:
parameters:
python-version: ["3.7", "3.8", "3.9", "3.10"]
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## [2.1.0] - 2022-04-25

### Added
- Added support for Python 3.8, 3.9, and 3.10 (#55)

### Changed
- Updated core and dev dependencies (#55)
- Switched from TravisCI to CircleCI (#55)

### Removed
- Dropped support for Python 3.5 and 3.6 (#55)

## [2.0.0] - 2020-09-08

### Added
Expand Down
15 changes: 8 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
civis-jupyter-notebook
======================

.. image:: https://travis-ci.org/civisanalytics/civis-jupyter-notebook.svg?branch=master
:target: https://travis-ci.org/civisanalytics/civis-jupyter-notebook
.. image:: https://circleci.com/gh/civisanalytics/civis-jupyter-notebook.svg?style=shield
:target: https://circleci.com/gh/civisanalytics/civis-jupyter-notebook
:alt: CircleCI Builds

A tool to enable any Docker image to be used with Civis Platform Jupyter notebooks.

Expand All @@ -17,7 +18,7 @@ In your ``Dockerfile``, put the following code at the end::
civis-jupyter-notebooks-install

# Add Tini
ENV TINI_VERSION v0.16.1
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

Expand Down Expand Up @@ -54,12 +55,12 @@ Integration Testing Code Changes with the Civis Platform
--------------------------------------------------------

The scripts ``tests/build_dev_image.sh`` and ``tests/run_dev_image.sh`` can be used to test the
integration of coee changes with the Civis Platform.
integration of code changes with the Civis Platform.

From the top directory in the repo type::

$ ./test/build_dev_image.sh
$ ./test/run_dev_image.sh <NOTEBOOK ID>
$ ./tests/build_dev_image.sh
$ ./tests/run_dev_image.sh <NOTEBOOK ID>

where ``<NOTEBOOK ID>`` is the ID of a Civis Platform notebook. See step 1 above if you do not
have a notebook ID. Then you can connect to the notebook from your local browser and check
Expand All @@ -68,7 +69,7 @@ to make sure it is working properly.
Contributing
------------

See ``CONTIBUTING.md`` for information about contributing to this project.
See ``CONTRIBUTING.md`` for information about contributing to this project.

License
-------
Expand Down
8 changes: 8 additions & 0 deletions civis_jupyter_notebooks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
try:
from importlib.metadata import version
except ModuleNotFoundError:
# For Python 3.7
from importlib_metadata import version


__version__ = version("civis-jupyter-notebook")
8 changes: 4 additions & 4 deletions civis_jupyter_notebooks/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import shutil
import pkg_resources
import subprocess
import subprocess # nosec

import click

Expand All @@ -28,7 +28,7 @@ def cli():
# enable civisjupyter extension
for cmd in ['jupyter nbextension install --py civis_jupyter_ext',
'jupyter nbextension enable --py civis_jupyter_ext']:
subprocess.check_call(cmd, shell=True)
subprocess.check_call(cmd, shell=True) # nosec

# copy code
def _copy(src, dst):
Expand All @@ -51,8 +51,8 @@ def _copy(src, dst):
_copy(('assets', 'extensions', fe_ext), ('~', '.jupyter', 'extensions'))

# install and enable nbextensions
subprocess.check_call('jupyter nbextension install ~/.jupyter/extensions', shell=True)
subprocess.check_call('jupyter nbextension install ~/.jupyter/extensions', shell=True) # nosec
for extension in frontend_extensions:
ext_name = os.path.splitext(extension)[0]
cmd = 'jupyter nbextension enable extensions/{}'.format(ext_name)
subprocess.check_call(cmd, shell=True)
subprocess.check_call(cmd, shell=True) # nosec
4 changes: 2 additions & 2 deletions civis_jupyter_notebooks/notebook_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def find_and_install_requirements(requirements_path, c):

def config_jupyter(c):
# Jupyter Configuration
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.ip = '0.0.0.0' # nosec
c.NotebookApp.allow_origin = '*'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
c.NotebookApp.token = ''
c.NotebookApp.token = '' # nosec
c.NotebookApp.disable_check_xsrf = True
c.NotebookApp.tornado_settings = {'headers': {'Content-Security-Policy': "frame-ancestors *"}}
c.NotebookApp.terminado_settings = {'shell_command': ['bash']}
Expand Down
10 changes: 5 additions & 5 deletions civis_jupyter_notebooks/platform_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import nbformat
import os
import sys
import subprocess
import subprocess # nosec
import requests
from io import open
from subprocess import check_call
from subprocess import CalledProcessError
from subprocess import check_call # nosec
from subprocess import CalledProcessError # nosec
from civis_jupyter_notebooks import log_utils


Expand Down Expand Up @@ -81,7 +81,7 @@ def find_and_install_requirements(requirements_path):
def pip_install(requirements_file):
logger.info('Installing packages from %s' % requirements_file)
try:
subprocess.check_output(
subprocess.check_output( # nosec
[sys.executable, '-m', 'pip', 'install', '-r', requirements_file],
stderr=subprocess.STDOUT
)
Expand Down Expand Up @@ -126,7 +126,7 @@ def generate_and_save_preview(url, os_path):
d, fname = os.path.split(os_path)
logger.info('Rendering notebook to HTML')
try:
check_call(['jupyter', 'nbconvert', '--to', 'html', fname], cwd=d)
check_call(['jupyter', 'nbconvert', '--to', 'html', fname], cwd=d) # nosec
except CalledProcessError as e:
raise NotebookManagementError('nbconvert failed to convert notebook file to html: {}'.format(repr(e)))

Expand Down
17 changes: 17 additions & 0 deletions civis_jupyter_notebooks/tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import re

import civis_jupyter_notebooks


_REPO_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))


def test_version_number_match_with_changelog():
"""__version__ and CHANGELOG.md match for the latest version number."""
changelog = open(os.path.join(_REPO_DIR, 'CHANGELOG.md')).read()
version_in_changelog = (
re.search(r'##\s+\[(\d+\.\d+\.\d+)\]', changelog).groups()[0])
assert civis_jupyter_notebooks.__version__ == version_in_changelog, (
'Make sure both __version__ and CHANGELOG are updated to match the '
'latest version number')
1 change: 0 additions & 1 deletion civis_jupyter_notebooks/version.py

This file was deleted.

4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pytest~=3.2
flake8~=3.0
pytest==7.0.1
flake8==4.0.1
9 changes: 7 additions & 2 deletions example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
FROM python:3.7
FROM python:3.10.4-slim-buster

ENV DEFAULT_KERNEL python3

RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*

RUN pip install civis-jupyter-notebook && \
civis-jupyter-notebooks-install

# Add Tini
ENV TINI_VERSION v0.16.1
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

Expand Down
17 changes: 9 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
civis~=1.9
requests~=2.18
click~=6.7
jupyter-core~=4.6.0
notebook==6.0.0
tornado<6
civis-jupyter-extensions~=1.0
GitPython~=2.1
civis>=1.9
requests>=2.18
click>=6.7
jupyter-core>=4.6.0
notebook>=6.4.1
tornado>=6.1.0
civis-jupyter-extensions>=1.1.0
GitPython>=2.1
importlib-metadata >= 1.0 ; python_version < '3.8'
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ def read(fname):
return _in.read()


__version__ = None
exec(read('civis_jupyter_notebooks/version.py'))

setup(
name="civis-jupyter-notebook",
version=__version__,
version="2.1.0",
author="Civis Analytics Inc",
author_email="[email protected]",
url="https://www.civisanalytics.com",
description=("A tool for building Docker images for Civis "
"Platform Jupyter notebooks."),
packages=find_packages(),
long_description=read('README.rst'),
long_description_content_type="text/x-rst",
include_package_data=True,
license="BSD-3",
install_requires=read('requirements.txt').strip().split('\n'),
Expand Down
9 changes: 7 additions & 2 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
FROM python:3.7
FROM python:3.10.4-slim-buster

RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*

COPY ./requirements.txt /root/requirements.txt
RUN pip install -r /root/requirements.txt

# Add Tini
ENV TINI_VERSION v0.16.1
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

Expand Down

0 comments on commit c83aeac

Please sign in to comment.