Skip to content
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

Ecoscope 197 #245

Merged
merged 36 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4eb921d
test first iteration
davidovichmarcos Aug 5, 2024
493cc53
test pipeline remotely
davidovichmarcos Aug 9, 2024
302d173
Merge branch 'master' into ecoscope-197
davidovichmarcos Aug 9, 2024
407f784
fix indentation
davidovichmarcos Aug 9, 2024
61bc6c8
remove env
davidovichmarcos Aug 9, 2024
cece8c1
adding env var
davidovichmarcos Aug 9, 2024
7bcb4fb
adding var to env
davidovichmarcos Aug 12, 2024
8311989
test workflow directly
davidovichmarcos Aug 12, 2024
2f10c84
test
davidovichmarcos Aug 12, 2024
acad5ee
adding gcloud setup
davidovichmarcos Aug 13, 2024
d3f2fa2
change version
davidovichmarcos Aug 13, 2024
54a7bb7
fixes
davidovichmarcos Aug 13, 2024
dd48af0
moving deps to env file
davidovichmarcos Aug 14, 2024
a380655
test
davidovichmarcos Aug 14, 2024
ca25da1
fixes
davidovichmarcos Aug 14, 2024
b2211f9
Merge branch 'master' into ecoscope-197
davidovichmarcos Aug 14, 2024
921e3e9
skip test for other pipelines
davidovichmarcos Aug 14, 2024
a1e46ca
moving test to another folder
davidovichmarcos Aug 15, 2024
9522c0c
code review applied
davidovichmarcos Aug 16, 2024
614e80b
testing EE env vars
davidovichmarcos Aug 16, 2024
1b8daf1
fix dependency
davidovichmarcos Aug 16, 2024
b4ecb49
fix
davidovichmarcos Aug 16, 2024
0dcae8b
Merge branch 'master' into ecoscope-197
davidovichmarcos Aug 16, 2024
8802e4e
adding fail if EE is not setup
davidovichmarcos Aug 16, 2024
47a9eb5
adding pytest xdist
davidovichmarcos Aug 16, 2024
9337f0d
remove unused import
davidovichmarcos Aug 16, 2024
05d5dc1
rename file
davidovichmarcos Aug 16, 2024
f08bfa7
improve error handling
davidovichmarcos Aug 16, 2024
d346935
polishing code
davidovichmarcos Aug 16, 2024
56e985d
Update requirements-notebooks-test.txt
davidovichmarcos Aug 16, 2024
911b86d
fix error type
davidovichmarcos Aug 16, 2024
1922120
Merge remote-tracking branch 'origin/ecoscope-197' into ecoscope-197
davidovichmarcos Aug 16, 2024
c511f1a
adding errors
davidovichmarcos Aug 16, 2024
6a31d60
fixes
davidovichmarcos Aug 16, 2024
7f2136d
fix
davidovichmarcos Aug 16, 2024
6788e6c
fix
davidovichmarcos Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run tests
davidovichmarcos marked this conversation as resolved.
Show resolved Hide resolved
on:
push:
branches: [ "*" ]
davidovichmarcos marked this conversation as resolved.
Show resolved Hide resolved
env:
ER_USERNAME: ${{ secrets.ER_USERNAME }}
ER_PASSWORD: ${{ secrets.ER_PASSWORD }}
GCP_DATAFLOW_SERVICE_KEY: ${{ secrets.GCP_DATAFLOW_SERVICE_KEY }}
davidovichmarcos marked this conversation as resolved.
Show resolved Hide resolved

jobs:
run_unit_tests:
runs-on: ubuntu-latest
steps:
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_DATAFLOW_SERVICE_KEY }}'
davidovichmarcos marked this conversation as resolved.
Show resolved Hide resolved
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Checkout branch
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install pip
run: python -m ensurepip --upgrade
- name: Install dependencies
run: pip install -r requirements-notebooks-test.txt
- name: Use the kernel
run: python -m ipykernel install --user --name=venv
- name: Run unit tests
run: pytest nb-tests/test_notebooks.py -s
env:
ER_USERNAME: ${{ secrets.ER_USERNAME }}
ER_PASSWORD: ${{ secrets.ER_PASSWORD }}
GCP_DATAFLOW_SERVICE_KEY: ${{ secrets.GCP_DATAFLOW_SERVICE_KEY }}
davidovichmarcos marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
pytest -v -r s --color=yes --cov=ecoscope --cov-append --cov-report=xml

- name: Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v4
57 changes: 57 additions & 0 deletions nb-tests/test_notebooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os
import pathlib
from dataclasses import dataclass
import papermill
from papermill.execute import PapermillExecutionError
import pytest


NB_DIR = pathlib.Path(__file__).parent.parent / "doc" / "source" / "notebooks"

KNOWN_ERRORS_REGEXES = { # This is basically a GitHub ticket queue
"EarthRanger_IO.ipynb": "Series found",
"GEE_IO.ipynb": "frontend does not support input requests", # This error only happens in the ci pipeline
"EcoMap.ipynb": "frontend does not support input requests", # This error only happens in the ci pipeline
"Remote Sensing Time Series Anomaly.ipynb": "frontend does not support input requests", # This error only happens in the ci pipeline
davidovichmarcos marked this conversation as resolved.
Show resolved Hide resolved
"Relocations_and_Trajectories.ipynb": "not a zip file",
"EcoGraph.ipynb": "not a zip file",
"EcoPlot.ipynb": "not a zip file",
"Landscape Grid.ipynb": "not a zip file",
"Seasonal Calculation.ipynb": "buffer source array is read-only",
"Tracking Data Gantt Chart.ipynb": "not a zip file",
}
class UnexecptedNotebookExecutionError(Exception):
pass

@dataclass
class Notebook:
path: pathlib.Path
raises: bool = False
raises_match: str = None


ALL_NOTEBOOKS = [
Notebook(
path=p,
raises=False if not p.name in KNOWN_ERRORS_REGEXES else True,
raises_match=KNOWN_ERRORS_REGEXES.get(p.name),
)
for p in NB_DIR.rglob("*.ipynb")
]

@pytest.mark.parametrize(
"notebook",
ALL_NOTEBOOKS,
ids=[nb.path.name for nb in ALL_NOTEBOOKS],
)
def test_notebooks(notebook: Notebook):
try:
papermill.execute_notebook(str(notebook.path), "./output.ipynb", kernel_name="venv")
except Exception as e:
if notebook.raises: # these are the ones we expect to raise errors
pytest.xfail(f"Notebook {notebook.path} is known to fail with error {notebook.raises_match}")
else:
raise UnexecptedNotebookExecutionError(
f"{notebook.path.name=} not in {list(KNOWN_ERRORS_REGEXES)= } but execution errored. "
"This notebook is unexpectedly broken."
) from e
7 changes: 7 additions & 0 deletions requirements-notebooks-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pip-tools
pytest
papermill
folium
branca
davidovichmarcos marked this conversation as resolved.
Show resolved Hide resolved
ecoscope[all]
ipykernel
Loading