Skip to content

Commit

Permalink
upload
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielTollenaar committed Jul 18, 2024
1 parent 6c1e1e9 commit a85cf09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion notebooks/rijkswaterstaat/9_model_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

cloud = CloudStorage()

cloud.upload_model("Rijkswaterstaat", "hws", include_results=True)
cloud.upload_model("Rijkswaterstaat", "hws", include_results=True, include_plots=True)
# %%
16 changes: 15 additions & 1 deletion src/ribasim_nl/ribasim_nl/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ def strip_version(dir: str):

return [strip_version(i) for i in uploaded_models]

def upload_model(self, authority: str, model: str, include_results=False):
def upload_model(
self, authority: str, model: str, include_results=False, include_plots=False
):
"""Upload a model to a water authority
Parameters
Expand All @@ -381,6 +383,8 @@ def upload_model(self, authority: str, model: str, include_results=False):
name of the model (directory) to upload
include_results: bool, optional
to include results dir in upload; yes/no = True/False. defaults to False.
include_plots: bool, optional
to include plots dir in upload; yes/no = True/False. defaults to False.
Raises
------
Expand Down Expand Up @@ -436,6 +440,16 @@ def upload_model(self, authority: str, model: str, include_results=False):
out_file = results_dir / file.name
out_file.write_bytes(file.read_bytes())

# if plots, copy too
if include_plots and (model_dir.joinpath("plots").exists()):
files = list(model_dir.joinpath("plots").glob("*.*"))
if files:
plots_dir = model_version_dir.joinpath("plots")
plots_dir.mkdir()
for file in files:
out_file = plots_dir / file.name
out_file.write_bytes(file.read_bytes())

# create dir in CloudStorage and upload content
self.create_dir(authority, "modellen", model_version_dir.name)
self.upload_content(model_version_dir)
Expand Down

0 comments on commit a85cf09

Please sign in to comment.