Skip to content

docs: Documentation for event-based models#117

Merged
toby-coleman merged 35 commits into
mainfrom
docs/event-based-example
Oct 8, 2025
Merged

docs: Documentation for event-based models#117
toby-coleman merged 35 commits into
mainfrom
docs/event-based-example

Conversation

@toby-coleman
Copy link
Copy Markdown
Contributor

@toby-coleman toby-coleman commented Mar 21, 2025

Summary

Adds documentation for event-based process models.

Changes

  • Completes the tutorial for event-based models.
  • Momentum trading signals on S&P500.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @toby-coleman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request focuses on enhancing the documentation for the Plugboard library, specifically adding a tutorial for event-based process models. It also includes minor improvements to the README and adds tags and a topic index to the documentation for better navigation. The event-based model tutorial introduces the concept of event-driven models within Plugboard, demonstrating how data can be passed between components based on defined triggers.

Highlights

  • Documentation: Adds a complete tutorial for event-based process models, explaining how to define events, build components to create and consume events, and put it all together in a Plugboard process.
  • Navigation: Implements tags and a topic index in the documentation to improve navigation and make it easier for users to find specific information.
  • README Updates: Includes minor fixes and improvements to the README file, such as adding detailed logging to the list of Plugboard's capabilities and updating the documentation link.

Changelog

Click here to see the changelog
  • README.md
    • Added 'Detailed logging' to the list of Plugboard capabilities.
    • Updated the documentation site link to point to the 'latest' version.
  • docs/examples/tutorials/.meta.yml
    • Added tags for the tutorial.
  • docs/examples/tutorials/event-driven-models.md
    • Created a new tutorial for event-driven models, including explanations, code snippets, and a diagram of the model.
    • Added frontmatter tags for events.
  • docs/examples/tutorials/more-components.md
    • Added frontmatter tags for logging, llm, and io.
    • Added an info section about logging with structlog.
  • docs/examples/tutorials/running-in-parallel.md
    • Added frontmatter tags for ray.
  • docs/usage/key-concepts.md
    • Updated the documentation to refer to Event as [Event][plugboard.events.Event].
    • Updated the documentation to refer to Connector as [Connector][plugboard.connector.Connector].
  • docs/usage/topics.md
    • Created a topic index page to improve documentation navigation.
  • examples/demos/llm/.meta.yml
    • Added tags for llm.
  • examples/demos/llm/002_bluesky_websocket/.meta.yml
    • Added tags for io and streaming.
  • examples/demos/physics-models/.meta.yml
    • Added tags for physics-models.
  • examples/tutorials/003_more_components/hello_llm.py
    • Changed the example description from 'Simple hello world example' to 'Simple LLM example'.
    • Added error logging for weather API queries using structlog.
  • examples/tutorials/005_events/.gitignore
    • Added *.csv to the .gitignore file.
  • examples/tutorials/005_events/hello_events.py
    • Created a new Python file containing the event-based model example, including event definitions, component implementations, and the main function to run the model.
  • examples/tutorials/005_events/model.yaml
    • Created a new YAML file defining the event-based model.
  • mkdocs.yaml
    • Added 'meta' and 'tags' plugins.
    • Added 'Topics' to the navigation menu.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Did you know?

The Mermaid diagramming tool, used in the event-driven model documentation, was initially created by Knut Sveidqvist in 2014 to simplify documentation.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request adds documentation for event-based process models, improves documentation navigation with tags and a topic index, and includes minor fixes to the README. The changes look good overall, with a well-structured tutorial and helpful additions to the documentation.

Merge Readiness

The pull request appears to be in good shape for merging. The addition of documentation for event-based models is a valuable contribution, and the improvements to navigation enhance the user experience. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@toby-coleman toby-coleman changed the title [WIP] docs: Documentation for event-based models docs: Documentation for event-based models Mar 22, 2025
@toby-coleman toby-coleman requested a review from chrisk314 March 22, 2025 16:02
@toby-coleman
Copy link
Copy Markdown
Contributor Author

@chrisk314 there are a few bits in here other than the event-based examples that would be good to merge. I'll cherry-pick them into a separate PR tomorrow and merge them in.

toby-coleman added a commit that referenced this pull request Apr 10, 2025
toby-coleman added a commit that referenced this pull request Apr 10, 2025
# Summary
Various improvements to the docs, including topic tags. Migrated from
#117.

# Changes
* Adds tags and a topic index to the docs for improved navigation.
* Minor fixes and improvements to the README.
* Small fix to the logger code to allow it to serialise types not
supported by `msgspec`, e.g. Pydantic objects.
chrisk314 pushed a commit that referenced this pull request Apr 12, 2025
# Summary
Various improvements to the docs, including topic tags. Migrated from
#117.

# Changes
* Adds tags and a topic index to the docs for improved navigation.
* Minor fixes and improvements to the README.
* Small fix to the logger code to allow it to serialise types not
supported by `msgspec`, e.g. Pydantic objects.
@chrisk314 chrisk314 force-pushed the main branch 2 times, most recently from c5dd519 to daf3ac4 Compare April 12, 2025 21:25
@github-actions
Copy link
Copy Markdown

Benchmark comparison for b61d61e5 (base) vs dd8b96a3 (PR)


