kevin su
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
2
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Out of Core Plugin [RFC] ## Motivation Currently it is hard to implement backend plugins, especially for data-scientists & MLE’s who do not have working knowledge of Golang. Also, performance requirements, maintenance and development is cumbersome. The document here proposes a path to make it possible to write plugins rapidly, while decoupling them from the core flytepropeller engine. ## Goals * Plugins should be easy to author - no need of code generation, using tools that MLEs and Data Scientists are not accustomed to using. * Most important plugins for Flyte today are plugins that communicate with external services. * It should be possible to test these plugins independently and also deploy them privately. * It should be possible for users to use backend plugins for local development, especially in flytekit and unionML * It should be possible to author plugins in any language. * Plugins should be scalable * Plugins should have a very simple API * Plugins should show up in the UI (extra details) ## Overview **Flytekit Backend Plugin** is a plugin registry written by fastAPI. Both users and Propeller can send the request to it to run the jobs (Bigquery, Databricks). Moreover, this registry should be stateless, so we can easily to scale up to multiple machines. ![](https://i.imgur.com/3FQcW99.png) ![](https://i.imgur.com/9xBeEri.jpg) **FlytePropeller Backend System Plugin**: New web api plugin used to send the request to flytekit backend service to create a job on an external platform. ### Create Job ```sequence Propeller->Grpc API Server: REST (Task spec) Grpc API Server->BigQuery: REST (BQ job Spec) BigQuery->Grpc API Server: Job Id Grpc API Server->Propeller: Job Id ``` ### Poll Job ```sequence Propeller->Async Cache: Create Cache Async Cache->Grpc API Server: REST (Job Id) Grpc API Server->BigQuery: REST (Job Id) BigQuery->Grpc API Server: Job State, Message Grpc API Server->Async Cache: Job State, Message Propeller->Async Cache: Fetch Cache ``` ### Register a backend plugin Users should be able to write the plugin using a rest-like interface. In this proposal we recommend using a simplified form of WebAPI plugins. the goal of the plugins is to enable the following functions It should be possible to implement this using a Web Service framework like `FastAPI`. Raw implementation for a `fastAPI` like server can be as follows. **Note**: It should be possible to implement multiple **resource** plugins per python library. Thus each resource should be delimited. ```python= from fastapi import FastAPI from flytekit.backend.plugins import TaskInfo, IO, PollResultSuccess, PollResultFailure, OperationInProgress, PollResult app = FastAPI() @app.put("/plugins/v1/{task_type}/{version}") def create(task_info: TaskInfo) -> ResourceInfo: """ Creates resource. return job_id, error code, message 200 Job was created. 401 The request was unauthorized. 500 The request was not handled correctly due to a server error. """ return {"job_id": job_id, "error_code": error_code, "message": message} @app.get("/plugins/v1/{task_type}/{version}") async def poll(resource_id: int, task_info: TaskInfo, io: IO, resource_info: ResourceInfo) -> PollResult: """ Retrieves resource and returns the current observable status return job_spec, job_state (succeed, failed, running), error core, message. 200 Job was retrieved successfully. 400 The request was malformed. See JSON response for error details. 401 The request was unauthorized. 500 The request was not handled correctly due to a server error. """ if resp.state == "success": state = succeed elif resp.state == "failure": state = failed elif resp.state == "running": state = running return {"job_spec": job_spec, "job_state": state, "error_code": error_code, "message": message} @app.delete("/plugins/v1/{task_type}/{version}") async def delete_res(resource_id: str): """ Delete the resource return job_id, error core, message. 200 Job was deleted successfully. 400 The request was malformed. See JSON response for error details. 401 The request was unauthorized. 500 The request was not handled correctly due to a server error. """ return {"job_id": job_id, "error_code": error_code, "message": message} ``` **Ideally**, we should provide a simplified interface to this in flytekit. This would mean that the flytekit plugin can simply use this interface to create a local plugin and a backendplugin. ```python= class BackendPluginBase: def __init__(self, task_type: str, version: str = "v1"): self._task_type = task_type self._version = version @property def task_type(self) -> str: return self._task_type @property def version(self) -> str: return self._version @abstractmethod async def create(self): pass @abstractmethod async def poll(self): pass @abstractmethod async def delete(self): pass BackendPluginRegistry.register(BQPlugin()) ``` ### (Alternative) GRPC Backend Server ```python= class BackendPluginServer(BackendPluginServiceServicer): def CreateTask(self, request: plugin_system_pb2.TaskCreateRequest, context) -> plugin_system_pb2.TaskCreateResponse: req = TaskCreateRequest.from_flyte_idl(request) plugin = BackendPluginRegistry.get_plugin(req.template.type) return plugin.create(req.inputs, req.output_prefix, req.template) def GetTask(self, request: plugin_system_pb2.TaskGetRequest, context): plugin = BackendPluginRegistry.get_plugin(request.task_type) return plugin.get(job_id=request.job_id, output_prefix=request.output_prefix, prev_state=request.prev_state) def DeleteTask(self, request: plugin_system_pb2.TaskDeleteRequest, context): plugin = BackendPluginRegistry.get_plugin(request.task_type) return plugin.delete(request.job_id) ``` # Register a New plugin ### Run a Flytekit Backend Plugin The workflow code running Snowflake, Databricks should not be changed. We can add a new config `enable_backend_flytekit_plugin_system`. If it's true, the job will be handled by plugin system. If can't find the plugin in the registry, falling back to use the default web api plugin in the propeller. ### Secrets Mmanagement Secrets management should not be imposed using Flyte’s convention, though we should provide a simplified secrets reader using flytekits secret system? ## Backend Plugin System Deployment There are two options to deploy backend plugin system. ### 1. All the plugin running in one deployment Pros: * Easy to maintain. * One image, and one deployment yaml file. Cons: * Dependecy conflict between two plugins. * Need to restart the deployment and rebuild the image when we add a new backend plugin to flytekit. ### 2. One plugin per deployment Pros: * We can scale up the specific plugin deployments when the reqeusts increase in some plugins. * Only need to deploy the plugins that people will use. Cons: * Hard to maintain. (tons of images, and deployment yaml files) ### Deployment yaml Backend plugin system can be run in the deployment independently. Because it's stateless, we can just scale up the replica if request increases. This yaml file can be added into the Flyte helm chart (`flyte-core`). ```ymal= apiVersion: apps/v1 kind: Deployment metadata: name: backend-plugin-system labels: app: backend-plugin-system spec: replicas: 1 selector: matchLabels: app: backend-plugin-system template: metadata: labels: app: backend-plugin-system spec: containers: - name: backend-plugin-system image: pingsutw/backend-plugin-system:v1 ports: - containerPort: 8000 --- apiVersion: v1 kind: Service metadata: name: backend-plugin-system spec: selector: app: backend-plugin-system ports: - protocol: TCP port: 8000 targetPort: 8000 ``` ### Docker Image ```dockerfile= FROM python:3.9-slim-buster MAINTAINER Flyte Team <users@flyte.org> LABEL org.opencontainers.image.source=https://github.com/flyteorg/flytekit WORKDIR /root ENV PYTHONPATH /root RUN apt-get update && apt-get install -y git RUN pip install "git+https://github.com/flyteorg/flytekit@backend-plugin-system" RUN pip install fastapi uvicorn[standard] RUN pip install numpy==1.23.1 CMD uvicorn flytekit.extend.backend.fastapi:app --host 0.0.0.0 --port 8000 ``` ## Authentication - [Authentication with FastAPI](https://www.freecodecamp.org/news/how-to-add-jwt-authentication-in-fastapi/) - [Network Policies](https://kubernetes.io/docs/concepts/services-networking/network-policies/) ## Phase 1 (POC) - **Flytekit**: Use Fast api to create a beckend plugin service that can submit the job to Bigquery or Databricks. - **FlytePropeller**: Add a web api plugin that can talk to flytekit backend plugin service. ## Phase 2 - **Authentication** - only propeller and users having access token can submit the job to beckend plugin system. - **Deployment**: Add beckend plugin system deployment to the helm chart. - **Benchmark**: Measure the overhead, and improve the performance. ## Open Question: 1. Should we provide a way to deploy these plugins using Flyte? IMO this should be optional and not required for MVP? 2. We could implement something similar for golang ## Benchmark Compare the memory and CPU consumption of the FastAPI server with that of the current Propeller server. ![](https://i.imgur.com/EXXmdyt.png) The round latency between grpc and fastAPI server. ![](https://i.imgur.com/hp8wss4.png =50%x) The round latency between grpc and current propeller. ![](https://i.imgur.com/42mdktu.png =50%x)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully