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

Fix env #109

Merged
merged 11 commits into from
Jul 3, 2024
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
36 changes: 25 additions & 11 deletions envs/environment_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ dependencies:
- h5py
- fiona=1.9.5
- shapely=2.0.2
- gdal=3.8.4
# - gdal=3.8.4 incompatible with rasterio

#User folder
- jupyterlab=3.6.3
- ipywidgets=8.0.6
- jupyterlab=4.2.0
- ipywidgets=8.1.2
#External deps plugin

- pytest=7.2.2
Expand All @@ -30,20 +30,34 @@ dependencies:
- iniconfig=2.0.0 #pytest dependency
- tqdm=4.64.0
- rioxarray=0.15.0 #higher versions need python >=3.10
- pyogrio=0.7.2
- pyogrio=0.7.2 #0.9.0 doesnt work with gdal
- rasterio=1.3.10 #rxr dep
- affine=2.4.0 #rxr dep
- dask=2024.6.2 #rxr dep
- matplotlib=3.8.* #3.9.0 gives RuntimeError: Entry point name 'inline' duplicated
# See also: https://discourse.matplotlib.org/t/latest-versions-via-pip-jupyterlab-import-of-matplotlib-broken/24477/7


- xarray=2024.3.0
- openpyxl=3.1.2
- cached_property=1.5.2
- rtree=1.0.1
- pip=24.0

- pip: # 3Di packages are not conda installable and are therefore installed by PIP
- threedi_modelchecker==2.4.0 #ThreediToolbox 2.5.5
- threedi_modelchecker==2.6.3 #threedi_results_analysis 3.9.0
- threedi_scenario_downloader==1.4 #Lizard API v4 only
- threedi_schema==0.217.11 #ThreediToolbox 2.5.4
- threedi-api-client==4.1.4 #3Di Models and Simulations 3.5.2
- threedigrid_builder==1.12.1 #ThreediToolbox 2.5.5
- threedigrid==2.0.6 #ThreediToolbox 2.5.4
- threedidepth==0.6.1 #ThreediToolbox 2.5.4

- threedi_schema==0.219.3 #threedi_results_analysis 3.9.0
- threedi-api-client==4.1.7 #3Di Models and Simulations 3.11.0
- threedigrid_builder==1.13.1 #threedi_results_analysis 3.9.0
- threedigrid==2.2.10 #threedi_results_analysis 3.9.0
- threedidepth==0.6.3 #threedi_results_analysis 3.9.0

# Schema 217.
# - threedi_modelchecker==2.4.0 #ThreediToolbox 2.5.5
# - threedi_scenario_downloader==1.4 #Lizard API v4 only
# - threedi_schema==0.217.11 #ThreediToolbox 2.5.4
# - threedi-api-client==4.1.4 #3Di Models and Simulations 3.5.2
# - threedigrid_builder==1.12.1 #ThreediToolbox 2.5.5
# - threedigrid==2.0.6 #ThreediToolbox 2.5.4
# - threedidepth==0.6.1 #ThreediToolbox 2.5.4
2 changes: 1 addition & 1 deletion hhnk_threedi_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

