OpenFn / kit

The bits & pieces that make OpenFn work. (diagrammer, cli, compiler, runtime, runtime manager, logger, etc.)
9 stars 10 forks source link

[DMP 2024] Generate a project.yaml file from a list of steps #619

Open christad92 opened 6 months ago

christad92 commented 6 months ago

Overview

We are looking to integrate an AI agent that is able to generate a workflow for a user, based on an instructions specifying the required steps and adaptors.

This feature will enable new users of OpenFn (Lightning) to get started faster after registration by entering the steps they need.

The agent will automatically build a workflow can run without error and ready for editing.

Deliverables

To be clear, this work does NOT include any integration on the Lightning side.

Extensions to this work include:

Sample Inputs

Below are examples of prompts and their corresponding workflow.yaml for reference and testing. Prompt 1

Prompt 2:

workflow-1:
    name: another simple workflow
    jobs:
      Fetch-submissions-from-KoboCollect:
        name: Fetch submissions from KoboCollect
        adaptor: '@openfn/language-kobotoolbox@latest'
        # credential:
        # globals:
        body: |
          // Get started by adding operations from the API reference

      Push-Data-to-PostgreSQL:
        name: Push Data to PostgreSQL
        adaptor: '@openfn/language-postgresql@latest'
        # credential:
        # globals:
        body: |
          // Get started by adding operations from the API reference

      Send-a-text-message-to-admin:
        name: Send a text message to admin
        adaptor: '@openfn/language-twilio@0.3.4'
        # credential:
        # globals:
        body: |
          // Get started by adding operations from the API reference

    triggers:
      webhook:
        type: webhook
        enabled: true
    edges:
      webhook->Fetch-submissions-from-KoboCollect:
        source_trigger: webhook
        target_job: Fetch-submissions-from-KoboCollect
        condition_type: always
        enabled: true
      Fetch-submissions-from-KoboCollect->Push-Data-to-PostgreSQL:
        source_job: Fetch-submissions-from-KoboCollect
        target_job: Push-Data-to-PostgreSQL
        condition_type: on_job_success
        enabled: true
      Push-Data-to-PostgreSQL->Send-a-text-message-to-admin:
        source_job: Push-Data-to-PostgreSQL
        target_job: Send-a-text-message-to-admin
        condition_type: on_job_success
        enabled: true

Demo script

To validate the work, we would like a demo script which lets us easily test various inputs and see them visualised in Lightning.

The demo should be executable from a terminal. It could be a python or bash script. It should not be integrated with the the OpenFn CLI.

The demo should do the following:

Suggested API

We recommend the following API for the service

JSON input:

{ 
  steps: ["instructions for step 1", "instructions for step"]
  format: "yaml" | "json"
}

JSON output:

{
    files: {
       'project.yaml': '...'
    }
}

The resulting structure and the files key makes for easy integration with the apollo server.

Background

OpenFn is an open source platform for data integration and workflow automation which can be used via a CLI or a web UI.

Projects on OpenFn can be encoded in a yaml file containing workflows, steps, jobs, triggers and edges.

Key terms

Workflows contains one trigger and one or more steps connected by edges.

Workflows are at the base of users activities and steps related to a objective are built and saved in a workflow.

A step is a task or instruction that users write mostly in Javascript. The output of a step can be anything from sending a text message, transform data, make an API call, send data to an external systems or fetch data from an external system. These jobs are performed with the help of adaptors.

Triggers are useful for nudging workflows to run based on an event or at a scheduled time. Edges connects two steps and determines the order and conditions for the steps in a workflow.

See more details at https://docs.openfn.org/documentation/get-started/terminology

Sample Project.yaml

Below is an example of a yaml file for a project openhie-project which has one workflow OpenHIE-Workflow and 4 steps [ "FHIR-standard-Data-with-change", "Send-to-OpenHIM-to-route-to-SHR", "Send-to-OpenHIM-to-route-to-SHR", "Notify-CHW-upload-successful"]. The trigger is a Webhook event and there are also 4 edges with source_job, target_job and condition variables that guide how the workflow should be executed.

name: openhie-project
description: Some sample
# credentials:
# globals:
workflows:
  OpenHIE-Workflow:
    name: OpenHIE Workflow
    jobs:
      FHIR-standard-Data-with-change:
        name: FHIR-standard-Data-with-change
        adaptor: '@openfn/language-http@latest'
        enabled: true
        # credential:
        # globals:
        body: |
          fn(state => {
            console.log("hello world")
            return state
        });

      Send-to-OpenHIM-to-route-to-SHR:
        name: Send-to-OpenHIM-to-route-to-SHR
        adaptor: '@openfn/language-http@latest'
        enabled: true
        # credential:
        # globals:
        body: |
          fn(state => state);

      Notify-CHW-upload-successful:
        name: Notify-CHW-upload-successful
        adaptor: '@openfn/language-http@latest'
        enabled: true
        # credential:
        # globals:
        body: |
          fn(state => state);

      Notify-CHW-upload-failed:
        name: Notify-CHW-upload-failed
        adaptor: '@openfn/language-http@latest'
        enabled: true
        # credential:
        # globals:
        body: |
          fn(state => state);

    triggers:
      webhook:
        type: webhook
    edges:
      webhook->FHIR-standard-Data-with-change:
        source_trigger: webhook
        target_job: FHIR-standard-Data-with-change
        condition: always
      FHIR-standard-Data-with-change->Send-to-OpenHIM-to-route-to-SHR:
        source_job: FHIR-standard-Data-with-change
        target_job: Send-to-OpenHIM-to-route-to-SHR
        condition: on_job_success
      Send-to-OpenHIM-to-route-to-SHR->Notify-CHW-upload-successful:
        source_job: Send-to-OpenHIM-to-route-to-SHR
        target_job: Notify-CHW-upload-successful
        condition: on_job_success
      Send-to-OpenHIM-to-route-to-SHR->Notify-CHW-upload-failed:
        source_job: Send-to-OpenHIM-to-route-to-SHR
        target_job: Notify-CHW-upload-failed
        condition: on_job_failure

