-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rebuild environment. Add ui tests and workflows
- Loading branch information
1 parent
fb1d4e2
commit f9f0d8b
Showing
4 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build | ||
# To test with act: gh act --secret-file $ENV_FILE --workflows .github/workflows/unit.yml | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
env: | ||
EARTHENGINE_TOKEN: ${{ secrets.EARTHENGINE_TOKEN }} | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python "3.10" | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install sepal_ui | ||
run: python -m pip install "git+https://github.com/12rambau/sepal_ui.git@sepal_pre_release" | ||
- name: Build with sepal_ui venv | ||
run: module_venv | ||
- name: Install nox | ||
run: python -m pip install nox | ||
- name: set entry point and run tests | ||
run: nox -s test_ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
*nox_ui.ipynb | ||
*Untitled* | ||
|
||
|
||
# C extensions | ||
*.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
"""All the process that can be run using nox. | ||
The nox run are build in isolated environment that will be stored in .nox. to force the venv update, remove the .nox/xxx folder. | ||
""" | ||
|
||
from pathlib import Path | ||
import nbformat | ||
from nbconvert.preprocessors import ExecutePreprocessor | ||
from jupyter_client.kernelspec import KernelSpecManager | ||
import nox | ||
|
||
|
||
@nox.session(reuse_venv=True) | ||
def lint(session): | ||
"""Apply the pre-commits.""" | ||
session.install("pre-commit") | ||
session.run("pre-commit", "run", "--a", *session.posargs) | ||
|
||
|
||
@nox.session(reuse_venv=True) | ||
def app(session): | ||
"""Run the application.""" | ||
|
||
entry_point = str(Path("ui.ipynb")) | ||
|
||
# Duplicate the entry point file | ||
session.run("cp", entry_point, "nox_ui.ipynb") | ||
|
||
# change the kernel name in the entry point | ||
session.run("entry_point", "--test", "nox_ui.ipynb") | ||
|
||
session.run("jupyter", "trust", entry_point) | ||
session.run( | ||
"voila", "--show_tracebacks=True", "--template=sepal-ui-base", "nox_ui.ipynb" | ||
) | ||
|
||
|
||
@nox.session() | ||
def test_ui(session): | ||
"""Run the application.""" | ||
|
||
ksm = KernelSpecManager() | ||
kernel_names = list(ksm.get_all_specs()) | ||
print(kernel_names) | ||
|
||
# get the current path | ||
root_folder = Path(__file__).parent | ||
repo_name = root_folder.name | ||
|
||
# Copy the ui.ipynb to test_ui.ipynb | ||
session.run("cp", root_folder / "ui.ipynb", root_folder / "nox_ui.ipynb") | ||
|
||
session.run("entry_point", "--test", root_folder / "nox_ui.ipynb") | ||
|
||
test_notebooks = [root_folder / "nox_ui.ipynb"] | ||
|
||
for notebook in test_notebooks: | ||
with open(notebook) as ff: | ||
nb_in = nbformat.read(ff, nbformat.NO_CONVERT) | ||
|
||
print("Running notebook", notebook) | ||
|
||
try: | ||
ep = ExecutePreprocessor(timeout=600, kernel_name=f"test-{repo_name}") | ||
|
||
nb_out = ep.preprocess(nb_in) | ||
except Exception as e: | ||
print("########### Error running notebook", notebook) | ||
raise e | ||
|
||
|
||
@nox.session(reuse_venv=True) | ||
def jupyter(session): | ||
"""Run the application.""" | ||
session.install("-r", "requirements.txt") | ||
session.run("jupyter", "trust", "no_ui.ipynb") | ||
session.run("jupyter", "notebook", "no_ui.ipynb") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ GDAL==3.8.3 | |
tensorflow_probability | ||
tensorflow | ||
pandas | ||
rasterio | ||
rasterio | ||
|
||
# trigger build |