Skip to content

Commit

Permalink
Fix deprecation warning for torch.load
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Einig committed Oct 2, 2024
1 parent e36cc99 commit 905b765
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish package to PyPI when a new version tag is pushed

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
pypi-publish:
name: Publish release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/nnbma>
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -q build
- name: Build package
run: |
python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ It enables to evaluate any neural network, its gradient, and its Hessian matrix

If you do not have a Python environment compatible with the above dependencies, we advise you to create a specific conda environment to use this code (<https://conda.io/projects/conda/en/latest/user-guide/>).

## Reference
## References

\[1\] Palud, P. & Einig, L. & Le Petit, F. & Bron, E. & Chainais, P. & Chanussot, J. & Pety, J. & Thouvenin, P.-A. & Languignon, D. & Beslić, I. & G. Santa-Maria, M. & Orkisz, J.H. & Ségal, L. & Zakardjian, A. & Bardeau, S. & Gerin, M. & Goicoechea, J.R. & Gratier, P. & Guzman, V. (2023). Neural network-based emulation of interstellar medium models. Astronomy & Astrophysics. 10.1051/0004-6361/202347074.
21 changes: 21 additions & 0 deletions coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions nnbma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__version__ = "1.0.2"

from .dataset import *
from .layers import *
from .learning import *
Expand Down
2 changes: 1 addition & 1 deletion nnbma/networks/neural_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ def _recursive_load(path: str) -> "NeuralNetwork":
module: nn.Module = type_module(**d)

sd = module.state_dict()
sd.update(torch.load(template.format("state_dict.pth")))
sd.update(torch.load(template.format("state_dict.pth"), weights_only=True))
module.load_state_dict(sd)

return module
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "nnbma"
version = "1.0.1"
version = ["version"]
authors = [
"Lucas Einig", "Pierre Palud",
]
Expand Down

0 comments on commit 905b765

Please sign in to comment.