Skip to content

Commit

Permalink
Merge pull request #57 from Deltares-research/feature/flet-frontend
Browse files Browse the repository at this point in the history
Add Flet app package
  • Loading branch information
kordejong authored Jan 17, 2025
2 parents d9185fd + a7bfc3d commit 8c58c89
Show file tree
Hide file tree
Showing 105 changed files with 3,484 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
matrix:
python_version: ["3.12"]
platform:
- { os: "ubuntu-22.04", arch: x64 }
- { os: "ubuntu-24.04", arch: x64 }
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
platform:
- { os: "macos-14", arch: arm64 }
- { os: "macos-13", arch: x64 }
- { os: "ubuntu-22.04", arch: x64 }
- { os: "ubuntu-24.04", arch: x64 }
- { os: "windows-2022", arch: x64 }
steps:
- name: Setup Linux platform
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.venv
build/
env/
**/__pycache__/
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: '\.svg$'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ project(AdaptationPathways
HOMEPAGE_URL "https://publicwiki.deltares.nl/display/AP/Adaptation+Pathways"
)

set(AP_COPYRIGHT "2025 by TODO")
string(JOIN ", " AP_AUTHORS
# TODO Add everybody, in some order (alphabet?)
"Kor de Jong (Geoneric, NL)"
"Marjolijn Haasnoot (Deltares, NL)"
"Willem van Deursen (Carthago Consultancy, NL)"
)

enable_testing()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/environment/cmake)
Expand Down
Binary file added datasets/test-dataset.apw
Binary file not shown.
2 changes: 1 addition & 1 deletion documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ add_custom_target(apidoc
--module-first
-d 1
-o ${CMAKE_CURRENT_BINARY_DIR}/api
${PROJECT_SOURCE_DIR}/source/package/adaptation_pathways
${PROJECT_SOURCE_DIR}/source/package
)

# https://www.sphinx-doc.org/en/master/man/sphinx-build.html
Expand Down
11 changes: 2 additions & 9 deletions documentation/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,8 @@ import re
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "@CMAKE_PROJECT_NAME@"
copyright = "2024, TODO"
author = ", ".join(
[
# TODO Add everybody
"Marjolijn Haasnoot (Deltares, NL)",
"Willem van Deursen (Carthago Consultancy, NL)",
"Kor de Jong (Geoneric, NL)",
]
)
copyright = "@AP_COPYRIGHT@"
author = "@AP_AUTHORS@"
version = "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@"

# -- General configuration ---------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions environment/configuration/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build
cairosvg
cmake
flet>=0.25.1
furo
linkchecker
ninja
Expand Down
3 changes: 3 additions & 0 deletions mockup/images/Action Outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mockup/images/deltares-logo-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions mockup/images/deltares-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions mockup/images/icon_line-chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ sections = "FUTURE,STDLIB,THIRDPARTY,AP,FIRSTPARTY,LOCALFOLDER"
profile = "black"

[tool.pylint]
disable = "C0103, C0114, C0115, C0116, C0302, E0401, W0212, W0511, R0801"
max-line-length=240
disable = "C0103, C0114, C0115, C0116, C0302, E0401, W0212, W0511, R0801, R0902, R0903, R0913, R0914, R0904, R0917"
extension-pkg-allow-list = [
"matplotlib",
"PySide6",
Expand Down Expand Up @@ -34,10 +34,10 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
"docopt",
# "docopt", # TODO flet build can't find docopt...
"matplotlib",
"networkx[default]",
"pyside6",
# "pyside6",
]

[project.urls]
Expand Down
1 change: 1 addition & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(package/adaptation_pathways/desktop)
add_subdirectory(package/pathways_app)
add_subdirectory(test)
2 changes: 1 addition & 1 deletion source/package/adaptation_pathways/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
Actions = list[Action | ActionCombination]
Sequence = tuple[Action, Action]
Sequences = list[Sequence]
TippingPoint = int
TippingPoint = float
TippingPointByAction = dict[Action, TippingPoint]
3 changes: 3 additions & 0 deletions source/package/adaptation_pathways/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Contains the classes needed to communicate between the Flet app and the other parts of the codebase
"""
6 changes: 6 additions & 0 deletions source/package/adaptation_pathways/app/model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
These models are used by the front-end app to manipulate pathways data
"""

from .action import Action, ActionDependency
from .metric import Metric
from .pathway import Pathway
from .pathways_project import PathwaysProject
from .scenario import Scenario, TimeSeriesPoint
13 changes: 10 additions & 3 deletions source/package/adaptation_pathways/app/model/action.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dataclasses

from comparisons import SequenceComparison
from metric import Metric, MetricValue
from .comparisons import SequenceComparison
from .metric import MetricEffect


@dataclasses.dataclass
Expand All @@ -10,7 +10,14 @@ class Action:
name: str
color: str
icon: str
metric_data: dict[Metric, MetricValue | None]
metric_data: dict[str, MetricEffect]

def apply_effect(self, metric_id: str, value: float) -> float:
if metric_id not in self.metric_data:
return value

effect = self.metric_data[metric_id]
return effect.apply_to(value)


@dataclasses.dataclass
Expand Down
Loading

0 comments on commit 8c58c89

Please sign in to comment.