torchebm 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. torchebm-0.2.4/.github/workflows/docs_ci.yml +129 -0
  2. torchebm-0.2.4/.github/workflows/publish.yml +39 -0
  3. torchebm-0.2.4/.github/workflows/tag-release.yml +206 -0
  4. torchebm-0.2.4/.gitignore +165 -0
  5. torchebm-0.2.4/LICENSE +21 -0
  6. torchebm-0.2.4/PKG-INFO +265 -0
  7. torchebm-0.2.4/README.md +193 -0
  8. torchebm-0.2.4/__init__.py +1 -0
  9. torchebm-0.2.4/api_nav_structure.yml +25 -0
  10. torchebm-0.2.4/docs/api/index.md +111 -0
  11. torchebm-0.2.4/docs/api/torchebm/core/basesampler/classes/BaseSampler.md +23 -0
  12. torchebm-0.2.4/docs/api/torchebm/core/basesampler/index.md +31 -0
  13. torchebm-0.2.4/docs/api/torchebm/core/energy_function/classes/AckleyEnergy.md +23 -0
  14. torchebm-0.2.4/docs/api/torchebm/core/energy_function/classes/DoubleWellEnergy.md +23 -0
  15. torchebm-0.2.4/docs/api/torchebm/core/energy_function/classes/EnergyFunction.md +23 -0
  16. torchebm-0.2.4/docs/api/torchebm/core/energy_function/classes/GaussianEnergy.md +23 -0
  17. torchebm-0.2.4/docs/api/torchebm/core/energy_function/classes/HarmonicEnergy.md +23 -0
  18. torchebm-0.2.4/docs/api/torchebm/core/energy_function/classes/RastriginEnergy.md +23 -0
  19. torchebm-0.2.4/docs/api/torchebm/core/energy_function/classes/RosenbrockEnergy.md +23 -0
  20. torchebm-0.2.4/docs/api/torchebm/core/energy_function/index.md +37 -0
  21. torchebm-0.2.4/docs/api/torchebm/core/index.md +36 -0
  22. torchebm-0.2.4/docs/api/torchebm/core/losses/classes/Loss.md +23 -0
  23. torchebm-0.2.4/docs/api/torchebm/core/losses/index.md +31 -0
  24. torchebm-0.2.4/docs/api/torchebm/core/optimizer/classes/Optimizer.md +23 -0
  25. torchebm-0.2.4/docs/api/torchebm/core/optimizer/index.md +31 -0
  26. torchebm-0.2.4/docs/api/torchebm/core/score_matching/classes/ScoreMatching.md +23 -0
  27. torchebm-0.2.4/docs/api/torchebm/core/score_matching/index.md +31 -0
  28. torchebm-0.2.4/docs/api/torchebm/core/trainer/classes/ContrastiveDivergenceTrainer.md +23 -0
  29. torchebm-0.2.4/docs/api/torchebm/core/trainer/index.md +31 -0
  30. torchebm-0.2.4/docs/api/torchebm/cuda/index.md +27 -0
  31. torchebm-0.2.4/docs/api/torchebm/index.md +36 -0
  32. torchebm-0.2.4/docs/api/torchebm/losses/contrastive_divergence/classes/ContrastiveDivergence.md +23 -0
  33. torchebm-0.2.4/docs/api/torchebm/losses/contrastive_divergence/classes/ContrastiveDivergenceBase.md +23 -0
  34. torchebm-0.2.4/docs/api/torchebm/losses/contrastive_divergence/classes/ParallelTemperingCD.md +23 -0
  35. torchebm-0.2.4/docs/api/torchebm/losses/contrastive_divergence/classes/PersistentContrastiveDivergence.md +23 -0
  36. torchebm-0.2.4/docs/api/torchebm/losses/contrastive_divergence/index.md +34 -0
  37. torchebm-0.2.4/docs/api/torchebm/losses/index.md +31 -0
  38. torchebm-0.2.4/docs/api/torchebm/models/base_model/classes/BaseModel.md +23 -0
  39. torchebm-0.2.4/docs/api/torchebm/models/base_model/index.md +31 -0
  40. torchebm-0.2.4/docs/api/torchebm/models/index.md +31 -0
  41. torchebm-0.2.4/docs/api/torchebm/samplers/index.md +32 -0
  42. torchebm-0.2.4/docs/api/torchebm/samplers/langevin_dynamics/classes/LangevinDynamics.md +23 -0
  43. torchebm-0.2.4/docs/api/torchebm/samplers/langevin_dynamics/index.md +31 -0
  44. torchebm-0.2.4/docs/api/torchebm/samplers/mcmc/classes/HamiltonianMonteCarlo.md +23 -0
  45. torchebm-0.2.4/docs/api/torchebm/samplers/mcmc/index.md +31 -0
  46. torchebm-0.2.4/docs/api/torchebm/utils/index.md +31 -0
  47. torchebm-0.2.4/docs/assets/images/blog/hamiltonian/non-L-pendulum.png +0 -0
  48. torchebm-0.2.4/docs/assets/images/blog/hamiltonian/numerical_err.png +0 -0
  49. torchebm-0.2.4/docs/assets/images/blog/hamiltonian/pendulum_phase_space.mp4 +0 -0
  50. torchebm-0.2.4/docs/assets/images/blog/hamiltonian/quadratics.png +0 -0
  51. torchebm-0.2.4/docs/assets/images/e_functions/ackley.png +0 -0
  52. torchebm-0.2.4/docs/assets/images/e_functions/double_well.png +0 -0
  53. torchebm-0.2.4/docs/assets/images/e_functions/gaussian.png +0 -0
  54. torchebm-0.2.4/docs/assets/images/e_functions/harmonic.png +0 -0
  55. torchebm-0.2.4/docs/assets/images/e_functions/rastrigin.png +0 -0
  56. torchebm-0.2.4/docs/assets/images/e_functions/rosenbrock.png +0 -0
  57. torchebm-0.2.4/docs/assets/images/examples/double_well_trajectory.png +0 -0
  58. torchebm-0.2.4/docs/assets/images/examples/hmc_basic.png +0 -0
  59. torchebm-0.2.4/docs/assets/images/examples/hmc_comparison.png +0 -0
  60. torchebm-0.2.4/docs/assets/images/examples/hmc_custom_mass.png +0 -0
  61. torchebm-0.2.4/docs/assets/images/examples/hmc_standard.png +0 -0
  62. torchebm-0.2.4/docs/assets/images/examples/langevin_basic.png +0 -0
  63. torchebm-0.2.4/docs/assets/images/examples/langevin_trajectory.png +0 -0
  64. torchebm-0.2.4/docs/assets/images/favicon.svg +33 -0
  65. torchebm-0.2.4/docs/assets/images/logo_with_text.svg +50 -0
  66. torchebm-0.2.4/docs/assets/images/nabla_icon.svg +176 -0
  67. torchebm-0.2.4/docs/assets/images/parallel.jpg +0 -0
  68. torchebm-0.2.4/docs/assets/images/sampling.jpg +0 -0
  69. torchebm-0.2.4/docs/assets/images/trajectory.jpg +0 -0
  70. torchebm-0.2.4/docs/assets/images/visualization/advanced_energy_landscape.png +0 -0
  71. torchebm-0.2.4/docs/assets/images/visualization/basic_energy_landscape.png +0 -0
  72. torchebm-0.2.4/docs/assets/images/visualization/distribution_comparison.png +0 -0
  73. torchebm-0.2.4/docs/assets/images/visualization/energy_evolution.png +0 -0
  74. torchebm-0.2.4/docs/assets/images/visualization/interactive_visualization.png +0 -0
  75. torchebm-0.2.4/docs/assets/images/visualization/langevin_trajectory.png +0 -0
  76. torchebm-0.2.4/docs/assets/images/visualization/multiple_chains.png +0 -0
  77. torchebm-0.2.4/docs/blog/.authors.yml +15 -0
  78. torchebm-0.2.4/docs/blog/index.md +51 -0
  79. torchebm-0.2.4/docs/blog/posts/code-examples.md +57 -0
  80. torchebm-0.2.4/docs/blog/posts/hamiltonian-mechanics.md +723 -0
  81. torchebm-0.2.4/docs/blog/posts/langevin_dynamics_sampling.md +128 -0
  82. torchebm-0.2.4/docs/blog/posts/neural_energy_functions.md +12 -0
  83. torchebm-0.2.4/docs/blog/posts/schrodinger-bridges.md +18 -0
  84. torchebm-0.2.4/docs/developer_guide/api_design.md +288 -0
  85. torchebm-0.2.4/docs/developer_guide/api_generation.md +239 -0
  86. torchebm-0.2.4/docs/developer_guide/architecture.md +159 -0
  87. torchebm-0.2.4/docs/developer_guide/code_style.md +320 -0
  88. torchebm-0.2.4/docs/developer_guide/commit_conventions.md +81 -0
  89. torchebm-0.2.4/docs/developer_guide/contributing.md +249 -0
  90. torchebm-0.2.4/docs/developer_guide/core_components.md +610 -0
  91. torchebm-0.2.4/docs/developer_guide/cuda_optimizations.md +629 -0
  92. torchebm-0.2.4/docs/developer_guide/design_principles.md +321 -0
  93. torchebm-0.2.4/docs/developer_guide/development_setup.md +184 -0
  94. torchebm-0.2.4/docs/developer_guide/implementation_energy.md +663 -0
  95. torchebm-0.2.4/docs/developer_guide/implementation_losses.md +837 -0
  96. torchebm-0.2.4/docs/developer_guide/implementation_models.md +500 -0
  97. torchebm-0.2.4/docs/developer_guide/implementation_samplers.md +492 -0
  98. torchebm-0.2.4/docs/developer_guide/index.md +204 -0
  99. torchebm-0.2.4/docs/developer_guide/performance.md +301 -0
  100. torchebm-0.2.4/docs/developer_guide/project_structure.md +248 -0
  101. torchebm-0.2.4/docs/developer_guide/testing_guide.md +332 -0
  102. torchebm-0.2.4/docs/examples/core/energy_functions.md +118 -0
  103. torchebm-0.2.4/docs/examples/energy_visualization.md +201 -0
  104. torchebm-0.2.4/docs/examples/hmc.md +264 -0
  105. torchebm-0.2.4/docs/examples/index.md +129 -0
  106. torchebm-0.2.4/docs/examples/langevin_dynamics.md +280 -0
  107. torchebm-0.2.4/docs/examples/langevin_trajectory.md +274 -0
  108. torchebm-0.2.4/docs/examples/samplers/hmc.md +264 -0
  109. torchebm-0.2.4/docs/examples/samplers/langevin.md +280 -0
  110. torchebm-0.2.4/docs/examples/visualization/index.md +233 -0
  111. torchebm-0.2.4/docs/faq.md +153 -0
  112. torchebm-0.2.4/docs/getting_started.md +92 -0
  113. torchebm-0.2.4/docs/guides/custom_neural_networks.md +432 -0
  114. torchebm-0.2.4/docs/guides/energy_functions.md +178 -0
  115. torchebm-0.2.4/docs/guides/index.md +155 -0
  116. torchebm-0.2.4/docs/guides/loss_functions.md +210 -0
  117. torchebm-0.2.4/docs/guides/parallel_sampling.md +26 -0
  118. torchebm-0.2.4/docs/guides/samplers.md +183 -0
  119. torchebm-0.2.4/docs/guides/training.md +618 -0
  120. torchebm-0.2.4/docs/guides/visualization.md +461 -0
  121. torchebm-0.2.4/docs/hooks/socialmedia.py +29 -0
  122. torchebm-0.2.4/docs/index.md +348 -0
  123. torchebm-0.2.4/docs/introduction.md +72 -0
  124. torchebm-0.2.4/docs/overrides/partials/outdated.html +9 -0
  125. torchebm-0.2.4/docs/stylesheets/extra.css +265 -0
  126. torchebm-0.2.4/docs/tags.md +0 -0
  127. torchebm-0.2.4/examples/README.md +71 -0
  128. torchebm-0.2.4/examples/core/energy_advanced.py +106 -0
  129. torchebm-0.2.4/examples/core/energy_basic.py +39 -0
  130. torchebm-0.2.4/examples/core/energy_functions/landscape_2d.py +39 -0
  131. torchebm-0.2.4/examples/core/energy_functions/multimodal.py +106 -0
  132. torchebm-0.2.4/examples/core/energy_functions/parametric.py +50 -0
  133. torchebm-0.2.4/examples/main.py +88 -0
  134. torchebm-0.2.4/examples/samplers/hmc/advanced.py +408 -0
  135. torchebm-0.2.4/examples/samplers/hmc/gaussian_sampling.py +412 -0
  136. torchebm-0.2.4/examples/samplers/hmc/mass_matrix.py +89 -0
  137. torchebm-0.2.4/examples/samplers/langevin/advanced.py +246 -0
  138. torchebm-0.2.4/examples/samplers/langevin/gaussian_sampling.py +246 -0
  139. torchebm-0.2.4/examples/samplers/langevin/multimodal_sampling.py +164 -0
  140. torchebm-0.2.4/examples/samplers/langevin/visualization_trajectory.py +201 -0
  141. torchebm-0.2.4/examples/visualization/advanced/energy_evolution.py +51 -0
  142. torchebm-0.2.4/examples/visualization/advanced/energy_landscape.py +57 -0
  143. torchebm-0.2.4/examples/visualization/advanced/energy_over_time.py +51 -0
  144. torchebm-0.2.4/examples/visualization/advanced/langevin_trajectory.py +83 -0
  145. torchebm-0.2.4/examples/visualization/advanced/multiple_chains.py +76 -0
  146. torchebm-0.2.4/examples/visualization/advanced/multiple_doublewell.py +50 -0
  147. torchebm-0.2.4/examples/visualization/advanced/parallel_chains.py +76 -0
  148. torchebm-0.2.4/examples/visualization/advanced/trajectory_animation.py +83 -0
  149. torchebm-0.2.4/examples/visualization/advanced/visualization_examples.py +171 -0
  150. torchebm-0.2.4/examples/visualization/basic/contour_plots.py +41 -0
  151. torchebm-0.2.4/examples/visualization/basic/current_energy_fns_vis.py +106 -0
  152. torchebm-0.2.4/examples/visualization/basic/distribution_comparison.py +93 -0
  153. torchebm-0.2.4/examples/visualization/basic/energy_fn_vis.py +173 -0
  154. torchebm-0.2.4/examples/visualization/basic/energy_landscape.py +41 -0
  155. torchebm-0.2.4/examples/visualization/samplers_vis.py +171 -0
  156. torchebm-0.2.4/examples/visualization/utils.py +173 -0
  157. torchebm-0.2.4/generate_api_docs.py +912 -0
  158. torchebm-0.2.4/mkdocs.yml +278 -0
  159. torchebm-0.2.4/pyproject.toml +96 -0
  160. torchebm-0.2.4/requirements-docs.txt +13 -0
  161. torchebm-0.2.4/requirements.txt +3 -0
  162. torchebm-0.2.4/setup.cfg +4 -0
  163. torchebm-0.2.4/tests/conftest.py +33 -0
  164. torchebm-0.2.4/tests/core/test_energy_function.py +45 -0
  165. torchebm-0.2.4/tests/samplers/test_hmc.py +522 -0
  166. torchebm-0.2.4/tests/samplers/test_langevin_dynamics.py +182 -0
  167. torchebm-0.2.4/torchebm/__init__.py +1 -0
  168. torchebm-0.2.4/torchebm/_version.py +21 -0
  169. torchebm-0.2.4/torchebm/core/__init__.py +12 -0
  170. torchebm-0.2.4/torchebm/core/basesampler.py +104 -0
  171. torchebm-0.2.4/torchebm/core/energy_function.py +469 -0
  172. torchebm-0.2.4/torchebm/core/losses.py +17 -0
  173. torchebm-0.2.4/torchebm/core/optimizer.py +30 -0
  174. torchebm-0.2.4/torchebm/core/score_matching.py +61 -0
  175. torchebm-0.2.4/torchebm/core/trainer.py +43 -0
  176. torchebm-0.2.4/torchebm/cuda/__init__.py +0 -0
  177. torchebm-0.2.4/torchebm/losses/__init__.py +0 -0
  178. torchebm-0.2.4/torchebm/losses/contrastive_divergence.py +89 -0
  179. torchebm-0.2.4/torchebm/models/__init__.py +0 -0
  180. torchebm-0.2.4/torchebm/models/base_model.py +35 -0
  181. torchebm-0.2.4/torchebm/samplers/__init__.py +1 -0
  182. torchebm-0.2.4/torchebm/samplers/langevin_dynamics.py +382 -0
  183. torchebm-0.2.4/torchebm/samplers/mcmc.py +646 -0
  184. torchebm-0.2.4/torchebm/utils/__init__.py +3 -0
  185. torchebm-0.2.4/torchebm/utils/visualization.py +413 -0
  186. torchebm-0.2.4/torchebm.egg-info/PKG-INFO +265 -0
  187. torchebm-0.2.4/torchebm.egg-info/SOURCES.txt +188 -0
  188. torchebm-0.2.4/torchebm.egg-info/dependency_links.txt +1 -0
  189. torchebm-0.2.4/torchebm.egg-info/requires.txt +25 -0
  190. torchebm-0.2.4/torchebm.egg-info/top_level.txt +5 -0
