Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
# Labels names are important as they are used by Release Drafter to decide
# regarding where to record them in changelog or if to skip them.
#
# The repository labels will be automatically configured using this file and
# the GitHub Action https://github.com/marketplace/actions/github-labeler.
- name: breaking
description: Breaking Changes
color: bfd4f2
- name: bug
description: Something isn't working
color: d73a4a
- name: build
description: Build System and Dependencies
color: bfdadc
- name: ci
description: Continuous Integration
color: 4a97d6
- name: dependencies
description: Pull requests that update a dependency file
color: 0366d6
- name: documentation
description: Improvements or additions to documentation
color: 0075ca
- name: duplicate
description: This issue or pull request already exists
color: cfd3d7
- name: enhancement
description: New feature or request
color: a2eeef
- name: github_actions
description: Pull requests that update Github_actions code
color: "000000"
- name: good first issue
description: Good for newcomers
color: 7057ff
- name: help wanted
description: Extra attention is needed
color: 008672
- name: invalid
description: This doesn't seem right
color: e4e669
- name: performance
description: Performance
color: "016175"
- name: python
description: Pull requests that update Python code
color: 2b67c6
- name: question
description: Further information is requested
color: d876e3
- name: refactoring
description: Refactoring
color: ef67c4
- name: removal
description: Removals and Deprecations
color: 9ae7ea
- name: style
description: Style
color: c120e5
- name: testing
description: Testing
color: b1fc6f
- name: wontfix
description: This will not be worked on
color: ffffff
29 changes: 29 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
categories:
- title: ":boom: Breaking Changes"
label: "breaking"
- title: ":rocket: Features"
label: "enhancement"
- title: ":fire: Removals and Deprecations"
label: "removal"
- title: ":beetle: Fixes"
label: "bug"
- title: ":racehorse: Performance"
label: "performance"
- title: ":rotating_light: Testing"
label: "testing"
- title: ":construction_worker: Continuous Integration"
label: "ci"
- title: ":books: Documentation"
label: "documentation"
- title: ":hammer: Refactoring"
label: "refactoring"
- title: ":lipstick: Style"
label: "style"
- title: ":package: Dependencies"
labels:
- "dependencies"
- "build"
template: |
## Changes

$CHANGES
33 changes: 33 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: labeler

on:
push:
branches:
- 'main'
paths:
- '.github/labels.yml'
- '.github/workflows/labels.yml'
pull_request:
paths:
- '.github/labels.yml'
- '.github/workflows/labels.yml'

jobs:
labeler:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Labeler
uses: crazy-max/ghaction-github-labeler@v5
with:
skip-delete: true
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
dry-run: ${{ github.event_name == 'pull_request' }}
exclude: |
help*
*issue
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Release

permissions:
contents: write
pages: write

on:
push:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.10"

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.2"

- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"

- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/[email protected]
with:
version-command: |
uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version

- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
run: |
uv run version_bumper.py &&
version=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version) &&
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $version.dev.$(date +%s)

- name: Install dependencies
run: |
uv sync

- name: Build book
run: uv run jupyter-book build . --verbose

- name: Publish
if: steps.check-version.outputs.tag
run: uv run ghp-import -n -p -f _build/html

- name: Publish the release notes
uses: release-drafter/[email protected]
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: tests

on:
- pull_request
- push

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: pre-commit/[email protected]

build:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.10"

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.2"

- name: set timezone
run: |
TZ="Europe/London" &&
sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime

- name: install linux deps
run: |
sudo apt-get -y install openssl graphviz nano texlive graphviz-dev unzip build-essential

- name: Install dependencies
run: |
uv sync

- name: build the book
run: |
uv run jupyter-book build . --verbose

