Skip to content

Commit

Permalink
Fix pytest error (#26)
Browse files Browse the repository at this point in the history
* Update example.archive.json

Fix pytest error. Schema expects a str expected instead of a bool.

* Add nomad-lab dependency to pyproject.toml

* Remove nomad-lab from github action

* Github action uses uv for dependency management now

* Update github actions

* Update github actions and uv dependency management

* Update Python versions in GitHub Actions workflow

* Replace deprecated function in EQEAnalyzer

* Update permissions in GitHub Actions workflow

* Update uv installation in GitHub Actions workflow

* Update Python version matrix in GitHub Actions workflow

* Add dependencies for nomad-schema-plugin-run and nomad-schema-plugin-simulation-workflow
  • Loading branch information
fabianschoeppach authored Oct 17, 2024
1 parent f394d21 commit b29cbbd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
49 changes: 31 additions & 18 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,44 @@ name: install-and-test-workflow

on: [push]

permissions:
contents: read

env:
# using uv pip requires an existing venv by default
# allows installating packages in the system
UV_SYSTEM_PYTHON: true

jobs:
install-and-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python_version: ["3.12", "3.11", "3.10", "3.9"]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python ${{matrix.python_version}}
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: ${{matrix.python_version}}
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
# uses: astral-sh/setup-uv@v3
- name: Install dependencies
run: |
pip install --upgrade pip
# we need the latest nomad version for testing
pip install nomad-lab[infrastructure]@git+https://github.com/nomad-coe/nomad.git@develop
pip install '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple
pip install coverage coveralls
uv pip install -e '.[dev]'
- name: Test with pytest
run: |
python -m coverage run -m pytest -sv
- name: Submit to coveralls
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls --service=github
pytest
# python -m coverage run -m pytest -sv
# - name: Submit to coveralls
# continue-on-error: true
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# coveralls --service=github
# - name: Test with nomad
# run: |
# python -m nomad.cli parse tests/data/example.archive.json
Expand All @@ -39,14 +52,14 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Build the package
run: |
pip install --upgrade pip
pip install build
python -m build --sdist
uv build --sdist
- name: Install the package
run: |
pip install dist/*.tar.gz --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple
uv pip install dist/*.tar.gz --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple
# - name: Test with nomad
# run: |
# python -m nomad.cli parse tests/data/example.archive.json
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ maintainers = [
]
requires-python = ">=3.9"
dependencies = [
"nomad-lab>=1.3.0",
"nomad-schema-plugin-run>=1.0.1",
"nomad-schema-plugin-simulation-workflow>=1.0.1",
"rdkit",
"openpyxl",
"lxml_html_clean"
Expand All @@ -40,6 +43,9 @@ license = { file = "LICENSE" }
"Homepage" = "https://github.com/FAIRmat-NFDI/nomad-perovskite-solar-cells-database"
Repository = "https://github.com/FAIRmat-NFDI/nomad-perovskite-solar-cells-database"

[tool.uv]
index-url = "https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple"

[project.optional-dependencies]
dev = ["ruff", "pytest", "structlog"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def calculate_jsc(self):
energy_AM15 = np.array(df_am15[df_am15.columns[1]])
spectrum_AM15 = np.array(df_am15[df_am15.columns[2]])
spectrum_AM15G_interp = np.interp(x, energy_AM15, spectrum_AM15)
jsc_calc = integrate.cumtrapz(y * spectrum_AM15G_interp, x)
jsc_calc = integrate.cumulative_trapezoid(y * spectrum_AM15G_interp, x)
jsc = max(jsc_calc * q * 1e4)
return jsc

Expand Down
4 changes: 2 additions & 2 deletions tests/data/example.archive.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"composition_leadfree": false,
"additives_compounds": "Cl",
"band_gap": 1.6,
"band_gap_graded": false,
"band_gap_graded": "false",
"band_gap_estimation_basis": "Composition",
"storage_time_until_next_deposition_step": "Unknown",
"storage_atmosphere": "Unknown"
Expand Down Expand Up @@ -255,4 +255,4 @@
"irradiance_measured": false
}
}
}
}

0 comments on commit b29cbbd

Please sign in to comment.