------------------------------------------------------------------------------------------------------------------ benchmark: 2 tests -----------------------------------------------------------------------------------------------------------------
Name (time in ms)                                                                         Min                 Max                Mean            StdDev              Median               IQR            Outliers     OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_process_run (main/.benchmarks/Linux-CPython-3.12-64bit/0001_base)     437.7517 (1.0)      451.6523 (1.01)     445.1072 (1.00)     5.4899 (1.39)     445.5774 (1.00)     8.5989 (1.33)          2;0  2.2466 (1.00)          5           1
test_benchmark_process_run (pr/.benchmarks/Linux-CPython-3.12-64bit/0001_pr)         439.2860 (1.00)     448.5648 (1.0)      444.9868 (1.0)      3.9438 (1.0)      445.5697 (1.0)      6.4803 (1.0)           1;0  2.2473 (1.0)           5           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

@github-actions
Copy link
Copy Markdown

Benchmark comparison for b61d61e5 (base) vs 9ffa0a01 (PR)


------------------------------------------------------------------------------------------------------------------ benchmark: 2 tests ------------------------------------------------------------------------------------------------------------------
Name (time in ms)                                                                         Min                 Max                Mean            StdDev              Median                IQR            Outliers     OPS            Rounds  Iterations
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_process_run (main/.benchmarks/Linux-CPython-3.12-64bit/0001_base)     455.6203 (1.0)      482.0620 (1.03)     470.5869 (1.01)     9.7035 (2.63)     471.1319 (1.01)     10.8947 (2.43)          2;0  2.1250 (0.99)          5           1
test_benchmark_process_run (pr/.benchmarks/Linux-CPython-3.12-64bit/0001_pr)         459.7108 (1.01)     469.7616 (1.0)      465.0433 (1.0)      3.6934 (1.0)      464.7944 (1.0)       4.4777 (1.0)           2;0  2.1503 (1.0)           5           1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

@toby-coleman
Copy link
Copy Markdown
Contributor Author

toby-coleman commented Sep 16, 2025

@chrisk314 this PR is fixed up and running correctly with the new event code. One change I have noticed is a difference in mixed event/stepping components. For example:

This component is event-driven only, and its step method will be called only after an event. Previously, step would have been called at every step of the model.

class MyComponent(Component):
    io = IOController(input_events=[SomeEvent])

    async def step(self) -> None:
        self._logger.info("Step called")

    @SomeEvent.handler
    async def my_handler(self, event: SomeEvent) -> None:
        self._logger.info("Event handled", data=event.data)

This component has both an input and an event, and its step method is called on every step of the model.

class MyComponent(Component):
    io = IOController(inputs=["some_input"], input_events=[SomeEvent])

    async def step(self) -> None:
        self._logger.info("Step called")

    @SomeEvent.handler
    async def my_handler(self, event: SomeEvent) -> None:
        self._logger.info("Event handled", data=event.data)

I think the new behaviour is quite useful in many circumstances, but also means that if the user does want step called at every process step, then they need to include a dummy input to the component to make it look like the second example. Do you think we should document like this, or have some way of configuring the two different behaviours without resorting to dummy inputs?

@github-actions
Copy link
Copy Markdown

Benchmark comparison for b61d61e5 (base) vs ad955e56 (PR)


------------------------------------------------------------------------------------------------------------------ benchmark: 2 tests ------------------------------------------------------------------------------------------------------------------
Name (time in ms)                                                                         Min                 Max                Mean            StdDev              Median                IQR            Outliers     OPS            Rounds  Iterations
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_process_run (main/.benchmarks/Linux-CPython-3.12-64bit/0001_base)     443.6048 (1.0)      454.6879 (1.0)      448.2913 (1.0)      5.6158 (1.65)     445.4328 (1.0)      10.5964 (1.74)          2;0  2.2307 (1.0)           5           1
test_benchmark_process_run (pr/.benchmarks/Linux-CPython-3.12-64bit/0001_pr)         447.1971 (1.01)     454.7505 (1.00)     450.4248 (1.00)     3.4020 (1.0)      449.1675 (1.01)      6.0739 (1.0)           1;0  2.2201 (1.00)          5           1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 1, 2025

Benchmark comparison for b61d61e5 (base) vs 1c67def6 (PR)


------------------------------------------------------------------------------------------------------------------ benchmark: 2 tests -----------------------------------------------------------------------------------------------------------------
Name (time in ms)                                                                         Min                 Max                Mean            StdDev              Median               IQR            Outliers     OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_process_run (pr/.benchmarks/Linux-CPython-3.12-64bit/0001_pr)         436.9907 (1.0)      448.1529 (1.0)      443.0732 (1.0)      4.6101 (1.0)      441.9959 (1.0)      7.4003 (1.24)          2;0  2.2570 (1.0)           5           1
test_benchmark_process_run (main/.benchmarks/Linux-CPython-3.12-64bit/0001_base)     438.1887 (1.00)     454.9326 (1.02)     444.9283 (1.00)     6.1636 (1.34)     444.0953 (1.00)     5.9606 (1.0)           2;0  2.2476 (1.00)          5           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

@toby-coleman toby-coleman merged commit 5be64e7 into main Oct 8, 2025
19 checks passed
@toby-coleman toby-coleman deleted the docs/event-based-example branch October 8, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant