-
Notifications
You must be signed in to change notification settings - Fork 1
Pypi package for green-grids #8
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
Changes from all commits
15bb2af
f5840ea
43de440
a3f3758
1c2a0ef
f20a2b6
6aafbdb
21eaaee
2a6f8d1
96603e4
355e191
2d3ae7f
fef6022
ea4ebb8
62f3d3f
cfe2fa4
d3d36ec
98a2a1c
bafc665
7c89ecf
468f05f
ae4377e
40cad6b
fdf48b6
6a79353
f510136
55bad21
9777460
428be3e
4411ab2
992532f
8fc39a2
b9a0a08
89a25f0
abfe72e
0075888
8939977
382190f
836f80b
1895141
59c1048
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| ignore: | ||
| - "test/*" | ||
| - "test/*" | ||
| - "python/**/tests/**" | ||
| - "python/generate.py" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: Build and Publish | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - pypi | ||
| tags: | ||
| - 'v*' | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build_sdist: | ||
| name: Build source distribution | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.x' | ||
|
|
||
| - name: Build distributions | ||
| run: pipx run build | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: sdist | ||
| path: dist/* | ||
| if-no-files-found: error | ||
|
|
||
| upload_pypi: | ||
| needs: [build_sdist] | ||
| runs-on: ubuntu-latest | ||
| environment: release | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release' | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: sdist | ||
| path: dist | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| print-hash: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
| # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
|
||
| name: Python application | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python 3.12 | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: "3.12" | ||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install lcov libhdf5-dev | ||
| python -m pip install --upgrade pip | ||
| pip install flake8 pytest coverage pytest-cov | ||
| pip install -r python/requirements.txt | ||
| - name: Lint with flake8 | ||
| run: | | ||
| cd python | ||
| # stop the build if there are Python syntax errors or undefined names | ||
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
| # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
| - name: Install package | ||
| run: pip install . | ||
| - name: Test with pytest | ||
| run: pytest --cov python/ | ||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v3 | ||
| env: | ||
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,19 @@ namespace green::grids { | |
|
|
||
| void transformer_t::read_trans(const std::string& path) { | ||
| green::h5pp::archive tnl_file(grid_path(path)); | ||
|
|
||
| // Read version info | ||
| if (tnl_file.has_attribute("__grids_version__")) { | ||
| std::string v_str = tnl_file.get_attribute<std::string>("__grids_version__"); | ||
| set_version(v_str); | ||
| if (!CheckVersion(v_str)) { | ||
| throw outdated_grids_file_error("The grids file version " + v_str + | ||
| " is outdated. Minimum required version is " + GRIDS_MIN_VERSION + "."); | ||
| } | ||
| } else { | ||
| set_version(GRIDS_MIN_VERSION); | ||
gauravharsha marked this conversation as resolved.
Show resolved
Hide resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about that. If you read file that does not have version why the current version should be set as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Falling back to 0.2.4 simply to keep a value that is consistent with the previous release tag: https://github.com/Green-Phys/green-grids/releases/tag/v0.2.4 Do you have any alternative suggestion? If we set the grids version to an empty string or, say, "0.0.0", then that will trigger error with |
||
| } | ||
|
|
||
| read_trans_statistics(tnl_file, 1, _Tnc, _Tcn, _Ttc, _Tct); | ||
| read_trans_statistics(tnl_file, 0, _Tnc_B, _Tcn_B, _Ttc_B, _Tct_B); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| [build-system] | ||
| requires = ["setuptools>=64", "wheel"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| name = "green-grids" | ||
| dynamic = ["version"] | ||
| description = "Sparse-grid tools for Green's function methods in physics" | ||
| readme = "README.md" | ||
| requires-python = ">=3.9" | ||
| license = { text = "MIT" } # or your license | ||
| authors = [ | ||
| { name = "Sergei Iskakov", email = "siskakov@umich.edu" } | ||
| ] | ||
| maintainers = [ | ||
| { name = "Gaurav Harsha", email = "gharsha@umich.edu" }, | ||
| { name = "Sergei Iskakov", email = "siskakov@umich.edu" } | ||
| ] | ||
| keywords = [ | ||
| "physics", | ||
| "greens-functions", | ||
| "sparse-grids", | ||
| "numerical-methods", | ||
| "many-body", | ||
| "scientific-computing" | ||
| ] | ||
| classifiers = [ | ||
| "Development Status :: 4 - Beta", | ||
| "Intended Audience :: Science/Research", | ||
| "Topic :: Scientific/Engineering :: Physics", | ||
| "License :: OSI Approved :: MIT License", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.9", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Operating System :: POSIX", | ||
| "Operating System :: Unix", | ||
| "Operating System :: MacOS", | ||
| ] | ||
| dependencies = [ | ||
| "numpy>=1.19.0", | ||
| "scipy>=1.5.0", | ||
| "h5py>=3.0.0", | ||
| "mpmath>=1.0.0", | ||
| "sparse-ir>=1.0.0,<2.0.0", | ||
| "xprec>=1.3.0" | ||
| ] | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://green-phys.org" | ||
| Repository = "https://github.com/green-phys/green-grids" | ||
| Issues = "https://github.com/green-phys/green-grids/issues" | ||
| Documentation = "https://github.com/green-phys/green-grids#readme" | ||
|
|
||
| # ------------------------- | ||
| # setuptools configuration | ||
| # ------------------------- | ||
|
|
||
| [tool.setuptools] | ||
| package-dir = {"" = "python"} | ||
|
|
||
| [tool.setuptools.packages.find] | ||
| where = ["python"] | ||
| include = ["green_grids", "green_grids.*"] | ||
|
|
||
| [tool.setuptools.dynamic] | ||
| version = {attr = "green_grids.version.__version__"} | ||
|
|
||
| # ------------------------- | ||
| # Optional dev tooling | ||
| # ------------------------- | ||
|
|
||
| [project.optional-dependencies] | ||
| tests = ["coverage>=5.0.3", "pytest", "pytest-benchmark[histogram]>=3.2.1"] | ||
|
|
||
| # ------------------------- | ||
| # Coverage configuration | ||
| # ------------------------- | ||
| [tool.coverage.run] | ||
| branch = true | ||
| source = ["python/green_grids"] | ||
|
|
||
| # ------------------------- | ||
| # Pytest configuration | ||
| # ------------------------- | ||
| [tool.pytest.ini_options] | ||
| markers = [ | ||
| "slow: mark a test that takes a long time to run.", | ||
| ] |
Uh oh!
There was an error while loading. Please reload this page.