hydroflows.methods.events.EventSet#

class hydroflows.methods.events.EventSet(*, root: Path | None = None, events: List[EventDict])[source]#

Bases: BaseModel

A dictionary of events, referring to event file names.

Examples

The event set can be created from a YAML file as follows:

EventSet.from_yaml("path/to/eventset.yaml")

The event set can be created from a dictionary as follows:

EventSet(
    events=[
        {
            "name": "event1",
            "path": "path/to/event1.yml"
        }
    ],
)
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

field root: Path | None = None#

The root directory for the event files.

field events: List[EventDict] [Required]#

The list of events. Each event is a dictionary with an event name and reference to an event file.

classmethod from_yaml(path: Path) EventSet[source]#

Create an EventSet from a YAML file.

to_dict(root: Path | None = None, **kwargs) dict[source]#

Return the EventSet as a dictionary.

to_yaml(path: Path) None[source]#

Write the EventSet to a YAML file.

get_event(name: str, raise_error=False) Event | None[source]#

Get an event by name.

Parameters:
  • name (str) – The name of the event.

  • raise_error (bool, optional) – Raise an error if the event is not found, by default False and returns None.

add_event(name: str, path: Path) None[source]#

Add an event.

namestr

name of the event

pathPath

Path to yaml file with event description See Event for the structure of the data in this path.