All Projects → firdaus → Cadence Python

firdaus / Cadence Python

Licence: mit
Python framework for Cadence Workflow Service

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Cadence Python

Hark Lang
Build stateful and portable serverless applications without thinking about infrastructure.
Stars: ✭ 103 (+3%)
Mutual labels:  microservices, orchestration
Baker
Orchestrate microservice-based process flows
Stars: ✭ 233 (+133%)
Mutual labels:  microservices, orchestration
Genie
Distributed Big Data Orchestration Service
Stars: ✭ 1,544 (+1444%)
Mutual labels:  microservices, orchestration
Xstate
State machines and statecharts for the modern web.
Stars: ✭ 18,300 (+18200%)
Mutual labels:  workflow, orchestration
Prefect
The easiest way to automate your data
Stars: ✭ 7,956 (+7856%)
Mutual labels:  workflow, orchestration
Zeebe
Distributed Workflow Engine for Microservices Orchestration
Stars: ✭ 2,165 (+2065%)
Mutual labels:  microservices, workflow
Netramesh
Ultra light service mesh for any orchestrator
Stars: ✭ 175 (+75%)
Mutual labels:  microservices, orchestration
zenaton-ruby
💎 Ruby gem to run and orchestrate background jobs with Zenaton Workflow Engine
Stars: ✭ 32 (-68%)
Mutual labels:  workflow, orchestration
Service Fabric
Service Fabric is a distributed systems platform for packaging, deploying, and managing stateless and stateful distributed applications and containers at large scale.
Stars: ✭ 2,874 (+2774%)
Mutual labels:  microservices, orchestration
Service Fabric
We've moved!
Stars: ✭ 258 (+158%)
Mutual labels:  microservices, orchestration
Jdonframework
Domain-Driven-Design Pub/Sub Domain-Events framework
Stars: ✭ 978 (+878%)
Mutual labels:  microservices, workflow
Walkoff
A flexible, easy to use, automation framework allowing users to integrate their capabilities and devices to cut through the repetitive, tedious tasks slowing them down. #nsacyber
Stars: ✭ 855 (+755%)
Mutual labels:  workflow, orchestration
Server
The Prefect API and backend
Stars: ✭ 87 (-13%)
Mutual labels:  workflow, orchestration
Dockerfiles
Base Dockerfiles && Amazing Dockerfiles && Microservices Dockerfiles
Stars: ✭ 94 (-6%)
Mutual labels:  microservices
Api2html
Using the data from your API, generate the HTML on the fly! Server-side rendering of the mustache templates
Stars: ✭ 97 (-3%)
Mutual labels:  microservices
Jetpack
🚀 Jetpack – Webpack made more convenient.
Stars: ✭ 1,326 (+1226%)
Mutual labels:  workflow
My Cheat Sheets
A place to keep all my cheat sheets for the complete development of ASIC/FPGA hardware or a software app/service.
Stars: ✭ 94 (-6%)
Mutual labels:  microservices
Actionview
An issue tracking tool based on laravel+reactjs for small and medium-sized enterprises, open-source and free, similar to Jira.
Stars: ✭ 1,357 (+1257%)
Mutual labels:  workflow
Grpcjsontranscoder
A filter which allows a RESTful JSON API client to send requests to .NET web server over HTTP and get proxied to a gRPC service
Stars: ✭ 97 (-3%)
Mutual labels:  microservices
Aktion
Translates GitHub Actions into Tekton and Knative Objects
Stars: ✭ 94 (-6%)
Mutual labels:  workflow

Intro: Fault-Oblivious Stateful Python Code

cadence-python allows you to create Python functions that have their state (local variables etc..) implicitly saved such that if the process/machine fails the state of the function is not lost and can resume from where it left off.

This programming model is useful whenever you need to ensure that a function runs to completion. For example:

  • Business logic involving multiple micro services
  • CI/CD pipelines
  • Data pipelines
  • RPA
  • ETL
  • Marketing automation / Customer journeys / Customer engagement
  • Zapier/IFTTT like end user automation.
  • Chat bots
  • Multi-step forms
  • Scheduler/Cron jobs

Behind the scenes, cadence-python uses Cadence as its backend.

For more information about the fault-oblivious programming model refer to the Cadence documentation here

Install Cadencce

