Skip to content

Commit

Permalink
Merge pull request #43 from sepal-contrib/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
12rambau authored May 15, 2023
2 parents f35f95d + cfa9b23 commit a32efa4
Show file tree
Hide file tree
Showing 59 changed files with 961 additions and 793 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Unit testing

on:
- push
- workflow_dispatch

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- uses: pre-commit/[email protected]
- name: install dependencies
run: python -m pip install -r requirements.txt
- name: build the application
run: |
python -m pip install pytest nbmake
pytest --nbmake ui.ipynb
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#custom
parameters.py
planet.key
utils/planet_grid.geojson

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*[Uu]ntitled*

# C extensions
*.so
Expand Down
34 changes: 25 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
default_language_version:
python: python3
default_install_hook_types: [pre-commit]

repos:
- repo: https://github.com/psf/black
rev: 8a59528c2d8ae1ef5f366039c728614aaf1a470b
- repo: "https://github.com/psf/black"
rev: "22.3.0"
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/kynan/nbstripout
rev: 0.5.0
- id: black
stages: [commit]
- id: black-jupyter
stages: [commit]

- repo: "https://github.com/kynan/nbstripout"
rev: "0.5.0"
hooks:
- id: nbstripout
stages: [commit]

- repo: "https://github.com/pre-commit/mirrors-prettier"
rev: "v2.7.1"
hooks:
- id: prettier
stages: [commit]
exclude: "CHANGELOG.md"

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.215"
hooks:
- id: nbstripout
- id: ruff
stages: [commit]
35 changes: 0 additions & 35 deletions CONTRIBUTE.md

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ This dasboard application based on the [sepal-ui](https://sepal-ui.readthedocs.i

More information on usage can be found in the [doc](https://docs.sepal.io/en/latest/modules/dwn/planet_order.html)


## Contribute

first download the repository to your own sepal account
first download the repository to your own sepal account

```
git clone https://github.com/12rambau/planet-order.git
```

In the `planet-order` folder, copy paste the `planet.key.dist` file and remove the `.dist` extention
In the `planet-order` folder, copy paste the `planet.key.dist` file and remove the `.dist` extention

```
cp planet.key.dist planet.key
```

You'll need to change the values of the parameters according to your needs.
You'll need to change the values of the parameters according to your needs.

- **ThisIsNotAKey**: Your personal key to access the planet API

> :warning: The key that leaves in the `planet.key` file is used as the default key of the module. You can skip this step and use the key TextField to use your personnal.
Expand Down
6 changes: 5 additions & 1 deletion component/message/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import os
"""Creation of the Translator object associated with the application.
Can be accessed via the foolowing code: ``from component.message import cm``
"""

from pathlib import Path

from sepal_ui.translator import Translator
Expand Down
5 changes: 5 additions & 0 deletions component/message/en/aoi_control.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"aoi_control": {
"title": "Select AOI"
}
}
12 changes: 12 additions & 0 deletions component/message/en/down_control.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"down_control": {
"title": "Download images",
"btn": "Download",
"error": {
"no_aoi": "Select an aoi first"
},
"process": {
"loading_grid": "Loading the PLANET grid"
}
}
}
7 changes: 7 additions & 0 deletions component/message/en/dynamic_select.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dynamic_select": {
"prev": "prev",
"next": "next",
"label": "Select mosaic"
}
}
62 changes: 10 additions & 52 deletions component/message/en/locale.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,12 @@
{
"app": {
"title": "Planet ordering module",
"drawer_item": {
"aoi": "AOI selection",
"retrieve": "Retrieve images",
"about": "About"
}
},
"key": {
"password": {
"label": "API key",
"error_msg": "You cannot expose the default API key"
}
},
"dynamic_select": {
"prev": "prev",
"next": "next",
"label": "Select mosaic"
},
"planet": {
"title": "Explore planet data",
"btn": {
"check": "Check API key",
"download": "Download images"
},
"key": {
"invalid": "The current key is invalid, please provide a valid Planet key",
"test": "We are currently checking your API key",
"valid": "Your key have been validated"
},
"mosaic": {
"load": "We are retrieving the mosaics list",
"complete": "The list of mosaic is available in the Mosaic selector"
},
"down": {
"start": "exporting planet tiles",
"progress": "Images downloaded to Sepal",
"not_found": "Image {} not found",
"done": "Image {} downloaded to SEPAL",
"end": "Out of {} requested images, {} have been downloaded, {} skipped and {} failed",
"exist": "The image {} already exist in your sepal directory, aborting",
"no_access": "You don't have the right access to download this resource",
"view_only": "At least one of the missing tile was not downloaded because you don't have the right access to download the resources. Please see the module documentation or your Planet Lab profile to check their availability."
}
},
"map": {
"aoi": "loading aoi",
"grid": "generating planet grid",
"tiles": "loading tiles",
"done": "loading complete",
"aoi_border": "AOI border"
"app": {
"title": "Planet ordering module"
},
"planet": {
"down": {
"start": "exporting Planet tiles",
"progress": "Images downloaded",
"end": "Out of {} requested images, {} have been downloaded, {} skipped and {} failed"
}
}
}
}
48 changes: 48 additions & 0 deletions component/message/test_translation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import os\n",
"\n",
"sys.path.insert(0, os.path.abspath(\"../\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from message import cm\n",
"\n",
"cm.key_use(os.path.abspath(\"../../\"), \"cm\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "app",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
6 changes: 6 additions & 0 deletions component/model/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
"""Module to gather all the models from the application.
If you only have few widgets, a module is not necessary and you can simply use a model.py file
In a big module with lot of custom models, it can make sense to split things in separate files for the sake of maintenance.
If you use a module import all the functions here to only have 1 call to make
"""
from .order_model import *
10 changes: 9 additions & 1 deletion component/model/order_model.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
"""Model to order basemaps to NICFI."""

