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

Updated web app with save/load functionality #68

Merged
merged 12 commits into from
Jan 31, 2025
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: |
mkdir build
cd build
cmake -S .. -G Ninja
cmake -S .. -G Ninja -D AP_BASE_URL=PathwaysGenerator
- name: Build web app
run: |
cmake --build build --target web_app
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ enable_testing()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/environment/cmake)

set(AP_BASE_URL "" CACHE STRING
"Base url for web app. Use empty string (the default) for testing locally."
)

find_package(Flet REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
find_package(Quarto)
Expand Down
3 changes: 3 additions & 0 deletions environment/configuration/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
docopt
matplotlib
networkx[default]
pyside6>=6.6
flet==0.25.*
pyodide-py
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ profile = "black"

[tool.pylint]
max-line-length=240
disable = "C0103, C0114, C0115, C0116, C0302, E0401, W0212, W0511, R0801, R0902, R0903, R0913, R0914, R0904, R0917"
disable = "C0103, C0114, C0115, C0116, C0302, E0401, W0212, W0511, R0801, R0902, R0903, R0913, R0914, R0904, R0917, W0718"
extension-pkg-allow-list = [
"matplotlib",
]
Expand Down
2 changes: 1 addition & 1 deletion source/package/adaptation_pathways/app/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .metric import Metric
from .pathway import Pathway
from .pathways_project import PathwaysProject
from .scenario import Scenario, TimeSeriesPoint
from .scenario import Scenario
20 changes: 15 additions & 5 deletions source/package/adaptation_pathways/app/model/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def format(self, value: float):
class Metric:
id: str
name: str
current_value: float
unit_or_default: MetricUnit | str

@property
Expand All @@ -57,10 +56,20 @@ def __hash__(self) -> int:
return self.id.__hash__()


class MetricValueState(Enum):
BASE = 0
ESTIMATE = (1,)
OVERRIDE = 2


@dataclasses.dataclass
class MetricValue:
value: float
is_estimate: bool = False
state: MetricValueState = MetricValueState.BASE

@property
def is_estimate(self):
return self.state == MetricValueState.ESTIMATE


class MetricOperation(Enum):
Expand Down Expand Up @@ -138,14 +147,15 @@ class Volume:
si = [
MetricUnit(name="Milliliter", symbol="ml"),
MetricUnit(name="Liter", symbol="l"),
MetricUnit(name="Cubic Centimeter", symbol="cm^3"),
MetricUnit(name="Cubic Meter", symbol="m^3"),
MetricUnit(name="Cubic Centimeter", symbol="cm³"),
MetricUnit(name="Cubic Meter", symbol="m³"),
]
imperial = [
MetricUnit(name="Fluid Ounce", symbol="fl oz"),
MetricUnit(name="Pint", symbol="pt"),
MetricUnit(name="Quart", symbol="qt"),
MetricUnit(name="Gallon", symbol="gal"),
MetricUnit(name="Acre Feet", symbol="ac-ft"),
]

volume = Volume()
Expand Down Expand Up @@ -224,7 +234,7 @@ class MassWeight:
]

relative = [
MetricUnit(name="Percent", symbol="%", value_format=".2%"),
MetricUnit(name="Percent", symbol="%", value_format=".2"),
MetricUnit(
name="Impact", symbol="", short_name="Impact", value_format=FORMAT_SLIDER
),
Expand Down
Loading