- name: success
run: |
echo "Success in building book without errors!"
34 changes: 13 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,18 @@ repos:
entry: nbstripout
language: python
types: [jupyter]
- repo: https://github.com/psf/black
rev: 22.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.1
hooks:
- id: black
name: black
description: 'applies black formatter to .py files'
entry: black
language: python
types: [python]
- id: black-jupyter
name: black-jupyter
description:
"Black: The uncompromising Python code formatter (with Jupyter Notebook support)"
entry: black
language: python
minimum_pre_commit_version: 2.9.2
require_serial: true
# Run the linter.
- id: ruff
types_or: [python, pyi, jupyter]
args: [ --fix ]
- id: ruff
types_or: [python, pyi, jupyter]
name: sort imports with ruff
args: [--select, I, --fix]
# Run the formatter.
- id: ruff-format
types_or: [python, pyi, jupyter]
additional_dependencies: [".[jupyter]"]
- repo: https://github.com/pycqa/flake8
rev: 3.9.2 # pick a git hash / tag to point to
hooks:
- id: flake8
35 changes: 14 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
# DOCKERFILE for Coding for Economists
# Please note that you will need a lot of RAM dedicated to Docker to build this image (15Gb+, change this in your docker settings)
# DOCKERFILE for Python for Data Science

# Set base image (this also loads the Alpine Linux operating system)
FROM continuumio/miniconda3:4.10.3-alpine
# Set base image
FROM python:3.10-slim-bookworm

WORKDIR /app

# Update Linux package list and install some key libraries, including latex
RUN apk update && apk add openssl graphviz \
nano texlive alpine-sdk build-base graphviz-dev \
bash
RUN apt-get -y update && apt-get install -y openssl graphviz \
nano texlive graphviz-dev \
bash build-essential git

# change default shell from ash to bash
RUN sed -i -e "s/bin\/ash/bin\/bash/" /etc/passwd

# Install mamba
RUN conda install mamba -n base -c conda-forge
# Create the environment:
COPY uv.lock .
COPY pyproject.toml .

# Ensure pip's setuptools is latest
RUN pip install --upgrade setuptools wheel
# Install uv
COPY --from=ghcr.io/astral-sh/uv:0.5.14 /uv /bin/uv

# Create the environment:
COPY environment.yml .
# Install everything at once:
RUN mamba env create -f environment.yml
# Do a debug or incremental env install (builds quickly):
# RUN mamba create -n python4DS -c conda-forge python=3.9 numpy pandas -y

# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "py4ds2e", "/bin/bash", "-c"]
RUN uv sync --frozen

RUN mamba list
RUN uv pip list

# Copy the current directory contents into the container at /app
COPY . /app

RUN echo "Success building the python4DS container!"
RUN echo "Success building the Python4DS container!"
21 changes: 17 additions & 4 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
title: Python for Data Science
author: The Py4DS Community
logo: logo.png

exclude_patterns: [_build, Thumbs.db, .DS_Store, "**.ipynb_checkpoints", ".venv"]
# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
execute:
execute_notebooks: force
timeout: 120
exclude_patterns: [README.md]
exclude_patterns: ["README.md"]
allow_errors: false
nb_output_stderr: show


# Define the name of the latex output file for PDF builds
latex:
Expand All @@ -32,9 +35,19 @@ html:
use_issues_button: true
use_repository_button: true
favicon: "favicon.ico" # A path to a favicon image
google_analytics_id: "G-LXJC37BJVX" # A GA id that can be used to track book views.
analytics:
google_analytics_id: "G-LXJC37BJVX" # A GA id that can be used to track book views.

launch_buttons:
colab_url: "https://colab.research.google.com"
notebook_interface: "jupyterlab" # or "classic"
binderhub_url: "https://mybinder.org"
binderhub_url: "https://mybinder.org"

sphinx:
config:
html_js_files:
- https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js
bibtex_reference_style: author_year
suppress_warnings: ["mystnb.unknown_mime_type"]
nb_execution_show_tb: true
nb_execution_raise_on_error: true # Make build fail any content errors (don't want to publish if errors)
Loading
Loading