from sepal_ui import model
from traitlets import Any
from traitlets import Any, Unicode


class OrderModel(model.Model):

mosaic = Unicode("").tag(sync=True)
"the current mosaic name"

color = Unicode("rgb").tag(sync=True)
"the slected color"

order_index = Any(None).tag(sync=True)
orders = Any(None).tag(sync=True)
session = Any(None).tag(sync=True)
Expand Down
5 changes: 5 additions & 0 deletions component/parameter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
"""module to gather all the parameters used in the application.
if you only have few widgets, a module is not necessary and you can simply use a parameter.py file. Iin a big module with lot of custom parmeters, it can make sense to split things in separate files for the sake of maintenance.
If you use a module import all the functions here to only have 1 call to make
"""
from .directory import *
from .planet import *
18 changes: 9 additions & 9 deletions component/parameter/directory.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
"""All directories used in the application."""

from pathlib import Path

# module directory
module_dir = Path("~", "module_results").expanduser()
module_dir = Path.home() / "module_results"
module_dir.mkdir(exist_ok=True)

# result_dir
result_dir = module_dir.joinpath("planet-order")
result_dir = module_dir / "planet-order"
result_dir.mkdir(exist_ok=True)


def get_aoi_dir(aoi_name):
"""get the result dir associated with the aoi name"""

aoi_dir = result_dir.joinpath(aoi_name)
def get_aoi_dir(aoi_name: str) -> Path:
"""Returns the directory associated with the aoi_name."""
aoi_dir = result_dir / aoi_name
aoi_dir.mkdir(exist_ok=True)

return aoi_dir


def get_mosaic_dir(aoi_name, mosaic_name):
"""get the result dir associated with the mosaic name"""

"""Get the result dir associated with the mosaic name."""
aoi_dir = get_aoi_dir(aoi_name)
mosaic_dir = aoi_dir.joinpath(mosaic_name)
mosaic_dir = aoi_dir / mosaic_name
mosaic_dir.mkdir(exist_ok=True)

return mosaic_dir
3 changes: 2 additions & 1 deletion component/parameter/planet.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Planet related parameters."""

from pathlib import Path

default_planet_key = None
Expand All @@ -10,7 +12,6 @@
default_planet_key = f.read().strip()

planet_colors = [
"visual",
"rgb",
"cir",
"ndvi",
Expand Down
10 changes: 9 additions & 1 deletion component/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
from .planet import *
"""Module to gather all scripts of the application.
If you only have few widgets, a module is not necessary and you can simply use a scripts.py file
In a big module with lot of custom scripts, it can make sense to split things in separate files for the sake of maintenance
If you use a module import all the functions here to only have 1 call to make
"""

from .mapping import *
from .planet import *
Loading

0 comments on commit a32efa4

Please sign in to comment.