Here's what a list of steps might look like (also pictured in the image below):

When this feature is integrated with Lighnting, here is how a user would use it to generate a workflow.

Building this UI/X is NOT part of this project but the image below is helpful for contributors to understand the mission.

Image

Documentation and relevant links

josephjclark commented 5 months ago

This probably needs to wait until https://github.com/OpenFn/gen/issues/42 is ready before we can take contributions.

Then this project needs:

hiteshbandhu commented 5 months ago

Hey !

I'm interested in contributing to this project to solve the generation of workflows.yaml file.

@josephjclark I would love to talk and get more specific details on it and contribute

christad92 commented 5 months ago

Hey !

I'm interested in contributing to this project to solve the generation of workflows.yaml file.

@josephjclark I would love to talk and get more specific details on it and contribute

Hi @hiteshbandhu thanks for the interest. Please can you send an email to ayodele[at]openfn[dot]org and we will be able to decide on possible next steps.

Gmin2 commented 4 months ago

Hey @christad92 i am interested in working on this project should i mail w=you regarding the next steps?

CodesSunny commented 4 months ago

@christad92 hi, I am learning coding... Pls let me know whether I can join this project. Regards Vikas

christad92 commented 4 months ago

Hi @utnim2 I have responded to your email with next steps. We'd love to get you started, please use the link in the email to book a 30 mins call to discuss this issue.

AbhimanyuSamagra commented 4 months ago

Do not ask process related questions about how to apply and who to contact in the above ticket. The only questions allowed are about technical aspects of the project itself. If you want help with the process, you can refer instructions listed on Unstop and any further queries can be taken up on our Discord channel titled DMP queries. Here's a Video Tutorial on how to submit a proposal for a project.

AbhimanyuSamagra commented 4 months ago

Do not ask process related questions about how to apply and who to contact in the above ticket. The only questions allowed are about technical aspects of the project itself. If you want help with the process, you can refer instructions listed on Unstop and any further queries can be taken up on our Discord channel titled DMP queries. Here's a Video Tutorial on how to submit a proposal for a project.

babitarit commented 4 months ago

@christad92 i would like to work on this issue can u pls assign me this so that i can start working

Saksham0303 commented 4 months ago

Greetings @christad92, I've sent you my proposal via email. Could you please take a moment to review it and provide any feedback or suggestions for improvement. Once finalized, I'll be ready to submit it on the website.

Pin4sf commented 2 months ago

Hey @christad92 and @josephjclark I'm Shivansh, and I've been selected to work on this issue for DMP 2024. I've been developing a Python module to generate YAML files from workflow steps using NLP, rule-based parsing and NER. You can check the initial AI pipeline I am following.

image

You can find my initial YAML generator implementation in this Google Colab : RB+NER_Yaml.ipynb


This probably needs to wait until OpenFn/apollo#42 is ready before we can take contributions.

Then this project needs:

  • An AI module plugging into the AI server that can generate workflows (in python or JavaScript)
  • A CLI integration which allows the module to be called from the CLI and outputs workflow.yaml to disk
  • A UI in Lightning, which is probably a separate ticket in the lightning repo

I've also reviewed @josephjclark's comment on the issue thread and wanted to confirm if my primary task is developing the Python module for this issue. Additionally, I noticed the initial framework for Apollo service calls in the CLI and wanted to know if I should also contribute to the UI ticket on the lightning repository.

  • A CLI integration which allows the module to be called from the CLI and outputs workflow.yaml to disk

On inspection of apollo repository I noticed that you have set up the initial framework for making calls to Apollo services through the CLI. So need a clarification regarding the integration/plugging of this issue in Apollo repository and CLI calls.

I hope it aligns with the project goals, I would greatly appreciate your feedback and guidance on any potential improvements or clarifications on my responsibilities.

Best Regards

P.S : I think this issue should be in OpenFn/apollo.

josephjclark commented 2 months ago

Hi @Pin4sf!

Sorry for the late reply - and congrats on getting the ticket!

You are not expected to contribute to lightning as part of this project - the focus is on the backend, likely python.

A lot has changed since we created this issue and we're doing a little bit of planning to accommodate that. Unfortunately I'm super busy this week so we need a few days to prepare.

We're going to set up a kick-off call late next week to go through this. We'll be in touch soon to get that arranged, then we can let you loose!

Pin4sf commented 2 months ago

Weekly Learnings & Updates

You can access the contribution dashboard here C4GT DMP 24

Week 1

Week 2

Week 3

Week 4

Week 5

Week 6

Week 7

Week 8

hitenvidhani commented 1 month ago

Weekly Goals

Week 1