Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Cookie #1514

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
12 changes: 12 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 2024.08.19
_src_path: gh:scientific-python/cookie
backend: hatch
email: [email protected]
full_name: Econ-ARK Team
license: MIT
org: econ-ark
project_name: HARK
project_short_description: Heterogeneous Agents Resources and toolKit
url: https://github.com/econ-ark/HARK
vcs: true
3 changes: 3 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
89 changes: 89 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
See the [Scientific Python Developer Guide][spc-dev-intro] for a detailed
description of best practices for developing scientific packages.

[spc-dev-intro]: https://learn.scientific-python.org/development/

# Quick development

The fastest way to start with development is to use nox. If you don't have nox,
you can use `pipx run nox` to run it without installing, or `pipx install nox`.
If you don't have pipx (pip for applications), then you can install with
`pip install pipx` (the only case were installing an application with regular
pip is reasonable). If you use macOS, then pipx and nox are both in brew, use
`brew install pipx nox`.

To use, run `nox`. This will lint and test using every installed version of
Python on your system, skipping ones that are not installed. You can also run
specific jobs:

```console
$ nox -s lint # Lint only
$ nox -s tests # Python tests
$ nox -s docs -- --serve # Build and serve the docs
$ nox -s build # Make an SDist and wheel
```

Nox handles everything for you, including setting up an temporary virtual
environment for each run.

# Setting up a development environment manually

You can set up a development environment by running:

```bash
python3 -m venv .venv
source ./.venv/bin/activate
pip install -v -e .[dev]
```

If you have the
[Python Launcher for Unix](https://github.com/brettcannon/python-launcher), you
can instead do:

```bash
py -m venv .venv
py -m install -v -e .[dev]
```

# Pre-commit

You should prepare pre-commit, which will help you by checking that commits pass
required checks:

```bash
pip install pre-commit # or brew install pre-commit on macOS
pre-commit install # Will install a pre-commit hook into the git repo
```

You can also/alternatively run `pre-commit run` (changes only) or
`pre-commit run --all-files` to check even without installing the hook.

# Testing

Use pytest to run the unit checks:

```bash
pytest
```

# Coverage

Use pytest-cov to generate coverage reports:

```bash
pytest --cov=HARK
```

# Building docs

You can build the docs using:

```bash
nox -s docs
```

You can see a preview with:

```bash
nox -s docs -- --serve
```
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
5 changes: 5 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
exclude:
authors:
- dependabot
- pre-commit-ci
60 changes: 60 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CD

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types:
- published

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# Many color libraries just need this to be set to any value, but at least
# one distinguishes color depth, where "3" -> "256-bit color".
FORCE_COLOR: 3

jobs:
dist:
name: Distribution build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: hynek/build-and-inspect-python-package@v2

publish:
needs: [dist]
name: Publish to PyPI
environment: pypi
permissions:
id-token: write
attestations: write
contents: read
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Generate artifact attestation for sdist and wheel
uses: actions/[email protected]
with:
subject-path: "dist/*"

- uses: pypa/gh-action-pypi-publish@release/v1
with:
# Remember to tell (test-)pypi about this repo before publishing
# Remove this line to publish to PyPI
repository-url: https://test.pypi.org/legacy/
67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# Many color libraries just need this to be set to any value, but at least
# one distinguishes color depth, where "3" -> "256-bit color".
FORCE_COLOR: 3

jobs:
pre-commit:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: pre-commit/[email protected]
with:
extra_args: --hook-stage manual --all-files
- name: Run PyLint
run: pipx run nox -s pylint -- --output-format=github

checks:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
needs: [pre-commit]
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
runs-on: [ubuntu-latest, windows-latest, macos-14]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install package
run: python -m pip install .[test]

- name: Test package
run: >-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
--durations=20

- name: Upload coverage report
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
30 changes: 11 additions & 19 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
cache: "pip"
cache-dependency-path: |
requirements/base.txt
requirements/doc.txt
requirements/docs.txt

- name: Install Pandoc
run: sudo apt-get install --yes pandoc
Expand All @@ -44,16 +44,11 @@ jobs:
run: python -m pip install --upgrade pip

- name: Install HARK
run: python -m pip install .[doc]
run: python -m pip install .[docs]

- name: Run Sphinx
run: >
sphinx-build
-M html . HARK-docs
-T
-c Documentation
-W
-j 1
sphinx-build -M html docs HARK-docs -T -c docs -j 1

- name: Set up git for deployment
run: |
Expand All @@ -69,12 +64,13 @@ jobs:

- name: Deploy to GitHub Pages
# Only deploy to Pages on pushes to HEAD
if: (github.repository_owner == 'Econ-ARK') && (github.event_name == 'push') && (github.ref_name == 'master')
if:
(github.repository_owner == 'Econ-ARK') && (github.event_name ==
'push') && (github.ref_name == 'master')
run: >
git push
--force
https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}
`git subtree split --prefix HARK-docs/html gh-pages`:refs/heads/gh-pages
git push --force https://x-access-token:${{ github.token
}}@github.com/${{ github.repository }} `git subtree split --prefix
HARK-docs/html gh-pages`:refs/heads/gh-pages

lint:
runs-on: ubuntu-latest
Expand All @@ -91,9 +87,5 @@ jobs:
python -m pip install --upgrade sphinx-lint
- name: Lint documentation with sphinx-lint
run: >
sphinx-lint
--ignore Documentation/example_notebooks/GenIncProcessModel.py
--enable all
--max-line-length 85
README.md
Documentation/
sphinx-lint --ignore docs/example_notebooks/GenIncProcessModel.py
--enable all --max-line-length 85 README.md docs/
6 changes: 3 additions & 3 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:
- master
paths-ignore:
- ".github/workflows/documentation.yml"
- "Documentation/**"
- "docs/**"
pull_request:
branches:
- master
paths-ignore:
- ".github/workflows/documentation.yml"
- "Documentation/**"
- "docs/**"
schedule:
- cron: 0 0 * * *

Expand All @@ -35,4 +35,4 @@ jobs:
pip install ".[dev]"
- name: Run examples
run: |
pytest --nbval-lax --nbval-current-env --dist loadscope -n auto examples/
pytest --nbval-lax --nbval-current-env --dist loadscope -n auto docs/examples/
11 changes: 6 additions & 5 deletions .github/workflows/execute-notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ jobs:
python -m pip install ipykernel nbclient nbformat

- name: Strip output
run: nbstripout examples/**/*.ipynb
run: nbstripout docs/examples/**/*.ipynb

# This step takes c. 20 minutes
- name: Execute notebooks
run: python tools/nb_exec.py examples/**/*.ipynb
run: python tools/nb_exec.py docs/examples/**/*.ipynb
env:
PYTHONUNBUFFERED: "1"

Expand All @@ -67,7 +67,8 @@ jobs:
title: "[bot] Execute example notebooks"
# language=Markdown
body: >
This PR was [automatically generated] to re-execute
the example notebooks for use in the documentation.
This PR was [automatically generated] to re-execute the example
notebooks for use in the documentation.

[automatically generated]: https://github.com/Econ-ARK/HARK/actions/workflows/execute-notebooks.yml
[automatically generated]:
https://github.com/Econ-ARK/HARK/actions/workflows/execute-notebooks.yml
Loading
Loading