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

MAINT: limit dependencies in Binder environment #8

Merged
merged 12 commits into from
Apr 25, 2023
Merged
2 changes: 2 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
],
"ignorePaths": [
"**/.cspell.json",
".github/workflows",
".gitignore",
".pre-commit-config.yaml",
".vscode/*",
"environment.yml",
"pyproject.toml",
"requirements*.in",
"requirements*.txt",
"tox.ini"
],
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/constraints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Requirements

on:
pull_request:
branches:
- main
- epic/*
- "[0-9]+.[0-9]+.x"
workflow_dispatch:

jobs:
pip-constraints:
if: >-
github.event_name == 'workflow_dispatch' ||
github.event.pull_request.head.repo.full_name == github.repository
name: Update pip constraints
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- run: pip install pip-tools
- run: pip-compile --no-annotate --strip-extras --upgrade binder/requirements.in
- run: pip-compile --no-annotate --strip-extras --upgrade requirements.in
- uses: actions/upload-artifact@v3
with:
path: |
binder/requirements.txt
requirements.txt

pre-commit:
name: pre-commit autoupdate
if: >-
github.event_name == 'workflow_dispatch' ||
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: ComPWA/update-pre-commit@main

push:
name: Push changes
runs-on: ubuntu-22.04
needs:
- pip-constraints
- pre-commit
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
- uses: actions/download-artifact@v3
- run: ls -A
- name: Move artifacts to correct location
run: |
if [[ -d artifact ]]; then
cd artifact
ls -A
for path in .pre-commit-config.yaml requirements.txt binder/requirements.txt; do
[[ -f $path ]] && mv -f $path ../$path
done
fi
- run: git status -s
- name: Commit and push changes
if: github.event_name == 'pull_request'
run: |
git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }}
git config --global user.name "GitHub"
git config --global user.email "[email protected]"
git checkout -b ${{ github.head_ref }}
if [[ $(git status -s) ]]; then
git add -A
git commit -m "MAINT: update pip constraints and pre-commit"
git config pull.rebase true
git pull origin ${{ github.head_ref }}
git push origin HEAD:${{ github.head_ref }}
fi
- name: Create Pull Request
if: >-
github.event_name == 'workflow_dispatch'
uses: peter-evans/create-pull-request@v4
with:
commit-message: "MAINT: update pip constraints and pre-commit"
committer: GitHub <[email protected]>
author: GitHub <[email protected]>
title: "MAINT: update pip constraints and pre-commit"
labels: |
🔨 Maintenance
branch-suffix: timestamp
delete-branch: true
token: ${{ secrets.PAT }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.csv
.ipynb_checkpoints/
.tox/
condaenv.*.requirements.txt
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ repos:
- >
cell.metadata.code_folding
cell.metadata.id
cell.metadata.user_expressions
metadata.celltoolbar
metadata.colab.name
metadata.colab.provenance
Expand All @@ -70,8 +71,9 @@ repos:
metadata.toc-showmarkdowntxt
metadata.toc-showtags
metadata.varInspector
metadata.vscode

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.6
rev: v3.0.0-alpha.9-for-vscode
hooks:
- id: prettier
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"eamodio.gitlens",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"github.vscode-github-actions",
"ms-python.python",
"ms-vsliveshare.vsliveshare",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker",
"travisillig.vscode-json-stable-stringify",
"tyriar.sort-lines",
"yzhang.markdown-all-in-one"
]
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
},
"cSpell.enabled": true,
"editor.formatOnSave": true,
"editor.rulers": [80],
"editor.rulers": [88],
"git.rebaseWhenSync": true,
"python.analysis.autoImportCompletions": false,
"python.analysis.diagnosticMode": "workspace",
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"python.linting.enabled": false,
"python.testing.unittestEnabled": false,
"rewrap.wrappingColumn": 79
"rewrap.wrappingColumn": 88
}
11 changes: 3 additions & 8 deletions 2021.11.29/ampform.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@
" create_analytic_breit_wigner,\n",
" create_relativistic_breit_wigner_with_ff,\n",
")\n",
"from ampform.dynamics.kmatrix import (\n",
" NonRelativisticKMatrix,\n",
" RelativisticKMatrix,\n",
")\n",
"from ampform.dynamics.kmatrix import NonRelativisticKMatrix, RelativisticKMatrix\n",
"from IPython.display import Math, display\n",
"from sympy.physics.quantum.spin import WignerD"
]
Expand Down Expand Up @@ -139,9 +136,7 @@
},
"outputs": [],
"source": [
"dot = qrules.io.asdot(\n",
" reaction, collapse_graphs=True, render_final_state_id=True\n",
")\n",
"dot = qrules.io.asdot(reaction, collapse_graphs=True, render_final_state_id=True)\n",
"graphviz.Source(dot)"
]
},
Expand Down Expand Up @@ -296,7 +291,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.8.16"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion 2021.11.29/qrules.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.8.16"
}
},
"nbformat": 4,
Expand Down
20 changes: 5 additions & 15 deletions 2021.11.29/tensorwaves-0.3.4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@
"from jax.lib import xla_bridge\n",
"from matplotlib import cm\n",
"from tensorflow.python.ops.numpy_ops import np_config\n",
"from tensorwaves.data import (\n",
" TFUniformRealNumberGenerator,\n",
" generate_data,\n",
" generate_phsp,\n",
")\n",
"from tensorwaves.data import TFUniformRealNumberGenerator, generate_data, generate_phsp\n",
"from tensorwaves.data.transform import HelicityTransformer\n",
"from tensorwaves.estimator import UnbinnedNLL\n",
"from tensorwaves.model import LambdifiedFunction, SympyModel\n",
Expand Down Expand Up @@ -123,9 +119,7 @@
" colors = [cm.rainbow(x) for x in evenly_spaced_interval]\n",
" plt.xlabel(\"$m$ [GeV]\")\n",
" for i, p in enumerate(resonances):\n",
" plt.gca().axvline(\n",
" x=p.mass, linestyle=\"dotted\", label=p.name, color=colors[i]\n",
" )\n",
" plt.gca().axvline(x=p.mass, linestyle=\"dotted\", label=p.name, color=colors[i])\n",
"\n",
"\n",
"def compare_model(\n",
Expand Down Expand Up @@ -300,12 +294,8 @@
"outputs": [],
"source": [
"fig, ax = plt.subplots()\n",
"ax.hist(\n",
" np.array(data[\"m_12\"]), density=True, bins=100, alpha=0.5, label=\"data\"\n",
")\n",
"ax.hist(\n",
" np.array(phsp[\"m_12\"]), density=True, bins=100, alpha=0.5, label=\"phsp\"\n",
")\n",
"ax.hist(np.array(data[\"m_12\"]), density=True, bins=100, alpha=0.5, label=\"data\")\n",
"ax.hist(np.array(phsp[\"m_12\"]), density=True, bins=100, alpha=0.5, label=\"phsp\")\n",
"ax.set_xlabel(R\"$m_{\\pi^0\\pi^0}$\")\n",
"ax.set_yticks([])\n",
"plt.legend();"
Expand Down Expand Up @@ -445,7 +435,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.8.16"
}
},
"nbformat": 4,
Expand Down
20 changes: 5 additions & 15 deletions 2021.11.29/tensorwaves.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@
"from jax.lib import xla_bridge\n",
"from matplotlib import cm\n",
"from tensorflow.python.ops.numpy_ops import np_config\n",
"from tensorwaves.data import (\n",
" TFUniformRealNumberGenerator,\n",
" generate_data,\n",
" generate_phsp,\n",
")\n",
"from tensorwaves.data import TFUniformRealNumberGenerator, generate_data, generate_phsp\n",
"from tensorwaves.data.transform import HelicityTransformer\n",
"from tensorwaves.estimator import UnbinnedNLL\n",
"from tensorwaves.model import LambdifiedFunction, SympyModel\n",
Expand Down Expand Up @@ -123,9 +119,7 @@
" colors = [cm.rainbow(x) for x in evenly_spaced_interval]\n",
" plt.xlabel(\"$m$ [GeV]\")\n",
" for i, p in enumerate(resonances):\n",
" plt.gca().axvline(\n",
" x=p.mass, linestyle=\"dotted\", label=p.name, color=colors[i]\n",
" )\n",
" plt.gca().axvline(x=p.mass, linestyle=\"dotted\", label=p.name, color=colors[i])\n",
"\n",
"\n",
"def compare_model(\n",
Expand Down Expand Up @@ -300,12 +294,8 @@
"outputs": [],
"source": [
"fig, ax = plt.subplots()\n",
"ax.hist(\n",
" np.array(data[\"m_12\"]), density=True, bins=100, alpha=0.5, label=\"data\"\n",
")\n",
"ax.hist(\n",
" np.array(phsp[\"m_12\"]), density=True, bins=100, alpha=0.5, label=\"phsp\"\n",
")\n",
"ax.hist(np.array(data[\"m_12\"]), density=True, bins=100, alpha=0.5, label=\"data\")\n",
"ax.hist(np.array(phsp[\"m_12\"]), density=True, bins=100, alpha=0.5, label=\"phsp\")\n",
"ax.set_xlabel(R\"$m_{\\pi^0\\pi^0}$\")\n",
"ax.set_yticks([])\n",
"plt.legend();"
Expand Down Expand Up @@ -445,7 +435,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.8.16"
}
},
"nbformat": 4,
Expand Down
22 changes: 6 additions & 16 deletions 2021.12.13/ampform.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@
" create_analytic_breit_wigner,\n",
" create_relativistic_breit_wigner_with_ff,\n",
")\n",
"from ampform.dynamics.kmatrix import (\n",
" NonRelativisticKMatrix,\n",
" RelativisticKMatrix,\n",
")\n",
"from ampform.dynamics.kmatrix import NonRelativisticKMatrix, RelativisticKMatrix\n",
"from ampform.sympy import UnevaluatedExpression\n",
"from IPython.display import Math, display\n",
"from ipywidgets import Checkbox, SelectionSlider, SelectMultiple, ToggleButtons\n",
Expand Down Expand Up @@ -148,9 +145,7 @@
},
"outputs": [],
"source": [
"dot = qrules.io.asdot(\n",
" reaction, collapse_graphs=True, render_final_state_id=True\n",
")\n",
"dot = qrules.io.asdot(reaction, collapse_graphs=True, render_final_state_id=True)\n",
"graphviz.Source(dot)"
]
},
Expand Down Expand Up @@ -247,8 +242,7 @@
"A_step2 = symplot.partial_doit(A_step1, (BlattWeisskopfSquared, WignerD))\n",
"A_step2 = symplot.partial_doit(A_step2, EnergyDependentWidth)\n",
"mass_substitutions = {\n",
" sp.Symbol(f\"m_{i}\", real=True): p.mass\n",
" for i, p in reaction.final_state.items()\n",
" sp.Symbol(f\"m_{i}\", real=True): p.mass for i, p in reaction.final_state.items()\n",
"}\n",
"substitutions = {\n",
" sp.sqrt(2): sp.sqrt(2).n(),\n",
Expand Down Expand Up @@ -452,9 +446,7 @@
},
"outputs": [],
"source": [
"mass_symbols = {\n",
" s: Symbol(s.name, **s.assumptions0) for s in mass_substitutions\n",
"}\n",
"mass_symbols = {s: Symbol(s.name, **s.assumptions0) for s in mass_substitutions}\n",
"colored_symbols = {\n",
" s: sp.Symbol(Rf\"\\color{{RoyalBlue}}{{{s.name}}}\", **s.assumptions0)\n",
" for s in mass_substitutions\n",
Expand All @@ -477,9 +469,7 @@
"source": [
"expr_subs = expr.subs(mass_substitutions)\n",
"expr_subs = round_nested(expr_subs, n_decimals=2)\n",
"node = [\n",
" s for s in sp.preorder_traversal(expr_subs) if isinstance(s, sp.Float)\n",
"][0]\n",
"node = [s for s in sp.preorder_traversal(expr_subs) if isinstance(s, sp.Float)][0]\n",
"dot = sp.dotprint(expr_subs.subs(node, Symbol(f\"{node}\")), **graph_style)\n",
"display(expr_subs.subs(node, sp.Symbol(Rf\"\\color{{RoyalBlue}}{node}\")))\n",
"graphviz.Source(dot)"
Expand Down Expand Up @@ -545,7 +535,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.8.16"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion 2021.12.13/qrules.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.8.16"
}
},
"nbformat": 4,
Expand Down
Loading