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

Deprecate #71

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 0 additions & 57 deletions component/model/fad_model.py

This file was deleted.

49 changes: 0 additions & 49 deletions component/model/p223_model.py

This file was deleted.

29 changes: 29 additions & 0 deletions component/tile/deprecated_tile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import json
import shutil

from sepal_ui import sepalwidgets as sw
from sepal_ui.scripts import utils as su
import ipyvuetify as v

from component.message import cm
from component import parameter as cp
from component import widget as cw
from component import scripts as cs

from .gwb_tile import GwbTile


class DeprecatedTile(sw.Tile):
def __init__(self, tile_id):
alert = sw.Alert().show()
markdown = sw.Markdown(
f"The module {tile_id} has been deprecated. For details and alternatives, please view <a href='https://ies-ows.jrc.ec.europa.eu/gtb/GWB/GWB_changelog.txt' target='_blank'>the changelog</a>."
)
alert.add_msg(markdown, "info")
inputs = [alert]

super().__init__(
tile_id,
title="Deprecated process",
inputs=inputs,
)
66 changes: 4 additions & 62 deletions component/tile/fad_tile.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,6 @@
import json
import shutil
from .deprecated_tile import DeprecatedTile

from sepal_ui import sepalwidgets as sw
from sepal_ui.scripts import utils as su
import ipyvuetify as v

from component.message import cm
from component import parameter as cp
from component import widget as cw
from component import scripts as cs

from .gwb_tile import GwbTile


class FadTile(GwbTile):
def __init__(self, model):

# create the widgets
connectivity = v.Select(
label=cm.acc.connectivity,
items=cp.connectivity,
v_model=cp.connectivity[0]["value"],
)
prescision = v.Select(
label=cm.fad.prescision,
items=cp.prescision,
v_model=cp.prescision[0]["value"],
)
options = v.Select(
label=cm.acc.options,
items=cp.fad_options,
v_model=cp.fad_options[0]["value"],
)

# bind to the io
(
model.bind(connectivity, "connectivity")
.bind(prescision, "prescision")
.bind(options, "options")
)

super().__init__(
model=model,
inputs=[connectivity, prescision, options],
)

@su.loading_button()
def _on_click(self, widget, event, data):

# check inputs
if not all(
[
self.alert.check_input(self.model.connectivity, cm.acc.no_connex),
self.alert.check_input(self.model.prescision, cm.fad.no_prescision),
self.alert.check_input(self.model.options, cm.acc.no_options),
self.alert.check_input(self.model.bin_map, cm.bin.no_bin),
]
):
return

super()._on_click(widget, event, data)

return
class FadTile(DeprecatedTile):
def __init__(self):
super().__init__("fad_tile")
31 changes: 14 additions & 17 deletions component/tile/landing_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
tiles = {
"acc": {"title": "Accounting of image objects and areas", "desc": "some desc"},
"dist": {"title": "Euclidean Distance", "desc": "some desc"},
"fad": {"title": "Forest Area Density", "desc": "some desc"},
"frag": {"title": "Fragmentation", "desc": "some desc"},
"lm": {"title": "Landscape Mosaic", "desc": "some desc"},
"mspa": {"title": "Morphological Spatial Pattern Analysis", "desc": "some desc"},
"p223": {
"title": "Density (P2), Contagion (P22) or or FG-Adjacency (P23)",
"desc": "some desc",
},
"parc": {"title": "Parcellation", "desc": "some desc"},
"rss": {"title": "Restoration Status Summary", "desc": "some desc"},
"spa": {"title": "Simplified Pattern Analysis", "desc": "some desc"},
"reclassify": {"title": "Reclassify local rasters", "desc": "some desc"},
"fad": {"title": "Forest Area Density", "desc": "some desc"},
"p223": {
"title": "Density (P2), Contagion (P22) or or FG-Adjacency (P23)",
"desc": "some desc",
},
}


Expand Down Expand Up @@ -75,12 +75,11 @@ def load_element(self, tile_id):
process = tile.DistTile(model)

elif tile_id == "fad":
model = models.FadModel()
title = sw.Tile(
model.tile_id, cm.fad.title, [sw.Markdown(cm.fad.description)]
)
convert = tile.ConvertByte(model, 4)
process = tile.FadTile(model)
process = tile.FadTile()
self.built_tiles[tile_id] = [process]
self.card_content.children = [process]
return

elif tile_id == "frag":
model = models.FragModel()
title = sw.Tile(
Expand All @@ -106,12 +105,10 @@ def load_element(self, tile_id):
process = tile.MspaTile(model)

elif tile_id == "p223":
model = models.P223Model()
title = sw.Tile(
model.tile_id, cm.p223.title, [sw.Markdown(cm.p223.description)]
)
convert = tile.ConvertByte(model, 5)
process = tile.P223Tile(model)
process = tile.P223Tile()
self.built_tiles[tile_id] = [process]
self.card_content.children = [process]
return

elif tile_id == "parc":
model = models.ParcModel()
Expand Down
83 changes: 4 additions & 79 deletions component/tile/p223_tile.py
Original file line number Diff line number Diff line change
@@ -1,81 +1,6 @@
import json
import shutil
from .deprecated_tile import DeprecatedTile

from sepal_ui import sepalwidgets as sw
from sepal_ui.scripts import utils as su
import ipyvuetify as v

from component.message import cm
from component import parameter as cp
from component import widget as cw
from component import scripts as cs

from .gwb_tile import GwbTile


class P223Tile(GwbTile):
def __init__(self, model):

# create the widgets
algorithm = v.Select(
label=cm.p223.algo, items=cp.algo, v_model=cp.algo[0]["value"]
)
kdim = v.TextField(
label=cm.lm.kdim, type="number", hint=cm.frag.invalid_window, v_model=None
)
prescision = v.Select(
label=cm.fad.prescision,
items=cp.prescision,
v_model=cp.prescision[0]["value"],
)

# bind to the io
(
model.bind(algorithm, "algorithm")
.bind(kdim, "kdim")
.bind(prescision, "prescision")
)

# create extra js behaviour
kdim.on_event("focusout", self._on_focusout)

super().__init__(
model=model,
inputs=[
algorithm,
kdim,
prescision,
],
)

@su.loading_button()
def _on_click(self, widget, event, data):

# check inputs
if not all(
[
self.alert.check_input(self.model.kdim, cm.lm.no_kdim),
self.alert.check_input(self.model.bin_map, cm.bin.no_bin),
]
):
return

super()._on_click(widget, event, data)

return

def _on_focusout(self, widget, event, data):

# clear the error message
widget.error_messages = None

# check if an input exist
if not widget.v_model:
return self

# test the value over the limits
if not cs.is_valid_window(widget.v_model):
widget.v_model = False
widget.error_messages = [cm.frag.invalid_window]

return self
class P223Tile(DeprecatedTile):
def __init__(self):
super().__init__("p223_tile")
Loading