Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Make sure to have Python3 installed with pip3 support, setuptools and wheel.
  2. Install Aviso

    Code Block
    languagebash
    themeDJango
    user@local sudo pip3 install -e git+https://git.ecmwf.int/scm/lex/aviso.git@master#egg=aviso 


  3. Create a configuration file in the default location /etc/aviso/config.yaml with the following settings:

    Code Block
    languageyml
    username: <user_email>
    listeners:
      - event: dissemination
        request:
          destination: <user_destination>
          class: od
          expver: 1
          domain: g
          stream: enfo
          step: [1,2,3]
        triggers:
          - type: echo

    The first line is required for a correct authentication, the username is the email associated to the user's ECMWF account. This can be checked by logging at https://api.ecmwf.int/v1/key/.

    This file is a basic The listeners block is an example of a dissemination event listener. request describes for which dissemination event users want to execute the triggers. It is made by of a set of fields. Users have to specify only the fields they wants to use as filters. destination is a mandatory field and it is associated to one or more destinations which are linked to the user's ECMWF account. Only the notifications complying with all the fields defined will execute the trigger. The trigger in this example is echo. This will simply print out the notification to the console output.

  4. Save the ECMWF key as a file in /etc/aviso/key. The key can be obtained by logging at https://api.ecmwf.int/v1/key/ . 

  5. Launch the aviso application

    Code Block
    languagebash
    themeDJango
    user@local aviso listen

    Once in execution this command will create a process waiting for notifications. Users can terminate the application by typing CTRL+C .

    Note, the configuration file is only read at start time, therefore every time users make changes to it they need to restart the listening process.

...

Code Block
languageyml
{
    "event": "dissemination",
    "request": {
        "class": "od",
        "date": "20191112",
        "destination": "FOO",
        "domain": "g",
        "expver": "0001",
        "step": "001",
        "stream": "enfo",
        "time": "18"
    },
    "location": "httpss3://xxxstorage.ecmwf.inteuropeanweather.cloud/xxxecpds/xxx.xx"
}    

Here an example file of a listener command triggering a bash script executing a MARS request.

...

Code Block
languagepy
from pyaviso import NotificationManager


# define function to be called
def do_something(notification):
    print(f"Notification for step {notification['request']['step']} received")
    # now do something useful with it ...


# define the trigger
trigger = {"type": "function", "function": do_something}

# create a event listener request that uses that trigger
request = {"class": "od", "stream": "enfo"oper", "expver": 1, "datedomain": 20190810"g", "timestep": 01}
listener = {"event": "mars", "request": request, "triggers": [trigger]}
listeners = {"listeners": [listener]}

# run it
aviso = NotificationManager()
aviso.listen(listeners=listeners)

...