Skip to content

Commit

Permalink
[CIVIS-2326] MAINT update repo setup and packaging (#57)
Browse files Browse the repository at this point in the history
* MAINT switch to pyproject.toml, add support for python 3.12, drop python 3.8

* MAINT setup_remote_docker

* MAINT update ci config and add github templates

* FIX include dotfiles in setuptools.package-data

* REF refactor legacy python code
  • Loading branch information
jacksonlee-civis committed Jun 11, 2024
1 parent 450943e commit 7030306
Show file tree
Hide file tree
Showing 55 changed files with 842 additions and 744 deletions.
111 changes: 28 additions & 83 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,43 @@
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
build:
docker:
# Pick the highest Python 3.x version that this project is known to support
- image: cimg/python:3.11
# Pick the latest released Python 3.x version from https://circleci.com/developer/images/image/cimg/python
- image: cimg/python:3.12
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
name: Install the full development requirements
command: |
pip install --progress-bar off -e ".[dev]" && \
pip list -v
- 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/
name: bandit
command: |
pip install --progress-bar off --upgrade pip setuptools build && \
python -m build && \
pip install dist/`ls dist/ | grep .whl`
bandit --version && \
bandit -r src -x tests
- run:
name: Install the full development requirements
working_directory: ~/project/
command: pip install --progress-bar off -r dev-requirements.txt
name: black
command: |
black --check src tests
- run:
name: Show installed Python packages
command: pip list -v
name: flake8
command: |
flake8 src tests
- 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.
name: pip-audit
command: |
pytest -vv --durations=0 --junitxml=/tmp/testxml/report.xml project/civis_jupyter_notebooks
- store_test_results:
path: /tmp/testxml/
- setup_remote_docker
pip-audit --version && \
pip-audit --skip-editable
- run:
name: Test Docker image build
working_directory: ~/project/
name: Build and check the source distribution and wheel
command: |
if [ << parameters.python-version >> = 3.11 ]
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.8", "3.9", "3.10", "3.11"]
python -m build && \
twine check dist/`ls dist/ | grep .tar.gz` && \
twine check dist/`ls dist/ | grep .whl`
- run:
name: Run python tests
command: pytest --durations=0 --junitxml=/tmp/testxml/report.xml
- store_test_results:
path: /tmp/testxml/
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[flake8]
max-line-length = 125
max-line-length = 88
extend-ignore = E203
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/general.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: General
about: Ask a question, report a potential issue, etc.
title: ''
labels: ''
assignees: ''

---

**Note:** Civis employees should _not_ use the GitHub Issues feature at the public "civis-python" codebase
to file a ticket, and should instead use the internal ticketing system.
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


---

- [ ] (For Civis employees only) Reference to a relevant ticket in the pull request title
- [ ] Changelog entry added to `CHANGELOG.md` at the repo's root level
- [ ] Description of change in the pull request description
- [ ] If applicable, unit tests have been added and/or updated
- [ ] The CircleCI builds have all passed
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## [2.2.0] - 2024-06-12

### Added
- Added support for Python 3.12.

### Changed
- Updated packaging to use `pyproject.toml`.

### Removed
- Dropped support for Python 3.8.

## [2.1.1] - 2023-08-22

### Changed
Expand Down
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ See the `example`_ Docker image for more details.

.. _example: example

Integration Testing Docker Images with the Civis Platform
---------------------------------------------------------
Integration Testing Docker Images with Civis Platform
-----------------------------------------------------

If you would like to test your image's integration with the Civis Platform locally follow the steps below:
If you would like to test your image's integration with Civis Platform locally follow the steps below:

1. Create a notebook in your Civis Platform account and grab the id of the notebook. This ID is the number
1. Create a notebook in your Civis Platform account and grab the ID of the notebook. This ID is the number
that appears at the end of the URL for the notebook, ``https://platform.civisanalytics.com/#/notebooks/<NOTEBOOK ID>``.
2. Create an environment file called ``my.env`` and add the following to it::

Expand All @@ -51,11 +51,11 @@ If you would like to test your image's integration with the Civis Platform local
4. Run the container: ``docker run --rm -p 8888:8888 --env-file my.env test``.
5. Access the notebook at the ip of your Docker host with port 8888 (e.g., ``http://localhost:8888/notebooks/notebook.ipynb``).

Integration Testing Code Changes with the Civis Platform
--------------------------------------------------------
Integration Testing Code Changes with Civis Platform
----------------------------------------------------

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

From the top directory in the repo type::

Expand Down
8 changes: 0 additions & 8 deletions civis_jupyter_notebooks/__init__.py

This file was deleted.

58 changes: 0 additions & 58 deletions civis_jupyter_notebooks/__main__.py

This file was deleted.

15 changes: 0 additions & 15 deletions civis_jupyter_notebooks/assets/civis-git-clone

This file was deleted.

4 changes: 0 additions & 4 deletions civis_jupyter_notebooks/assets/ipython_config.py

This file was deleted.

52 changes: 0 additions & 52 deletions civis_jupyter_notebooks/log_utils.py

This file was deleted.

Loading

0 comments on commit 7030306

Please sign in to comment.