wget https://raw.githubusercontent.com/uber/cadence/master/docker/docker-compose.yml
docker-compose up

Register sample domain

docker run --network=host --rm ubercadence/cli:master --do sample domain register -rd 1

Installation cadence-python

pip install cadence-client==1.0.1

Hello World Sample

import sys
import logging
from cadence.activity_method import activity_method
from cadence.workerfactory import WorkerFactory
from cadence.workflow import workflow_method, Workflow, WorkflowClient

logging.basicConfig(level=logging.DEBUG)

TASK_LIST = "HelloActivity-python-tasklist"
DOMAIN = "sample"


# Activities Interface
class GreetingActivities:
    @activity_method(task_list=TASK_LIST, schedule_to_close_timeout_seconds=2)
    def compose_greeting(self, greeting: str, name: str) -> str:
        raise NotImplementedError


# Activities Implementation
class GreetingActivitiesImpl:
    def compose_greeting(self, greeting: str, name: str):
        return f"{greeting} {name}!"


# Workflow Interface
class GreetingWorkflow:
    @workflow_method(execution_start_to_close_timeout_seconds=10, task_list=TASK_LIST)
    async def get_greeting(self, name: str) -> str:
        raise NotImplementedError


# Workflow Implementation
class GreetingWorkflowImpl(GreetingWorkflow):

    def __init__(self):
        self.greeting_activities: GreetingActivities = Workflow.new_activity_stub(GreetingActivities)

    async def get_greeting(self, name):
        # Place any Python code here that you want to ensure is executed to completion.
        # Note: code in workflow functions must be deterministic so that the same code paths
        # are ran during replay.
        return await self.greeting_activities.compose_greeting("Hello", name)


if __name__ == '__main__':
    factory = WorkerFactory("localhost", 7933, DOMAIN)
    worker = factory.new_worker(TASK_LIST)
    worker.register_activities_implementation(GreetingActivitiesImpl(), "GreetingActivities")
    worker.register_workflow_implementation_type(GreetingWorkflowImpl)
    factory.start()

    client = WorkflowClient.new_client(domain=DOMAIN)
    greeting_workflow: GreetingWorkflow = client.new_workflow_stub(GreetingWorkflow)
    result = greeting_workflow.get_greeting("Python")
    print(result)

    print("Stopping workers....")
    worker.stop()
    print("Workers stopped...")
    sys.exit(0)

Status / TODO

cadence-python is still under going heavy development. It should be considered EXPERIMENTAL at the moment. A production version is targeted to be released in September of 2019 January 2020 March 2020 April 2020.

1.0

  • [x] Tchannel implementation
  • [x] Python-friendly wrapper around Cadence's Thrift API
  • [x] Author activities in Python
  • [x] Start workflows (synchronously)
  • [x] Create workflows
  • [x] Workflow execution in coroutines
  • [x] Invoke activities from workflows
  • [x] ActivityCompletionClient heartbeat, complete, complete_exceptionally
  • [x] Activity heartbeat, getHeartbeatDetails and doNotCompleteOnReturn
  • [x] Activity retry
  • [x] Activity getDomain(), getTaskToken(), getWorkflowExecution()
  • [x] Signals
  • [x] Queries
  • [x] Async workflow execution
  • [x] await
  • [x] now (currentTimeMillis)
  • [x] Sleep
  • [x] Loggers
  • [x] newRandom
  • [x] UUID
  • [x] Workflow Versioning
  • [x] WorkflowClient.newWorkflowStub(Class workflowInterface, String workflowId);

1.1

  • [ ] ActivityStub and Workflow.newUntypedActivityStub
  • [ ] Classes as arguments and return values to/from activity and workflow methods
  • [ ] WorkflowStub and WorkflowClient.newUntypedWorkflowStub
  • [ ] Custom workflow ids through start() and new_workflow_stub()
  • [ ] ContinueAsNew
  • [ ] Compatibility with Java client
  • [ ] Compatibility with Golang client

2.0

  • [ ] Sticky workflows

Post 2.0:

  • [ ] sideEffect/mutableSideEffect
  • [ ] Local activity
  • [ ] Parallel activity execution
  • [ ] Timers
  • [ ] Cancellation Scopes
  • [ ] Child Workflows
  • [ ] Explicit activity ids for activity invocations
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].