@@ -0,0 +1,129 @@
1
+ name: ci
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ - main
7
+ permissions:
8
+ contents: write
9
+ jobs:
10
+ deploy:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ with:
15
+ fetch-depth: 0
16
+ - name: Configure Git Credentials
17
+ run: |
18
+ git config user.name github-actions[bot]
19
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: 3.x
23
+ - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
24
+ - uses: actions/cache@v4
25
+ with:
26
+ key: mkdocs-material-${{ env.cache_id }}
27
+ path: .cache
28
+ restore-keys: |
29
+ mkdocs-material-
30
+ - run: |
31
+ python -m pip install -e .[docs]
32
+ pip install -e .
33
+ - name: Generate API Documentation
34
+ run: |
35
+ python generate_api_docs.py
36
+ - name: Extract Version
37
+ run: |
38
+ # Get version from SCM (setuptools_scm)
39
+ python -c "from torchebm._version import version; print(f'VERSION={version}')" >> $GITHUB_ENV
40
+ - name: Setup gh-pages branch
41
+ run: |
42
+ # Initialize gh-pages branch if it doesn't exist
43
+ git fetch origin gh-pages || git checkout --orphan gh-pages
44
+ if ! git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
45
+ # If gh-pages doesn't exist on remote, create it
46
+ git checkout --orphan gh-pages
47
+ git rm -rf .
48
+ touch .nojekyll
49
+ git add .nojekyll
50
+ git commit -m "Initialize gh-pages branch"
51
+ git push -u origin gh-pages
52
+ git checkout -
53
+ else
54
+ # If it exists, ensure we have it locally
55
+ git checkout gh-pages || git checkout -b gh-pages origin/gh-pages
56
+ # Make sure it's up to date
57
+ git pull origin gh-pages
58
+ git checkout -
59
+ fi
60
+ - name: Extract clean version
61
+ run: |
62
+ # Extract clean version without build metadata for mike
63
+ CLEAN_VERSION=$(echo $VERSION | cut -d'+' -f1)
64
+ echo "CLEAN_VERSION=${CLEAN_VERSION}" >> $GITHUB_ENV
65
+ - name: Build Documentation
66
+ run: |
67
+ # Print MkDocs configuration
68
+ echo "MkDocs configuration:"
69
+ cat mkdocs.yml | grep -E "site_dir|docs_dir" || echo "No site_dir or docs_dir specified in mkdocs.yml"
70
+
71
+ # First build the documentation to generate the site directory
72
+ mkdocs build -v
73
+
74
+ # Check the output directory after build
75
+ echo "Directories after build:"
76
+ ls -la
77
+
78
+ # Create .nojekyll file in the root to prevent GitHub Pages from using Jekyll
79
+ touch .nojekyll
80
+
81
+ # Make sure the site directory exists before creating .nojekyll inside it
82
+ if [ -d "site" ]; then
83
+ touch site/.nojekyll
84
+ echo "Site directory found, created .nojekyll inside it"
85
+ else
86
+ echo "Warning: Site directory not found. Checking alternative directories..."
87
+ for dir in public/ _site/ build/ docs/site/ site_docs/; do
88
+ if [ -d "$dir" ]; then
89
+ echo "Found alternative directory: $dir"
90
+ touch "$dir/.nojekyll"
91
+ # Create symlink to make things consistent
92
+ ln -sf "$dir" site
93
+ break
94
+ fi
95
+ done
96
+ fi
97
+ - name: Deploy with Mike
98
+ run: |
99
+ # Check that we have a valid version to deploy
100
+ if [ -z "${CLEAN_VERSION}" ]; then
101
+ echo "Error: No version found to deploy"
102
+ exit 1
103
+ fi
104
+
105
+ echo "Deploying version: ${CLEAN_VERSION}"
106
+
107
+ # List current mike versions
108
+ mike list || echo "No versions found yet"
109
+
110
+ # Print mike configuration
111
+ echo "Mike configuration:"
112
+ mike --help
113
+
114
+ # Verify site directory exists before deploying
115
+ if [ ! -d "site" ]; then
116
+ echo "Error: 'site' directory not found. Cannot deploy with mike."
117
+ exit 1
118
+ fi
119
+
120
+ # Deploy with Mike - first remove latest alias if it exists
121
+ mike delete --push latest || true
122
+
123
+ # Deploy the new version and set it as latest
124
+ mike deploy --push --update-aliases ${CLEAN_VERSION} latest
125
+
126
+ # Set default version to latest
127
+ mike set-default --push latest
128
+
129
+ echo "Deployment completed successfully!"
@@ -0,0 +1,39 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*' # Trigger on version tags like v1.0.0
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v3
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v4
18
+ with:
19
+ python-version: '3.10'
20
+
21
+ - name: Install dependencies
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install -r requirements.txt
25
+
26
+ - name: Run tests
27
+ run: |
28
+ pytest tests/ # Adjust the path to your test directory
29
+
30
+ - name: Build the package
31
+ run: |
32
+ python -m pip install --upgrade build
33
+ python -m build # This will create .tar.gz and .whl files in the dist/ directory
34
+
35
+ - name: Publish to PyPI
36
+ uses: pypa/gh-action-pypi-publish@release/v1
37
+ with:
38
+ username: __token__
39
+ password: ${{ secrets.PYPI_API_TOKEN_EBM }}
@@ -0,0 +1,206 @@
1
+ #name: Release and Publish
2
+ #
3
+ #on:
4
+ # push:
5
+ # branches:
6
+ # - master # Adjust as necessary
7
+ #
8
+ #jobs:
9
+ # release:
10
+ # runs-on: ubuntu-latest
11
+ #
12
+ # steps:
13
+ # - name: Checkout code
14
+ # uses: actions/checkout@v3
15
+ #
16
+ # - name: Get latest tag
17
+ # id: get_latest_tag
18
+ # run: |
19
+ # git fetch --tags
20
+ # TAG=$(git tag --sort=-creatordate | head -n 1)
21
+ # echo "Latest tag is $TAG"
22
+ # echo "::set-output name=latest::$TAG"
23
+ #
24
+ # - name: Determine new version
25
+ # id: new_version
26
+ # run: |
27
+ # latest_tag="${{ steps.get_latest_tag.outputs.latest }}"
28
+ # if [ -z "$latest_tag" ]; then
29
+ # new_version="0.1.0" # No 'v' prefix for version number
30
+ # else
31
+ # # Increment the patch version
32
+ # new_version=$(echo $latest_tag | awk -F. -v OFS=. '{$NF++;print}' | sed 's/^v//')
33
+ # fi
34
+ # echo "New version is $new_version"
35
+ # echo "::set-output name=new_version::$new_version"
36
+ #
37
+ # - name: Update pyproject.toml version
38
+ # run: |
39
+ # sed -i "s/^version = .*/version = \"${{ steps.new_version.outputs.new_version }}\"/" pyproject.toml
40
+ #
41
+ # - name: Create new tag
42
+ # run: |
43
+ # git tag "v${{ steps.new_version.outputs.new_version }}"
44
+ # git push origin "v${{ steps.new_version.outputs.new_version }}"
45
+ #
46
+ # - name: Set up Python
47
+ # uses: actions/setup-python@v4
48
+ # with:
49
+ # python-version: '3.10'
50
+ #
51
+ # - name: Install dependencies
52
+ # run: |
53
+ # python -m pip install --upgrade pip
54
+ # pip install -r requirements.txt
55
+ #
56
+ # - name: Set PYTHONPATH
57
+ # run: echo "PYTHONPATH=$(pwd)/torchebm" >> $GITHUB_ENV
58
+ #
59
+ # - name: Install package
60
+ # run: |
61
+ # pip install .
62
+ #
63
+ # - name: Run tests
64
+ # run: |
65
+ # pytest tests/ # Adjust the path to your test directory
66
+ #
67
+ # - name: Build the package
68
+ # run: |
69
+ # python -m pip install --upgrade build
70
+ # python -m build # This will create .tar.gz and .whl files in the dist/ directory
71
+ #
72
+ # - name: Publish to PyPI
73
+ # uses: pypa/gh-action-pypi-publish@release/v1
74
+ # with:
75
+ # username: __token__ # Use __token__ for token-based authentication
76
+ # password: ${{ secrets.PYPI_API_TOKEN_EBM }}
77
+
78
+
79
+ name: Automated Tagging and Release
80
+
81
+ on:
82
+ push:
83
+ branches:
84
+ - master
85
+
86
+ jobs:
87
+ update-tag:
88
+ runs-on: ubuntu-latest
89
+ outputs:
90
+ new_tag: ${{ steps.create_tag.outputs.new_tag }}
91
+ update_type: ${{ steps.get_update_type.outputs.update_type }}
92
+
93
+ steps:
94
+ - name: Checkout code
95
+ uses: actions/checkout@v3
96
+ with:
97
+ fetch-depth: 0
98
+
99
+ - name: Get update type from commit message
100
+ id: get_update_type
101
+ run: |
102
+ commit_message="${{ github.event.head_commit.message }}"
103
+ if [[ "$commit_message" == *"#major"* ]]; then
104
+ echo "update_type=major" >> $GITHUB_OUTPUT
105
+ elif [[ "$commit_message" == *"#minor"* ]]; then
106
+ echo "update_type=minor" >> $GITHUB_OUTPUT
107
+ else
108
+ echo "update_type=patch" >> $GITHUB_OUTPUT
109
+ fi
110
+
111
+ - name: Get latest tag
112
+ id: get_latest_tag
113
+ run: |
114
+ git fetch --tags
115
+ latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null || echo "")
116
+ echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT
117
+
118
+ - name: Create new tag
119
+ id: create_tag
120
+ run: |
121
+ latest_tag=${{ steps.get_latest_tag.outputs.latest_tag }}
122
+ update_type=${{ steps.get_update_type.outputs.update_type }}
123
+
124
+ if [ -z "$latest_tag" ]; then
125
+ new_tag="v0.1.0"
126
+ else
127
+ IFS='.' read -ra VERSION <<< "${latest_tag#v}"
128
+ major=${VERSION[0]}
129
+ minor=${VERSION[1]}
130
+ patch=${VERSION[2]}
131
+
132
+ case $update_type in
133
+ major)
134
+ major=$((major+1))
135
+ minor=0
136
+ patch=0
137
+ ;;
138
+ minor)
139
+ minor=$((minor+1))
140
+ patch=0
141
+ ;;
142
+ patch)
143
+ patch=$((patch+1))
144
+ ;;
145
+ esac
146
+
147
+ new_tag="v$major.$minor.$patch"
148
+ fi
149
+
150
+ echo "new_tag=${new_tag}" >> $GITHUB_OUTPUT
151
+ git config user.name github-actions
152
+ git config user.email github-actions@github.com
153
+ git tag $new_tag
154
+ git push origin $new_tag
155
+
156
+ release:
157
+ needs: update-tag
158
+ if: contains(github.event.head_commit.message, '#release')
159
+ runs-on: ubuntu-latest
160
+
161
+ steps:
162
+ - name: Checkout code
163
+ uses: actions/checkout@v3
164
+ with:
165
+ fetch-depth: 0
166
+
167
+ - name: Set up Python
168
+ uses: actions/setup-python@v4
169
+ with:
170
+ python-version: '3.10'
171
+ cache: 'pip'
172
+
173
+ - name: Install dependencies
174
+ run: |
175
+ python -m pip install --upgrade pip
176
+ pip install -r requirements.txt
177
+ pip install build twine wheel
178
+
179
+ - name: Install package for testing
180
+ run: pip install -e .
181
+
182
+ - name: Run tests
183
+ run: pytest tests/
184
+
185
+ - name: Build package
186
+ run: |
187
+ python -m build --sdist --wheel
188
+ python -m twine check dist/*
189
+
190
+ - name: Publish to PyPI
191
+ uses: pypa/gh-action-pypi-publish@release/v1
192
+ with:
193
+ username: __token__
194
+ password: ${{ secrets.PYPI_API_TOKEN_EBM }}
195
+ verbose: true
196
+
197
+ - name: Create GitHub Release
198
+ uses: softprops/action-gh-release@v1
199
+ with:
200
+ tag_name: ${{ needs.update-tag.outputs.new_tag }}
201
+ name: Release ${{ needs.update-tag.outputs.new_tag }}
202
+ draft: false
203
+ prerelease: false
204
+ generate_release_notes: true
205
+ env:
206
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,165 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ dist
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111
+ .pdm.toml
112
+ .pdm-python
113
+ .pdm-build/
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ #.idea/
164
+ /scope.txt
165
+ /.venv13/
torchebm-0.2.4/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 TorchEBM Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.