-
Notifications
You must be signed in to change notification settings - Fork 2
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
update customise interactions nodebook #117
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explanations are good an clear, so all good from that part, but...
I get quite a few deprecation warning when building the documentation, as well as:
ImportError: Missing optional dependency 'tabulate'. Use pip or conda to install tabulate.
It seems that dependency is missing. Also wrong relative links of the type;
INFO - Doc file 'wsimod_models.md' contains an unrecognized relative link './../reference-model/#wsimod.orchestration.model.to_datetime', it was left as is. Did you mean
'reference-model.md#wsimod.orchestration.model.to_datetime'?
|
||
@register_node_patch("my_fwtw", "pull_distributed") | ||
def custom_pull_distributed(self, vqip, *args, **kwargs): | ||
"""A custom handler function.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a handler, I think...
|
||
@register_node_patch("my_reservoir", "pull_set_handler", item="FWTW") | ||
def custom_pulls_fwtw(self, vqip, *args, **kwargs): | ||
"""A custom handler function.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a little bit more descriptive explanations? I don't think it matters, but it just looks odd to have lots of functions with exactly the same docstring.
from wsimod.orchestration.model import Model, to_datetime | ||
|
||
# Identify the location of the scripts folder | ||
scripts_folder = os.path.join(os.path.abspath(""), "docs", "demo", "scripts") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is not super elegant, but I know that jupyter and paths just don't get along very well...
# <details> | ||
# <summary>Source code</summary> | ||
# <pre><code class="language-python"> | ||
# from wsimod.extensions import register_node_patch | ||
# | ||
# @register_node_patch("my_dist", "push_check_handler", item="Node") | ||
# def custom_handler_function(self, vqip, *args, **kwargs): | ||
# """A custom handler function.""" | ||
# print("I reached a custom handler") | ||
# return self.push_check_handler\["default"\](vqip) | ||
# </code></pre> | ||
# | ||
# </details> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
# As we illustrated [above](#illustration), we define our new handlers in a separate module, which we will call `custom_reservoir_handler.py`. | ||
# | ||
# <details> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# | ||
# We have the following code in a separate module, which we will call `custom_fwtw_pull.py`. | ||
# | ||
# <details> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here
Summary
details
. My preferred option would be to use this API like in this, which feels much tidier in terms of formatting and more sustainable as code does not need to be reproduced. But as we discussed in SWMManywhere - it seems thatmkdocs-jupyter
can't access the API docstrings. I could use ayaml
codeblock, which would include thepython
formatting, but it looks super weird as it is formatted differently from the notebook and can't be stored in adetails
. Thus, I think this is the best way, but am open to suggesstions.scripts
folder as in the another demo withos
- though it's a bit ugly. Obviously__file__
would be preferrable, but this doesn't seem to work withmkdocs-jupyter
.river_discharge_order
.Fixes #112