Skip to content

Commit d83da74

Browse files
UV setup (#5)
* Enhance documentation and setup instructions in README and CONTRIBUTING files; add .gitignore and pyproject.toml for project configuration and dependency management. * Notebook for BAIS2 (#4) * readme and contrib initial commit. * Add attribution section to NDCI cyanobacteria detection notebook * Specifies how to install virtual environment * Adds files to ignore * Processes BAIS2 evalscript with openEO * Adds requirement file * Removes unused libraries * Removes UDP print * Updates text-based math formulae with latex --------- Co-authored-by: Emmanuel Mathot <[email protected]> * Enhance documentation and setup instructions in README and CONTRIBUTING files; add .gitignore and pyproject.toml for project configuration and dependency management. * Update .gitignore to include additional environment and temporary file exclusions --------- Co-authored-by: Firza Riany <[email protected]>
1 parent 235ed06 commit d83da74

File tree

3 files changed

+233
-16
lines changed

3 files changed

+233
-16
lines changed

CONTRIBUTING.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,95 @@
22

33
Thank you for your interest in contributing to the Sentinel Hub evalscript to openEO conversion project! This guide will help you understand our conversion process and standards so your contributions can be integrated smoothly.
44

5+
## Getting Started
6+
7+
### Development Environment Setup
8+
9+
Before you begin converting evalscripts, set up your development environment properly:
10+
11+
#### Prerequisites
12+
13+
- Python 3.11 or later
14+
- [uv](https://docs.astral.sh/uv/) for dependency management
15+
- Git for version control
16+
- Access to an openEO backend for testing
17+
18+
#### Environment Setup
19+
20+
1. **Install uv** if you haven't already:
21+
```bash
22+
# On macOS and Linux
23+
curl -LsSf https://astral.sh/uv/install.sh | sh
24+
25+
# On Windows
26+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
27+
```
28+
29+
2. **Fork and clone the repository**:
30+
```bash
31+
git clone https://github.com/your-username/openeo-udp.git
32+
cd openeo-udp
33+
```
34+
35+
3. **Set up the development environment**:
36+
```bash
37+
# Create virtual environment and install all dependencies
38+
uv sync
39+
40+
# Install development dependencies (for linting, testing)
41+
uv sync --group dev
42+
43+
# Install as Jupyter kernel for notebook development
44+
uv run python -m ipykernel install --user --name openeo-udp-dev --display-name "openEO UDP (Dev)"
45+
```
46+
47+
#### Jupyter Kernel Management
48+
49+
After installation, you should have the "openEO UDP (Dev)" kernel available in Jupyter. When creating or opening notebooks:
50+
51+
- Ensure you select the correct kernel
52+
- Verify the kernel has access to all required packages
53+
- Test the openEO connection in the first cell
54+
55+
### Working with the Development Environment
56+
57+
- **Starting Jupyter**: Use `uv run jupyter lab` or `uv run jupyter notebook`
58+
- **Running tests**: Use `uv run pytest`
59+
- **Code formatting**: Use `uv run black .`
60+
- **Linting**: Use `uv run ruff check .`
61+
- **Installing new packages**: Use `uv add package-name`
62+
- **Running any Python script**: Use `uv run python script.py`
63+
64+
#### Verifying Your Environment
65+
66+
Before starting development, verify your environment is set up correctly:
67+
68+
1. **Test Python and package availability**:
69+
```bash
70+
uv run python -c "
71+
import openeo
72+
import matplotlib.pyplot as plt
73+
import numpy as np
74+
from PIL import Image
75+
print('All packages imported successfully!')
76+
"
77+
```
78+
79+
2. **Test openEO connection** (optional, requires backend access):
80+
```bash
81+
uv run python -c "
82+
import openeo
83+
connection = openeo.connect('https://openeo.ds.io/')
84+
print('OpenEO connection successful!')
85+
"
86+
```
87+
88+
3. **Check Jupyter kernel**:
89+
- Launch Jupyter: `uv run jupyter lab`
90+
- Create a new notebook
91+
- Ensure "openEO UDP (Dev)" kernel is available and selected
92+
- Run the import test from step 1
93+
594
## Understanding the Conversion Process
695

796
Converting a Sentinel Hub evalscript to an openEO User-Defined Process involves more than simple translation. You need to understand both what the algorithm does scientifically and how to express that logic using openEO's process graph structure.

README.md

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,39 +88,62 @@ Each notebook concludes with proper attribution to the original evalscript autho
8888
To run these notebooks, you need:
8989

9090
- Python 3.11 or later
91-
- Jupyter Notebook or JupyterLab
91+
- [uv](https://docs.astral.sh/uv/) for fast and reliable dependency management
9292
- Access to an openEO backend (we recommend https://openeo.ds.io/ for testing)
9393
- Basic understanding of remote sensing concepts and Python programming
9494

95-
### Installation
95+
### Environment Setup
9696

97-
Clone the repository and install the required dependencies:
97+
This project uses [uv](https://docs.astral.sh/uv/) for fast and reliable dependency management.
9898

99-
```bash
100-
git clone https://github.com/developmentseed/openeo-udp.git
101-
cd openeo-udp
99+
1. **Install uv** if you haven't already:
102100

103-
# Create a virtual environment
104-
python -m venv .venv
101+
```bash
102+
# On macOS and Linux
103+
curl -LsSf https://astral.sh/uv/install.sh | sh
105104

106-
# Activate the virtual environment
107-
source .venv/bin/activate
105+
# On Windows
106+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
107+
```
108108

109-
# Install requirements
110-
pip install -r requirements.txt
111-
```
109+
2. **Clone the repository and set up the environment**:
110+
111+
```bash
112+
git clone https://github.com/developmentseed/openeo-udp.git
113+
cd openeo-udp
114+
115+
# Create virtual environment and install all dependencies
116+
uv sync
117+
```
112118

113-
The requirements file includes the openEO Python client library, visualization tools like matplotlib and Pillow, and any specialized processing libraries needed for specific algorithms.
119+
3. **Install as Jupyter kernel** (recommended for running notebooks):
120+
121+
```bash
122+
# Install the environment as a Jupyter kernel
123+
uv run python -m ipykernel install --user --name openeo-udp --display-name "openEO UDP"
124+
```
125+
126+
The environment includes the openEO Python client library, visualization tools like matplotlib and Pillow, Jupyter, and all other dependencies needed to run the notebooks.
114127

115128
### Running a Notebook
116129

117130
Start Jupyter and open any notebook. For example, the [NDCI cyanobacteria notebook](notebooks/sentinel/sentinel-2/marine_and_water_bodies/ndci_cyanobacteria.ipynb):
118131

119132
```bash
120-
jupyter notebook notebooks/sentinel/sentinel-2/marine_and_water_bodies/ndci_cyanobacteria.ipynb
133+
# Start Jupyter using uv
134+
uv run jupyter lab
135+
136+
# Or start Jupyter Notebook
137+
uv run jupyter notebook
121138
```
122139

123-
Execute the cells sequentially to see the conversion process, validate results, and export the UDP definition. Most notebooks are designed to run completely from top to bottom without modification, though you may want to adjust spatial extents or temporal ranges to explore different areas.
140+
When creating or opening a notebook:
141+
142+
1. Make sure the "openEO UDP" kernel is selected (if you installed it as a kernel)
143+
2. Open the [NDCI cyanobacteria notebook](notebooks/sentinel/sentinel-2/marine_and_water_bodies/ndci_cyanobacteria.ipynb)
144+
3. Execute the cells sequentially to see the conversion process, validate results, and export the UDP definition
145+
146+
Most notebooks are designed to run completely from top to bottom without modification, though you may want to adjust spatial extents or temporal ranges to explore different areas.
124147

125148
## Using the Exported UDPs
126149

pyproject.toml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "openeo-udp"
7+
description = "openEO User-Defined Processes converted from Sentinel Hub evalscripts"
8+
readme = "README.md"
9+
license = {text = "Apache-2.0"}
10+
authors = [
11+
{name = "Development Seed", email = "[email protected]"},
12+
]
13+
classifiers = [
14+
"Development Status :: 4 - Beta",
15+
"Intended Audience :: Science/Research",
16+
"License :: OSI Approved :: Apache Software License",
17+
"Operating System :: OS Independent",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"Topic :: Scientific/Engineering :: GIS",
22+
]
23+
requires-python = ">=3.11"
24+
dependencies = [
25+
"openeo>=0.24.0",
26+
"matplotlib>=3.7.0",
27+
"Pillow>=10.0.0",
28+
"numpy>=1.24.0",
29+
"jupyter>=1.0.0",
30+
"ipykernel>=6.25.0",
31+
"requests>=2.28.0",
32+
]
33+
34+
[project.optional-dependencies]
35+
dev = [
36+
"pytest>=7.0.0",
37+
"pytest-cov>=4.0.0",
38+
"black>=23.0.0",
39+
"ruff>=0.0.290",
40+
"pre-commit>=3.0.0",
41+
]
42+
docs = [
43+
"mkdocs>=1.5.0",
44+
"mkdocs-material>=9.0.0",
45+
"mkdocstrings[python]>=0.23.0",
46+
]
47+
48+
[project.urls]
49+
Homepage = "https://github.com/developmentseed/openeo-udp"
50+
Documentation = "https://github.com/developmentseed/openeo-udp"
51+
Repository = "https://github.com/developmentseed/openeo-udp"
52+
"Bug Tracker" = "https://github.com/developmentseed/openeo-udp/issues"
53+
54+
[tool.setuptools.packages.find]
55+
where = ["src"]
56+
57+
[tool.setuptools.package-dir]
58+
"" = "src"
59+
60+
[tool.black]
61+
line-length = 88
62+
target-version = ['py311']
63+
include = '\.pyi?$'
64+
extend-exclude = '''
65+
/(
66+
# directories
67+
\.eggs
68+
| \.git
69+
| \.hg
70+
| \.mypy_cache
71+
| \.tox
72+
| \.venv
73+
| _build
74+
| buck-out
75+
| build
76+
| dist
77+
)/
78+
'''
79+
80+
[tool.ruff]
81+
target-version = "py311"
82+
line-length = 88
83+
select = [
84+
"E", # pycodestyle errors
85+
"W", # pycodestyle warnings
86+
"F", # pyflakes
87+
"I", # isort
88+
"C", # flake8-comprehensions
89+
"B", # flake8-bugbear
90+
]
91+
ignore = [
92+
"E501", # line too long, handled by black
93+
"B008", # do not perform function calls in argument defaults
94+
"C901", # too complex
95+
]
96+
97+
[tool.pytest.ini_options]
98+
testpaths = ["tests"]
99+
python_files = ["test_*.py"]
100+
python_functions = ["test_*"]
101+
addopts = "-v --tb=short --strict-markers"
102+
markers = [
103+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
104+
"integration: marks tests as integration tests",
105+
]

0 commit comments

Comments
 (0)