Skip to content
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

[FEATURE-BRANCH] feat: add Webhooks #5467

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Commits on Sep 9, 2024

  1. feat: add Webhooks base feature (#5453)

    # Description
    
    This PR adds the base implementation for Webhooks with the following
    changes:
    * Adding a new API to create/update/delete Webhooks.
    * Add a new endpoint to execute a testing a ping event for a specific
    Webhook.
    * No background jobs integration. This is gonna be done in a different
    PR.
    
    **Type of change**
    
    - New feature (non-breaking change which adds functionality)
    
    **How Has This Been Tested**
    
    - [x] Manually tested locally and in HF spaces.
    
    **Checklist**
    
    - I added relevant documentation
    - I followed the style guidelines of this project
    - I did a self-review of my code
    - I made corresponding changes to the documentation
    - I confirm My changes generate no new warnings
    - I have added tests that prove my fix is effective or that my feature
    works
    - I have added relevant notes to the CHANGELOG.md file (See
    https://keepachangelog.com/)
    
    ---------
    
    Co-authored-by: Paco Aranda <[email protected]>
    jfcalvo and frascuchon committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    ff01b1c View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2024

  1. feat: add Webhooks notify events using background jobs (#5468)

    # Description
    
    This PR adds the following changes:
    * Add first real Webhooks notifications for responses using some
    background jobs for them.
    * Add a new RQ `high` queue where we will enqueue the Webhooks
    notification jobs.
    * Add webhook events:
      * `response.created`
      * `response.updated`
      * `response.deleted`
      * `response.upserted`
      * `dataset.created`
      * `dataset.updated`
      * `dataset.deleted`
      * `dataset.published`
    
    **Type of change**
    
    - New feature (non-breaking change which adds functionality)
    
    **How Has This Been Tested**
    
    - [x] Manually tested locally and in HF spaces.
    
    **Checklist**
    
    - I added relevant documentation
    - I followed the style guidelines of this project
    - I did a self-review of my code
    - I made corresponding changes to the documentation
    - I confirm My changes generate no new warnings
    - I have added tests that prove my fix is effective or that my feature
    works
    - I have added relevant notes to the CHANGELOG.md file (See
    https://keepachangelog.com/)
    
    ---------
    
    Co-authored-by: Damián Pumar <[email protected]>
    Co-authored-by: Paco Aranda <[email protected]>
    3 people committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    70a9b2e View commit details
    Browse the repository at this point in the history

Commits on Sep 16, 2024

  1. feat: add Webhook expanded events (#5480)

    # Description
    
    This is a PR exploring the possibility of expanding associated resources
    on webhook event messages.
    
    The following changes has been added:
    * Add webhook event schemas for the following resources:
      * `Response`
      * `Record`
      * `Dataset`
      * `Workspace`
      * `User`
    * Webhook events associated to deletion of resources are sending now a
    simple `{"id": "id-of-the-deleted-resource"}` to avoid problems with
    missing resources deleted on cascade.
    * The model associations are loaded using `awaitable_attrs` to avoid
    replacing the original resource instance (and avoid a database refresh
    that could cause losing the state of the resource).
    
    This is an example of a `response.created` event with the changes:
    
    ```json
    {
      "type": "response.created",
      "version": 1,
      "timestamp": "2024-09-12T11:52:15.083612Z",
      "data": {
        "id": "053a845a-02fd-4951-9884-2317a4a2be19",
        "values": {
          "int_score": {
            "value": 3
          }
        },
        "status": "submitted",
        "record": {
          "id": "60eadd2c-76ed-4216-870e-9d361ac0a894",
          "status": "pending",
          "fields": {
            "text": "a combination of one or more elementary reaction steps which start with the appropriate reactants and end with the appropriate product(s)\na description of the path, or sequence of steps, by which a reaction occurs\na description of the path that a reaction takes\na detailed description of how a chemical reaction occurs\na detailed description of the way a reaction occurs and is based on the known experimental data about the reaction\na detailed (theoretical) description of how we think the chemical reaction proceeds\na series of elementary reactions or elementary steps that lead from reactants to products\na set of steps at the molecular level\na step by step description of the separate steps that occur during a chemical reaction\na stepwise description of the reaction path\nmechanism. A list of all elementary reactions that occur in the course of an overall chemical reaction.\nIn chemistry, a reaction mechanism is the step by step sequence of elementary reactions by which overall chemical change occurs."
          },
          "metadata": {
            "dump": "CC-MAIN-2013-20",
            "url": "http://www.metaglossary.com/meanings/3337605/",
            "language": "en",
            "language_score": 0.9414262175559998,
            "token_count": 195,
            "score": 3.671875
          },
          "external_id": "<urn:uuid:7ae3a60b-341f-4a49-8f9d-b5b4588f2f8d>",
          "dataset": {
            "id": "408239b6-d100-4eff-b5d9-afcc8e99b9f1",
            "name": "fineweb-edu-min-submitted-big",
            "guidelines": null,
            "allow_extra_metadata": false,
            "status": "ready",
            "distribution": {
              "strategy": "overlap",
              "min_submitted": 1
            },
            "workspace": {
              "id": "350bc020-2cd2-4a67-8b23-37a15c4d8139",
              "name": "argilla",
              "inserted_at": "2024-09-05T11:39:20.377192",
              "updated_at": "2024-09-05T11:39:20.377192"
            },
            "questions": [
              {
                "id": "f6453e3a-5ed2-4853-a8c4-913d03bc1dfb",
                "name": "int_score",
                "title": "Rate the quality of the text",
                "description": null,
                "required": true,
                "settings": {
                  "type": "rating",
                  "options": [
                    {
                      "value": 0
                    },
                    {
                      "value": 1
                    },
                    {
                      "value": 2
                    },
                    {
                      "value": 3
                    },
                    {
                      "value": 4
                    },
                    {
                      "value": 5
                    }
                  ]
                },
                "inserted_at": "2024-09-06T10:21:25.482006",
                "updated_at": "2024-09-06T10:21:25.482006"
              },
              {
                "id": "4d0b53e6-9b96-42da-a863-2c17d483be01",
                "name": "comments",
                "title": "Comments:",
                "description": null,
                "required": false,
                "settings": {
                  "type": "text",
                  "use_markdown": false
                },
                "inserted_at": "2024-09-06T10:21:25.493565",
                "updated_at": "2024-09-06T10:21:25.493565"
              }
            ],
            "fields": [
              {
                "id": "02ef122a-d989-4422-89ad-e29096a1acfd",
                "name": "text",
                "title": "text",
                "required": true,
                "settings": {
                  "type": "text",
                  "use_markdown": false
                },
                "inserted_at": "2024-09-06T10:21:25.468310",
                "updated_at": "2024-09-06T10:21:25.468310"
              }
            ],
            "metadata_properties": [
              {
                "id": "c79d1808-7551-4fb8-b673-b5bb0bec0532",
                "name": "dump",
                "title": "dump",
                "settings": {
                  "type": "terms",
                  "values": null
                },
                "visible_for_annotators": true,
                "inserted_at": "2024-09-06T10:21:25.506303",
                "updated_at": "2024-09-06T10:21:25.506303"
              },
              {
                "id": "1195fc9b-0974-498f-8cff-6feddfd6e9a1",
                "name": "url",
                "title": "url",
                "settings": {
                  "type": "terms",
                  "values": null
                },
                "visible_for_annotators": true,
                "inserted_at": "2024-09-06T10:21:25.516085",
                "updated_at": "2024-09-06T10:21:25.516085"
              },
              {
                "id": "28cc925c-fed6-48bf-a1df-ef43e884b33b",
                "name": "language",
                "title": "language",
                "settings": {
                  "type": "terms",
                  "values": null
                },
                "visible_for_annotators": true,
                "inserted_at": "2024-09-06T10:21:25.523871",
                "updated_at": "2024-09-06T10:21:25.523871"
              },
              {
                "id": "9333a2c9-efaf-4b0e-88e7-b1ed24dfcbfa",
                "name": "language_score",
                "title": "language_score",
                "settings": {
                  "min": null,
                  "max": null,
                  "type": "float"
                },
                "visible_for_annotators": true,
                "inserted_at": "2024-09-06T10:21:25.532447",
                "updated_at": "2024-09-06T10:21:25.532447"
              },
              {
                "id": "9d56b399-3c53-4e98-9d4a-ebfb360ec293",
                "name": "token_count",
                "title": "token_count",
                "settings": {
                  "min": null,
                  "max": null,
                  "type": "integer"
                },
                "visible_for_annotators": true,
                "inserted_at": "2024-09-06T10:21:25.539531",
                "updated_at": "2024-09-06T10:21:25.539531"
              },
              {
                "id": "6c701f7b-de47-4224-b9b0-3629133282ed",
                "name": "score",
                "title": "score",
                "settings": {
                  "min": null,
                  "max": null,
                  "type": "float"
                },
                "visible_for_annotators": true,
                "inserted_at": "2024-09-06T10:21:25.546505",
                "updated_at": "2024-09-06T10:21:25.546505"
              }
            ],
            "vectors_settings": [],
            "last_activity_at": "2024-09-12T11:52:15.030317",
            "inserted_at": "2024-09-06T10:21:25.443578",
            "updated_at": "2024-09-12T11:52:04.923388"
          },
          "inserted_at": "2024-09-06T10:21:27.790000",
          "updated_at": "2024-09-06T10:21:27.790000"
        },
        "user": {
          "id": "df114042-958d-42c6-9f03-ab49bd451c6c",
          "first_name": "",
          "last_name": null,
          "username": "argilla",
          "role": "owner",
          "inserted_at": "2024-09-05T11:39:20.376463",
          "updated_at": "2024-09-05T11:39:20.376463"
        },
        "inserted_at": "2024-09-12T11:52:15.029023",
        "updated_at": "2024-09-12T11:52:15.029023"
      }
    }
    ```
    
    There are still missing changes and solutions to explore:
    - [ ] Review some associations that we can still add to the events.
    - [ ] Review if some missing endpoints are necessary.
    - [ ] Should we truncate record field values that are too large?
    - [ ] For example truncate image field values. Something like
    `afdsmk432mkfseiwer...(truncated)`
    - [ ] Update CHANGELOG if necessary.
    
    **Type of change**
    
    - New feature (non-breaking change which adds functionality)
    
    **How Has This Been Tested**
    
    - [ ] Manually test the new events on HF spaces.
    
    **Checklist**
    
    - I added relevant documentation
    - I followed the style guidelines of this project
    - I did a self-review of my code
    - I made corresponding changes to the documentation
    - I confirm My changes generate no new warnings
    - I have added tests that prove my fix is effective or that my feature
    works
    - I have added relevant notes to the CHANGELOG.md file (See
    https://keepachangelog.com/)
    jfcalvo committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    a55e884 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    935a299 View commit details
    Browse the repository at this point in the history
  3. [ENHANCEMENT] add record related webhook events (#5489)

    # Description
    <!-- Please include a summary of the changes and the related issue.
    Please also include relevant motivation and context. List any
    dependencies that are required for this change. -->
    
    This PR adds record-related webhook events: `created`, `updated`,
    `deleted` and `completed`
    
    **Type of change**
    <!-- Please delete options that are not relevant. Remember to title the
    PR according to the type of change -->
    
    - Improvement (change adding some improvement to an existing
    functionality)
    
    **How Has This Been Tested**
    <!-- Please add some reference about how your feature has been tested.
    -->
    
    **Checklist**
    <!-- Please go over the list and make sure you've taken everything into
    account -->
    
    - I added relevant documentation
    - I followed the style guidelines of this project
    - I did a self-review of my code
    - I made corresponding changes to the documentation
    - I confirm My changes generate no new warnings
    - I have added tests that prove my fix is effective or that my feature
    works
    - I have added relevant notes to the CHANGELOG.md file (See
    https://keepachangelog.com/)
    
    ---------
    
    Co-authored-by: José Francisco Calvo <[email protected]>
    frascuchon and jfcalvo committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    bea6eb0 View commit details
    Browse the repository at this point in the history
  4. [ENHANCEMENT] argilla: expose webhooks API (#5490)

    # Description
    <!-- Please include a summary of the changes and the related issue.
    Please also include relevant motivation and context. List any
    dependencies that are required for this change. -->
    
    This PR exposes the new webhooks API through the low-level `client.api`
    component. Once the backend API and SDK flows are validated, we can work
    on exposing webhooks as client resource level
    
    **Type of change**
    <!-- Please delete options that are not relevant. Remember to title the
    PR according to the type of change -->
    
    - Bug fix (non-breaking change which fixes an issue)
    - New feature (non-breaking change which adds functionality)
    - Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
    - Refactor (change restructuring the codebase without changing
    functionality)
    - Improvement (change adding some improvement to an existing
    functionality)
    - Documentation update
    
    **How Has This Been Tested**
    <!-- Please add some reference about how your feature has been tested.
    -->
    
    **Checklist**
    <!-- Please go over the list and make sure you've taken everything into
    account -->
    
    - I added relevant documentation
    - I followed the style guidelines of this project
    - I did a self-review of my code
    - I made corresponding changes to the documentation
    - I confirm My changes generate no new warnings
    - I have added tests that prove my fix is effective or that my feature
    works
    - I have added relevant notes to the CHANGELOG.md file (See
    https://keepachangelog.com/)
    frascuchon committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    48a0dfe View commit details
    Browse the repository at this point in the history
  5. chore: move webhooks folder outside api folder (#5493)

    # Description
    
    As discussed this PR is moving `webhooks` folder outside `api` folder.
    Now that we have specific schemas for webhooks it does not have much
    sense to have this code inside the `api` folder.
    
    Refs #1836 
    
    **Type of change**
    
    - Refactor (change restructuring the codebase without changing
    functionality)
    
    **How Has This Been Tested**
    
    - [x] Running test suite.
    
    **Checklist**
    
    - I added relevant documentation
    - I followed the style guidelines of this project
    - I did a self-review of my code
    - I made corresponding changes to the documentation
    - I confirm My changes generate no new warnings
    - I have added tests that prove my fix is effective or that my feature
    works
    - I have added relevant notes to the CHANGELOG.md file (See
    https://keepachangelog.com/)
    jfcalvo committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    3fb3d66 View commit details
    Browse the repository at this point in the history
  6. feat: remove response.upserted webhook event (#5494)

    # Description
    
    As discussed we want to stop using `response.upserted` webhook event and
    instead use `response.created` or `response.updated` when a response is
    upserted.
    
    Refs #1836 
    
    **Type of change**
    
    - New feature (non-breaking change which adds functionality)
    
    **How Has This Been Tested**
    
    - [x] Running test suite.
    
    **Checklist**
    
    - I added relevant documentation
    - I followed the style guidelines of this project
    - I did a self-review of my code
    - I made corresponding changes to the documentation
    - I confirm My changes generate no new warnings
    - I have added tests that prove my fix is effective or that my feature
    works
    - I have added relevant notes to the CHANGELOG.md file (See
    https://keepachangelog.com/)
    jfcalvo committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    cbf28c7 View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2024

  1. Configuration menu
    Copy the full SHA
    97802e2 View commit details
    Browse the repository at this point in the history

Commits on Sep 19, 2024

  1. Configuration menu
    Copy the full SHA
    38642ea View commit details
    Browse the repository at this point in the history
  2. tests: Add tests using IP address when creating or updating webhooks (#…

    …5511)
    
    # Description
    <!-- Please include a summary of the changes and the related issue.
    Please also include relevant motivation and context. List any
    dependencies that are required for this change. -->
    
    Since URLs including IP addresses are allowed values when
    creating/updating webhooks, this PR only adds tests checking these
    scenarios.
    
    **Type of change**
    <!-- Please delete options that are not relevant. Remember to title the
    PR according to the type of change -->
    
    
    **How Has This Been Tested**
    <!-- Please add some reference about how your feature has been tested.
    -->
    
    **Checklist**
    <!-- Please go over the list and make sure you've taken everything into
    account -->
    
    - I added relevant documentation
    - I followed the style guidelines of this project
    - I did a self-review of my code
    - I made corresponding changes to the documentation
    - I confirm My changes generate no new warnings
    - I have added tests that prove my fix is effective or that my feature
    works
    - I have added relevant notes to the CHANGELOG.md file (See
    https://keepachangelog.com/)
    
    ---------
    
    Co-authored-by: José Francisco Calvo <[email protected]>
    frascuchon and jfcalvo committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    a26f008 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a65eb96 View commit details
    Browse the repository at this point in the history