# notebooks
from hhnk_threedi_tools.utils.notebooks.run import (
add_notebook_paths,
# add_notebook_paths,
copy_notebooks,
open_server,
read_notebook_json,
Expand Down
2 changes: 1 addition & 1 deletion hhnk_threedi_tools/core/checks/sqlite/sqlite_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def run_controlled_structures(self, overwrite=False):
self.structure_control.run(overwrite=overwrite)

def run_dem_max_value(self):
stats = self.dem.statistics(approx_ok=False, force=True)
stats = self.dem.statistics()
if stats["max"] > DEM_MAX_VALUE:
result = f"Maximale waarde DEM: {stats['max']} is te hoog"
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _scenario_metadata_row(self, scenario, raster_type) -> pd.Series:
"""Raster statistics for single scenario"""
raster = getattr(scenario, raster_type)

stats = raster.statistics(approx_ok=True, force=True)
stats = raster.statistics()

# Fill row data
info_row = pd.Series(dtype=object)
Expand Down
78 changes: 39 additions & 39 deletions hhnk_threedi_tools/utils/notebooks/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,42 +186,42 @@ def create_command_bat_file(path, location="osgeo"):
bat_file.write(" ".join(command))


# TODO this doesnt work nicely with other environments. Prepare for deprecation
def add_notebook_paths(extra_notebook_paths):
"""adds extra notebook paths, which is used in the plugin"""

# user profile paths
user_profile_path = os.environ["USERPROFILE"]
ipython_profile_path = user_profile_path + "/.ipython/profile_default/ipython_config.py"

nb_path_command = "import sys"
for path in extra_notebook_paths:
path = path.replace("\\", "/")
nb_path_command = nb_path_command + f'; sys.path.insert(0,"{path}")'
nb_string = f"c.InteractiveShellApp.exec_lines = ['{nb_path_command}']"

if not os.path.exists(ipython_profile_path):
# create a profile
command = notebook_command("user", ipython=True)
command = command[1] + " profile create"

subprocess.run(command, shell=True)
print("Creating profile with: ", command)
# print(["start", "cmd", "/K"] + command)
# output, error = process.communicate()
# exit_code = process.wait()
# if exit_code:
# print(f"Creating ipython profile failed: {error} {output}")

# check if paths are already available
exists = False
with open(ipython_profile_path, "r") as profile_code:
for i in profile_code:
if nb_string in profile_code:
exists = True
break

if not exists:
print("Adding:", nb_string)
with open(ipython_profile_path, "a") as profile_code:
profile_code.write("\n" + nb_string)
# # TODO this doesnt work nicely with other environments. Prepare for deprecation
# def add_notebook_paths(extra_notebook_paths):
# """adds extra notebook paths, which is used in the plugin"""

# # user profile paths
# user_profile_path = os.environ["USERPROFILE"]
# ipython_profile_path = user_profile_path + "/.ipython/profile_default/ipython_config.py"

# nb_path_command = "import sys"
# for path in extra_notebook_paths:
# path = path.replace("\\", "/")
# nb_path_command = nb_path_command + f'; sys.path.insert(0,"{path}")'
# nb_string = f"c.InteractiveShellApp.exec_lines = ['{nb_path_command}']"

# if not os.path.exists(ipython_profile_path):
# # create a profile
# command = notebook_command("user", ipython=True)
# command = command[1] + " profile create"

# subprocess.run(command, shell=True)
# print("Creating profile with: ", command)
# # print(["start", "cmd", "/K"] + command)
# # output, error = process.communicate()
# # exit_code = process.wait()
# # if exit_code:
# # print(f"Creating ipython profile failed: {error} {output}")

# # check if paths are already available
# exists = False
# with open(ipython_profile_path, "r") as profile_code:
# for i in profile_code:
# if nb_string in profile_code:
# exists = True
# break

# if not exists:
# print("Adding:", nb_string)
# with open(ipython_profile_path, "a") as profile_code:
# profile_code.write("\n" + nb_string)
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
filename;bounds;max;mean;min;std;x_res;y_res
damage_total_piek_glg_T10;[109580.0, 110064.0, 541712.0, 543286.0];0.336;0.242796;3e-06;0.13539;968;3148
damage_total_piek_glg_T10;[109580.0, 110064.0, 541712.0, 543286.0];72.69912;0.197202;0.0;1.440296;968;3148
2 changes: 1 addition & 1 deletion tests/data/test_klimaatsommen/depth_max_info_expected.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
filename;bounds;max;mean;min;std;x_res;y_res
depth_max_piek_glg_T10;[109580.0, 110064.0, 541712.0, 543286.0];1.176843;0.075668;-0.009993;0.145807;968;3148
depth_max_piek_glg_T10;[109580.0, 110064.0, 541712.0, 543286.0];1.491628;0.086295;-0.01;0.161273;968;3148
4 changes: 2 additions & 2 deletions tests/notebooks/rtest_lizardapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
requested resolution: {resolution}
projection: {r.metadata.projection}
sum: {r.sum()}
stats: {r.statistics(approx_ok=False)}
stats: {r.statistics()}
bbox: {r.metadata.bbox}
georef: {r.metadata.georef}
pixelsize (x): {r.metadata.pixel_width}
Expand All @@ -103,7 +103,7 @@
requested resolution: {resolution}
projection: {r.metadata.projection}
sum: {r.sum()}
stats: {r.statistics(approx_ok=False)}
stats: {r.statistics()}
bbox: {r.metadata.bbox}
georef: {r.metadata.georef}
pixelsize (x): {r.metadata.pixel_width}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_schema_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_schema_migration():
migrate_schema = MigrateSchema(database_new)
migrate_schema.run()

assert migrate_schema.schema.get_version() == 217
assert migrate_schema.schema.get_version() == 219


# %%
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_run_dewatering_depth(self):
self.sqlite_check.run_dewatering_depth()
assert self.sqlite_check.output_fd.drooglegging.exists()

assert self.sqlite_check.output_fd.drooglegging.statistics(approx_ok=False) == {
assert self.sqlite_check.output_fd.drooglegging.statistics() == {
"min": -0.76,
"max": 10004.290039,
"mean": 2.167882,
Expand Down
Loading