Skip to content

Commit

Permalink
Merge branch 'main' into rioxarray
Browse files Browse the repository at this point in the history
  • Loading branch information
dfguerrerom committed Sep 12, 2024
2 parents f3092fc + 342f002 commit 3add31d
Show file tree
Hide file tree
Showing 39 changed files with 433 additions and 99 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/kaban.yml

This file was deleted.

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
25 changes: 25 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,28 @@ We are using :code:`api-doc` to build the documentation of the lib so if you wan
sphinx-apidoc --force --module-first --templatedir=docs/source/_templates/apidoc -o docs/source/modules
You can then build the documentation, it will automatically call :code:`autodoc` and :code:`autosummary` during the process.


Test the workflows locally
--------------------------

Test your locally your workflows using `Act <https://github.com/nektos/act>`_.

To pass your secrets to the workflows, create a `secrets.env` file and store the secrets of your custom workflow, for example:

.. code-block:: console
EARTHENGINE_TOKEN=""
PLANET_API_CREDENTIALS=""
PLANET_API_KEY=""
FIRMS_API_KEY=""
EARTHENGINE_SERVICE_ACCOUNT=""
Then run the following command:

.. code-block:: console
$ gh act --secret-file $ENV_FILE --workflows .github/workflows/unit.yml
You can change the workflow file to test the one you want, if you are only interested in testing some specific jobs, you can use the `--job` flag.

4 changes: 0 additions & 4 deletions docs/source/changelog.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ Meet our :doc:`contributor <./start/authors>`.
widgets/index
API Content <modules/sepal_ui>
cli/index
changelog
9 changes: 9 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,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
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "sepal-ui"
version = "2.17.0"
version = "2.20.0"
description = "Wrapper for ipyvuetify widgets to unify the display of voila dashboards in SEPAL platform"
keywords = ["UI", "Python", "widget", "sepal"]
classifiers = [
Expand Down Expand Up @@ -36,7 +36,7 @@ dependencies = [
"geopandas",
"matplotlib",
"jupyter-server-proxy", # required for localtileserver
"planet>=2",
"planet",
"pyarrow",
"localtileserver>=0.7.0", # first pure rio version
"pygaul>=0.3.1", # use the class implementation
Expand Down Expand Up @@ -88,7 +88,7 @@ test = [
"tomli",
]
doc = [
"sphinx<7",
"sphinx @ git+https://github.com/sphinx-doc/sphinx.git",
"jupyter-sphinx",
"pydata-sphinx-theme",
"sphinx-notfound-page",
Expand All @@ -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 All @@ -129,7 +131,7 @@ changelog_file = "CHANGELOG.md"
changelog_incremental = true
tag_format = "v$major.$minor.$patch$prerelease"
update_changelog_on_bump = false
version = "2.17.0"
version = "2.20.0"
version_files = [
"pyproject.toml:version",
"sepal_ui/__init__.py:__version__"
Expand Down
2 changes: 1 addition & 1 deletion sepal_ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

__author__ = """Pierrick Rambaud"""
__email__ = "pierrick.rambaud49@gmail.com"
__version__ = "2.17.0"
__version__ = "2.20.0"

color = SepalColor()
'color: the colors of sepal. members are in the following list: "main, darker, bg, primary, accent, secondary, success, info, warning, error, menu". They will render according to the selected theme.'
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
6 changes: 6 additions & 0 deletions sepal_ui/message/ar-SA/decorator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"decorator": {
"no_alert": "",
"no_button": ""
}
}
Loading

0 comments on commit 3add31d

Please sign in to comment.