Skip to content

Commit

Permalink
Main pre release merge (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfguerrerom authored Aug 6, 2024
2 parents 29312c2 + 965da70 commit 8f37996
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 54 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/kaban.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Auto Assign to Project(s)
# name: Auto Assign to Project(s)

on:
issues:
types: [opened]
pull_request:
types: [opened]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# on:
# issues:
# types: [opened]
# pull_request:
# types: [opened]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
assign_one_project:
runs-on: ubuntu-latest
name: Assign to the kaban Project
steps:
- name: Assign NEW issues and NEW pull requests to kaban project
uses: srggrs/assign-one-project-github-action@1.2.1
if: github.event.action == 'opened'
with:
project: "https://github.com/12rambau/sepal_ui/projects/5"
# jobs:
# assign_one_project:
# runs-on: ubuntu-latest
# name: Assign to the kaban Project
# steps:
# - name: Assign NEW issues and NEW pull requests to kaban project
# uses: srggrs/assign-one-project-github-action@1.2.1
# if: github.event.action == 'opened'
# with:
# project: "https://github.com/12rambau/sepal_ui/projects/5"
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Install nox
run: python -m pip install nox
- name: test with pytest
run: nox -s test
run: nox -s test -- -vv
- name: codecov
uses: codecov/codecov-action@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ __pycache__/
*$py.class
*[Uu]ntitled*

.github/workflows/act_unit.yml

# C extensions
*.so

Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ repos:
- id: doc8
stages: [commit]

- repo: https://github.com/FHPythonUtils/LicenseCheck
rev: "2023.1.1"
hooks:
- id: licensecheck
stages: [commit]
# - repo: https://github.com/FHPythonUtils/LicenseCheck
# rev: "2023.1.1"
# hooks:
# - id: licensecheck
# stages: [commit]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
Expand Down
10 changes: 9 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
The nox run are build in isolated environment that will be stored in .nox. to force the venv update, remove the .nox/xxx folder.
"""


import nox

nox.options.sessions = ["lint", "test", "docs"]
Expand All @@ -20,6 +19,15 @@ def lint(session):
def test(session):
"""Run all the test using the environment variable of the running machine."""
session.install(".[test]")

# if we are in the sepal-venv, force earthengine api fork
if "sepal-user" in session.virtualenv.location:
session.run(
"pip",
"install",
"git+https://github.com/openforis/earthengine-api.git@v0.1.384#egg=earthengine-api&subdirectory=python",
)

test_files = session.posargs or ["tests"]
session.run("pytest", "--color=yes", "--cov", "--cov-report=xml", *test_files)

Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies = [
"geopandas",
"matplotlib",
"jupyter-server-proxy", # required for localtileserver
"planet>=2",
"planet<2.7",
"pyarrow",
"localtileserver>=0.7.0", # first pure rio version
"pygaul>=0.3.1", # use the class implementation
Expand Down Expand Up @@ -97,6 +97,7 @@ doc = [
"sphinxcontrib-autoprogram",
"sphinx-favicon>=1.0.1",
"tomli",
"lxml_html_clean",
]

[project.scripts]
Expand All @@ -107,6 +108,7 @@ module_theme = "sepal_ui.bin.module_theme:main"
module_venv = "sepal_ui.bin.module_venv:main"
activate_venv = "sepal_ui.bin.activate_venv:main"
sepal_ipyvuetify = "sepal_ui.bin.sepal_ipyvuetify:main"
entry_point = "sepal_ui.bin.entry_point:main"

[tool.setuptools]
include-package-data = false
Expand Down
65 changes: 65 additions & 0 deletions sepal_ui/bin/entry_point.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/python3

"""Script to rename the kernel of a notebook to a specific name."""

import argparse
import json
from pathlib import Path

from colorama import Fore, init

init()

# init parser
parser = argparse.ArgumentParser(description=__doc__, usage="entry_point")

parser.add_argument("file", help="UI file path")

# Add a optional argument
parser.add_argument("-t", "--test", help="Either test or not (production)", action="store_true")


def main() -> None:
"""Launch the venv creation process."""
# read arguments (there should be none)
args = parser.parse_args()

ui_file = args.file
test = args.test

# welcome the user
print(f"{Fore.YELLOW}UI renaming process{Fore.RESET}")

# check that the local folder is a module folder
ui_file = Path.cwd() / ui_file
if not ui_file.is_file():
raise Exception(f"{Fore.RED}This is not a module folder.")

entry_point = Path.cwd() / ui_file

# create the kernel from venv
prefix_name = "test-" if test else "venv-"
prefix_display = "(test) test-" if test else " (venv) "

name = f"{prefix_name}{Path.cwd().name}"
display_name = f"{prefix_display}{Path.cwd().name}"

# change the kernel of the entrypoint to use this one instead
with entry_point.open() as f:
data = json.load(f)

data["metadata"]["kernelspec"]["display_name"] = display_name
data["metadata"]["kernelspec"]["name"] = name

entry_point.write_text(json.dumps(data, indent=1))

# display last message to the end user
print(
f'{Fore.GREEN}The python kernel of {args.file} has been updated"{display_name}".{Fore.RESET}'
)

return


if __name__ == "__main__":
main()
57 changes: 49 additions & 8 deletions sepal_ui/bin/module_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@

# init parser
parser = argparse.ArgumentParser(description=__doc__, usage="module_venv")
parser.add_argument("--venv_prefix", default="test", help="Prefix for the virtual environment name")


def main() -> None:
"""Launch the venv creation process."""
# read arguments (there should be none)
parser.parse_args()
args = parser.parse_args()

# welcome the user
print(f"{Fore.YELLOW}venv creation interface{Fore.RESET}")
print(f"{Fore.YELLOW}venv creation interface v10{Fore.RESET}")

# check that the local folder is a module folder
ui_file = Path.cwd() / "ui.ipynb"
Expand Down Expand Up @@ -63,12 +64,52 @@ def main() -> None:
pip = current_dir_venv / "bin" / "pip"
python3 = current_dir_venv / "bin" / "python3"

for lib in ["wheel", "Cython", "ipykernel"]:
subprocess.run([str(pip), "install", lib], cwd=Path.cwd())
base_libs = ["wheel", "ipykernel", "numpy"]

# if we are in sepal, install earthengine-api OF fork

if "sepal-user" in str(Path.cwd()):
earthengine_api = "git+https://github.com/openforis/earthengine-api.git@v0.1.384#egg=earthengine-api&subdirectory=python"
base_libs.append(earthengine_api)

subprocess.run([str(pip), "install", "--upgrade", "pip"], cwd=Path.cwd())

for lib in base_libs:
subprocess.run([str(pip), "install", "--no-cache-dir", lib], cwd=Path.cwd())

# Default installation of GDAL
# If we are installing it as venv (usually in github actions) we need to install gdal as binary
gdal_version = "3.8.3"

# We assume we are in a github action runner if the path contains "home/runner/"
if "home/runner/" not in str(Path.cwd()):
subprocess.run(
[str(pip), "install", "--no-cache-dir", f"GDAL=={gdal_version}"], cwd=Path.cwd()
)
else:
subprocess.run(
[
str(pip),
"install",
"--no-cache-dir",
"--find-links=https://girder.github.io/large_image_wheels",
f"GDAL=={gdal_version}",
],
cwd=Path.cwd(),
)

# install all the requirements
req = Path.cwd() / "requirements.txt"
subprocess.run([str(pip), "install", "-r", str(req)], cwd=Path.cwd())
subprocess.run(
[
str(pip),
"install",
"--no-cache-dir",
"-r",
str(req),
],
cwd=Path.cwd(),
)

# search for the module.yaml file
# it embeds name and entry point
Expand All @@ -82,11 +123,11 @@ def main() -> None:

else:
entry_point = Path.cwd() / "ui.ipynb"
name = Path.cwd().stem
name = Path.cwd().name

# create the kernel from venv
name = f"test-{Path.cwd().stem}"
display_name = f"(test) {name}"
name = f"{args.venv_prefix}-{Path.cwd().name}"
display_name = f"({args.venv_prefix}) {name}"
subprocess.run(
[
str(python3),
Expand Down
1 change: 1 addition & 0 deletions sepal_ui/frontend/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ header.v-app-bar {
/* set the menu_content on top of the map when it's set to fullscreen */
.v-menu__content {
max-width: 100% !important;
z-index: 801 !important;
}

/* make sure navigation drawers are always visible when they exist */
Expand Down
18 changes: 14 additions & 4 deletions sepal_ui/message/en/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
"navdrawer": {
"code": "Source code",
"wiki": "Wiki",
"bug": "Bug report"
"bug": "Bug report",
"changelog": {
"version": "Version: {}",
"title": "Changelog",
"close_btn": "Close"
}
},
"asset_select": {
"types": {
Expand All @@ -37,7 +42,8 @@
"custom": "Custom",
"no_access": "It seems like you do not have access to the input asset or it does not exist.",
"wrong_type": "The type of the selected asset ({}) does not match authorized asset type ({}).",
"placeholder": "users/custom_user/custom_asset"
"placeholder": "projects/{project}/assets/asset_name",
"no_assets": "No user assets found in: '{}'"
},
"load_table": {
"too_small": "The provided file have less than 3 columns. Please provide a complete point file with at least ID, lattitude and longitude columns."
Expand Down Expand Up @@ -74,7 +80,8 @@
"no_draw": "Please draw a shape in the map",
"no_admlyr": "Select an administrative layer",
"invalid_code": "The code is not in the database",
"no_gdf": "You must set the gdf before interacting with it"
"no_gdf": "You must set the gdf before interacting with it",
"no_fc": "You have to select a feature collection first"
}
},
"mapping": {
Expand All @@ -85,13 +92,16 @@
"exception": {
"empty": "Please fill the required field(s).",
"invalid": "Invalid email or password",
"nosubs": "Your credentials do not have any valid planet subscription."
"nosubs": "Your credentials do not have any valid planet subscription.",
"no_secret_file": "The credentials file does not exist, use a different login method."
},
"widget": {
"username": "Planet username",
"password": "Planet password",
"apikey": "Planet API key",
"store": "Remember credentials file in the session.",
"method": {
"from_file": "From saved credentials",
"label": "Login method",
"credentials": "Credentials",
"api_key": "Planet API key"
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def gee_dir(_hash: str) -> Optional[Path]:
gdf = gpd.GeoDataFrame({"data": data, "geometry": centers}, crs=3857).to_crs(4326)
ee_gdf = ee.FeatureCollection(gdf.__geo_interface__)

image = ee.Image.random().multiply(4).byte()
image = ee.Image.random(42).multiply(4).byte()

lon = ee.Image.pixelLonLat().select("longitude")
lat = ee.Image.pixelLonLat().select("latitude")
Expand Down Expand Up @@ -181,7 +181,7 @@ def gee_dir(_hash: str) -> Optional[Path]:
yield gee_dir

# flush the directory and it's content
gee.delete_assets(str(gee_dir), False)
# gee.delete_assets(str(gee_dir), False)

return

Expand Down
8 changes: 4 additions & 4 deletions tests/test_aoi/test_AoiModel/test_total_bounds.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- 12.44577020563167
- 41.90021953934408
- 12.457671530175347
- 41.90667181034749
- 12.4458
- 41.9002
- 12.4458
- 41.9067
3 changes: 1 addition & 2 deletions tests/test_mapping/test_SepalMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import ee
import pytest
from ee.ee_exception import EEException
from ipyleaflet import GeoJSON

from sepal_ui import mapping as sm
Expand Down Expand Up @@ -191,7 +190,7 @@ def test_add_ee_layer_exceptions() -> None:
)
)

with pytest.raises(EEException):
with pytest.raises(TypeError):
map_.addLayer(geometry, {"invalid_propery": "red", "fillColor": None})

return
Expand Down
Loading

0 comments on commit 8f37996

Please sign in to comment.